Ich bekomme einige sehr seltsame Ergebnisse mit Python und Yahoo-Finance-Paket. Wenn ich meine Funktion für einzelne Aktiensymbole verwende, führt die Funktion OK aus. Aber wenn ich sie in eine Schleife setze (hoffe später, die Liste zu erweitern), habe ich einige Fehlercodes von YQL bekommen. Ist jemand auf ähnliche Fehler gestoßen oder habe ich etwas übersehen? Siehe den folgenden Code und die Ausgaben. Entschuldigung, relativ neu in Python. Danke für jede Hilfe!Python und Yahoo Finanzen seltsam "YQLQueryError (Antwort ['Fehler'] ['Beschreibung'])" get_historical
t1=m1('AAPL')
t2=m1('MSFT')
df1=['MSFT','APPL']
print(t1)
print(t2)
for stock in df1:
print(type(stock))
for stock in df1:
m1(stock)
Adj_Close Close High Low Open Symbol \
Date
2016-01-04 102.612183 105.349998 105.370003 102.000000 102.610001 AAPL
2016-01-05 100.040792 102.709999 105.849998 102.410004 105.750000 AAPL
2016-01-06 98.083025 100.699997 102.370003 99.870003 100.559998 AAPL
2016-01-07 93.943473 96.449997 100.129997 96.430000 98.680000 AAPL
Volume price_gap target
Date
2016-01-04 67649400 NaN 0.026703
2016-01-05 55791000 0.003797 -0.028747
2016-01-06 68457400 -0.020933 0.001392
2016-01-07 81094400 -0.020060 -0.022598
Adj_Close Close High Low Open Symbol \
Date
2016-01-04 53.015032 54.799999 54.799999 53.389999 54.320000 MSFT
2016-01-05 53.256889 55.049999 55.389999 54.540001 54.930000 MSFT
2016-01-06 52.289462 54.049999 54.400002 53.639999 54.320000 MSFT
2016-01-07 50.470697 52.169998 53.490002 52.070000 52.700001 MSFT
Volume price_gap target
Date
2016-01-04 53778000 NaN 0.008837
2016-01-05 34079700 0.002372 0.002185
2016-01-06 39518900 -0.013261 -0.004971
2016-01-07 56564900 -0.024977 -0.010057
<class 'str'>
<class 'str'>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
//anaconda/lib/python3.5/site-packages/yahoo_finance/__init__.py in _request(self, query)
119 try:
--> ====120 _, results = response['query']['results'].popitem()
121 except (KeyError, StopIteration, AttributeError):
Attribute: 'NoneType' Objekt kein Attribut 'popitem' hat
Während der oben genannten Ausnahmebehandlung, eine weitere Ausnahme aufgetreten:
KeyError Traceback (most recent call last)
//anaconda/lib/python3.5/site-packages/yahoo_finance/__init__.py in _request(self, query)
122 try:
--> 123 raise YQLQueryError(response['error']['description'])
124 except KeyError:
KeyError: 'error'
During handling of the above exception, another exception occurred:
YQLResponseMalformedError Traceback (most recent call last)
<ipython-input-144-fb031b50c461> in <module>()
11 for stock in df1:
12 print(type(stock))
---> 13 m1(stock)
14
15 for stock in df1:
<ipython-input-143-7724677970e7> in m1(msft, d1, d2)
1 def m1(msft,d1='2016-1-4',d2='2016-1-7'):
2 msft=Share(msft)
----> 3 msft_p = msft.get_historical(start_date=d1, end_date=d2)
4 msft_prices=pd.DataFrame(msft_p)
5 msft_prices[['Open','Close','Volume','High','Low','Adj_Close']]=msft_prices[['Open','Close','Volume','High','Low','Adj_Close']].apply(pd.to_numeric)
//anaconda/lib/python3.5/site-packages/yahoo_finance/__init__.py in get_historical(self, start_date, end_date)
340 try:
341 query = self._prepare_query(table='historicaldata', startDate=s, endDate=e)
-> 342 Ergebnis = self._request (Abfrage) 343, wenn isinstance (Ergebnis dict): 344 result = [Ergebnis]
//anaconda/lib/python3.5/site-packages/yahoo_finance/__init__.py in _request(self, query)
123 raise YQLQueryError(response['error']['description'])
124 except KeyError:
--> 125 raise YQLResponseMalformedError()
126 else:
127 if self._is_error_in_results(results):
YQLResponseMalformedError: Response malformed.
Vielleicht Yahoo- Finanzpaket die Funktion deaktivieren, wenn mehrere Datenanrufe erkannt werden? – user4224870
Mögliches Duplikat von [Yahoo finance ichart service Verfügbarkeit] (https://stackoverflow.com/questions/44040042/yahoo-finance-ichart-service-availability) –