我从一个非常简单的代码调用yahoo_fin.options.get_expiration_dates()
,因此不太可能加载相同名称的其他模块。
我的整个代码是这样:
import matplotlib.pyplot as plt
import pandas as pd
from numpy import *
from yahoo_fin import options
plt.style.use("seaborn")
expirationDates = options.get_expiration_dates("goog")
最后一行的输出是:
NameError: name 'HTMLSession' is not defined
您能帮我了解发生了什么吗?
您是否安装了request-html?
pip install requests-html
该软件包仅支持python 3.6。
或者,还有另一个名为yahooquery的程序包,该程序包还将检索给定代码的所有到期日期的选项。适用于python 2.7、3.5 +。
Ticker(‘<ticker>’).option_chain
将返回一个数据帧。