繁体   English   中英

Python yahoo Finance error market_cap=int(data.get_quote_yahoo(str)['marketCap']) TypeError: 'int' object is not callable

[英]Python yahoo finance error market_cap=int(data.get_quote_yahoo(str)['marketCap']) TypeError: 'int' object is not callable

我正在尝试从 yfinance(在 repl.it 中工作)获取有关各种公司市值的数据,但在第一次停止工作后

import yfinance as yf
import numpy as np
from pandas_datareader import data

Tickers=["AAPL","GOOG","RY","HPQ"]
UndervaluedCompanies=[]

for str in Tickers:
  tickers = [(str)]
  print(tickers)

  market_cap=int(data.get_quote_yahoo(str)['marketCap'])

  stock= yf.Ticker(str)
  earnings=(stock.earnings)

  List=([earnings[i].tolist() for i in earnings.columns])
  profit=(List[1])

  for int in profit:
    ratio=(market_cap/int)
    print(ratio)

我想 go 并找到列表中所有股票的市盈率比率,但它没有获得市值数据

你可以这样做

import pandas_datareader as web

tickers=["AAPL","GOOG","RY","HPQ"]

# Get market cap (not really necessary for you)
market_cap_data = web.get_quote_yahoo(tickers)['marketCap']

# Get the P/E ratio directly
pe_data = web.get_quote_yahoo(tickers)['trailingPE']

# print stock and p/e ratio
for stock, pe in zip(tickers, pe_data):
    print(stock, pe)

# More keys that can be used
      ['language', 'region', 'quoteType', 'triggerable', 'quoteSourceName',
       'currency', 'preMarketChange', 'preMarketChangePercent',
       'preMarketTime', 'preMarketPrice', 'regularMarketChange',
       'regularMarketChangePercent', 'regularMarketTime', 'regularMarketPrice',
       'regularMarketDayHigh', 'regularMarketDayRange', 'regularMarketDayLow',
       'regularMarketVolume', 'regularMarketPreviousClose', 'bid', 'ask',
       'bidSize', 'askSize', 'fullExchangeName', 'financialCurrency',
       'regularMarketOpen', 'averageDailyVolume3Month',
       'averageDailyVolume10Day', 'fiftyTwoWeekLowChange',
       'fiftyTwoWeekLowChangePercent', 'fiftyTwoWeekRange',
       'fiftyTwoWeekHighChange', 'fiftyTwoWeekHighChangePercent',
       'fiftyTwoWeekLow', 'fiftyTwoWeekHigh', 'dividendDate',
       'earningsTimestamp', 'earningsTimestampStart', 'earningsTimestampEnd',
       'trailingAnnualDividendRate', 'trailingPE',
       'trailingAnnualDividendYield', 'marketState', 'epsTrailingTwelveMonths',
       'epsForward', 'sharesOutstanding', 'bookValue', 'fiftyDayAverage',
       'fiftyDayAverageChange', 'fiftyDayAverageChangePercent',
       'twoHundredDayAverage', 'twoHundredDayAverageChange',
       'twoHundredDayAverageChangePercent', 'marketCap', 'forwardPE',
       'priceToBook', 'sourceInterval', 'exchangeDataDelayedBy', 'tradeable',
       'firstTradeDateMilliseconds', 'priceHint', 'exchange', 'shortName',
       'longName', 'messageBoardId', 'exchangeTimezoneName',
       'exchangeTimezoneShortName', 'gmtOffSetMilliseconds', 'market',
       'esgPopulated', 'price']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM