简体   繁体   English

我如何让外汇行情在雅虎金融工作?

[英]How do I get a forex ticker working in yahoo finance?

When I use any ticker that isn't a forex pair it works.当我使用任何不是外汇对的股票代码时,它就可以工作。 But with the fx tickers it doesn't.但是对于 fx 代码,它不会。 I end up getting an error.我最终得到一个错误。

from yahoo_fin.stock_info import get_live_price
get_live_price('EURUSD=X')

Below Is the error I encountered.下面是我遇到的错误。

---------------------------------------------------------------------------
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

any ideas?有任何想法吗? It' clearly something to do with the ticker.这显然与股票行情有关。 When I use 'nflx' or 'aapl' it works like a charm.当我使用“nflx”或“aapl”时,它就像一个魅力。 It's with forex that it seems to misbehave?外汇交易似乎行为不端?

That is the same error you get if the tag is made up trash.如果标签是由垃圾组成的,这与您得到的错误相同。 Could you be trying to request a malformed tag/ticker?您可以尝试请求格式错误的标签/代码吗?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM