gpt4 book ai didi

python - 如何在 Python 中使用 pandas-datareader 提取看涨期权/看跌期权价格?

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:49 27 4
gpt4 key购买 nike

我有以下代码。我尝试从雅虎和谷歌获取数据,但都不起作用。它抛出以下消息

from pandas_datareader.data import Options

fb_options = Options('TSLA', 'yahoo')
options_df = fb_options.get_options_data(expiry=fb_options.expiry_dates[0])

print(options_df.tail())

Error Message: Yahoo Options has been immediately deprecated due to large breaks in the API without theintroduction of a stable replacement. Pull Requests to re-enable these dataconnectors are welcome.

还有其他方法可以检索期权价格吗?

最佳答案

以下内容现在对我有用

import yfinance as yf # https://github.com/ranaroussi/yfinance
aapl= yf.Ticker("AAPL")
# aapl.options # list of dates
DF_calls, DF_puts = aapl.option_chain(aapl.options[0]) # returns 2 DataFrames

替代方法

import  pandas_datareader as pdr
aapl = Options('aapl')
calls = aapl.get_call_data()

部分输出:

Last    Bid Ask Chg Vol Open_Int    IV  Underlying_Price    Last_Trade_Date                                 
200.0 2020-07-02 call AAPL200702C00200000 164.50 151.60 156.20 0.000000 13.0 13.0 1.962891 353.63 2020-06-23 13:30:03

Link to my project code

关于python - 如何在 Python 中使用 pandas-datareader 提取看涨期权/看跌期权价格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54384110/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com