下面的代码用于创建下面的输出:
from yahooquery import Ticker
# Fetching data for AAPL
aapl = Ticker('AAPL')
types = ['asOfDate', 'TangibleBookValue', 'ShareIssued']
financial_data = aapl.get_financial_data(types, trailing=False)
# Dropping specific columns
columns_to_exclude = ['periodType', 'currencyCode']
financial_data.drop(columns=columns_to_exclude, inplace=True)
print(financial_data)
输出:
我想从history module中添加一个额外的列,它根据相应的asOfDate获取adjclose的价格. 所以输出应该是:
下面是获取价格历史数据的示例代码,其输出如下:
tickers = Ticker('aapl', asynchronous=True)
# Default period = ytd, interval = 1d
df = tickers.history(start='2019-01-01', end='2023-12-31')
df.head()