Python Yahoo Finance没有提供输出

时间:2016-11-15 16:14:21

标签: python yahoo-finance

我正在尝试运行下面的代码并且它没有给我任何输出,而我所有其他Python程序(不使用Yahoo Finance Library)工作正常。我做错了什么?

import yahoo_finance
from pylab import *
import numpy as np
import scipy.signal as sc
import matplotlib.pyplot as plt
import pandas as pd
import datetime as dt

ticker = 'GLD'
begdate = '2014-11-11'
enddate = '2016-11-11'
data = yahoo_finance.Share('GLD')
data1 = data.get_historical(begdate,enddate)
gld_df = pd.DataFrame(data1)
date_df = pd.to_datetime((list(gld_df["Date"])))
adj_close_df = list(gld_df["Adj_Close"])
plt.plot(date_df,adj_close_df)
plt.title("SPDR Gold Shares ")

detrend = sc.detrend(adj_close_df)
plt.plot(date_df,detrend)
plt.title("SPDR Gold Detrend Prices")

这是我最终得到的错误。我是Python的新手,我不确定这意味着什么。

我使用的是Python3.x,Anaconda。该脚本昨天工作正常。

Traceback (most recent call last):

  File "<ipython-input-3-6c3ded7287fd>", line 1, in <module>
    runfile('D:/Quant/MSQF/4 - Algorithms 1/3-Sorting/Mini Project 2.py', wdir='D:/Quant/MSQF/4 - Algorithms 1/3-Sorting')

  File "D:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
    execfile(filename, namespace)

  File "D:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/Quant/MSQF/4 - Algorithms 1/3-Sorting/Mini Project 2.py", line 19, in <module>
    data = yahoo_finance.Share('GLD')

  File "D:\Anaconda\lib\site-packages\yahoo_finance\__init__.py", line 178, in __init__
    self.refresh()

  File "D:\Anaconda\lib\site-packages\yahoo_finance\__init__.py", line 142, in refresh
    self.data_set = self._fetch()

  File "D:\Anaconda\lib\site-packages\yahoo_finance\__init__.py", line 181, in _fetch
    data = super(Share, self)._fetch()

  File "D:\Anaconda\lib\site-packages\yahoo_finance\__init__.py", line 134, in _fetch
    data = self._request(query)

  File "D:\Anaconda\lib\site-packages\yahoo_finance\__init__.py", line 118, in _request
    response = yql.YQLQuery().execute(query)

  File "D:\Anaconda\lib\site-packages\yahoo_finance\yql.py", line 60, in execute
    return simplejson.loads(self.connection.getresponse().read())

  File "D:\Anaconda\lib\http\client.py", line 1197, in getresponse
    response.begin()

  File "D:\Anaconda\lib\http\client.py", line 297, in begin
    version, status, reason = self._read_status()

  File "D:\Anaconda\lib\http\client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"

RemoteDisconnected: Remote end closed connection without response

0 个答案:

没有答案