[英]How do I get a forex ticker working in yahoo finance?
當我使用任何不是外匯對的股票代碼時,它就可以工作。 但是對於 fx 代碼,它不會。 我最終得到一個錯誤。
from yahoo_fin.stock_info import get_live_price
get_live_price('EURUSD=X')
下面是我遇到的錯誤。
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-a1b6fb5ddbd7> in <module>
4
5 #Stock = input('Stock:')
----> 6 get_live_price('EURUSD=X')
7 #stockprice = get_live_price(str(Stock))
8
//anaconda3/lib/python3.7/site-packages/yahoo_fin/stock_info.py in get_live_price(ticker)
336 '''
337
--> 338 df = get_data(ticker, end_date = pd.Timestamp.today() + pd.DateOffset(10))
339
340
//anaconda3/lib/python3.7/site-packages/yahoo_fin/stock_info.py in get_data(ticker, start_date, end_date, index_as_date)
58 html = html.decode()
59
---> 60 start = html.index('"HistoricalPriceStore"')
61 end = html.index("firstTradeDate")
62
ValueError: substring not found
有任何想法嗎? 這顯然與股票行情有關。 當我使用“nflx”或“aapl”時,它就像一個魅力。 外匯交易似乎行為不端?
如果標簽是由垃圾組成的,這與您得到的錯誤相同。 您可以嘗試請求格式錯誤的標簽/代碼嗎?
In [12]: from yahoo_fin.stock_info import get_live_price
...: get_live_price('poop')
...:
...:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-17c9a30a78a2> in <module>
1 from yahoo_fin.stock_info import get_live_price
----> 2 get_live_price('poop')
3
~/anaconda3/lib/python3.7/site-packages/yahoo_fin/stock_info.py in get_live_price(ticker)
336 '''
337
--> 338 df = get_data(ticker, end_date = pd.Timestamp.today() + pd.DateOffset(10))
339
340
~/anaconda3/lib/python3.7/site-packages/yahoo_fin/stock_info.py in get_data(ticker, start_date, end_date, index_as_date)
58 html = html.decode()
59
---> 60 start = html.index('"HistoricalPriceStore"')
61 end = html.index("firstTradeDate")
62
ValueError: substring not found
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.