我有以下代码。我尝试从雅虎和谷歌获取数据,但都不起作用。它抛出以下消息
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
我是一名优秀的程序员,十分优秀!