我如何获得在Yahoo Finance中使用的外汇报价器?

问题描述 投票:0回答:1

[当我使用不是外汇对的任何股票时,它会起作用。但是使用外汇行情自动收录器却没有。我最终得到一个错误。

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'时,它就像一种魅力。它似乎与外汇交易有关?

python finance yahoo yahoo-finance stock
1个回答
0
投票

如果将标签制成垃圾桶,则会遇到相同的错误。您可以尝试请求格式错误的标记/代码吗?

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
© www.soinside.com 2019 - 2024. All rights reserved.