首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >历史库存数据错误

历史库存数据错误
EN

Stack Overflow用户
提问于 2017-06-26 07:51:10
回答 2查看 1.8K关注 0票数 3

当我试图从雅虎或谷歌(我都试过了)检索股票价格时,它总是返回这个错误。我不知道它是什么意思,也不知道如何修复它。我以前用过这段代码,它工作得很好。你能帮我解决这个错误和解决方案吗?谢谢。

代码语言:javascript
复制
import datetime as dt
import pandas as pd
import pandas_datareader.data as web


start = dt.datetime(2000,1,1)
end = dt.datetime(2004,1,1)

df= web.DataReader('TSLA', 'yahoo', start, end)
print(df.head)

servname : HTTPConnectionPool(host='ichart.finance.yahoo.com',port=80):超过url: /table.csv?a=0&ignore=.csv&s=TSLA&b=1&e=1&d=0&g=d&f=2004&c=2000的最大重试次数(由ConnectionError(‘:无法建立新连接: Errno 8 port=80或servname未提供,或未知’)引起)

EN

回答 2

Stack Overflow用户

发布于 2017-10-24 19:44:49

只需更改此部分即可:

df=web.DataReader("TSLA","yahoo",start,end) to:df=web.DataReader("TSLA","google",start,end)

这里的问题出在雅虎搜索引擎上。所以希望这能解决这个问题。

票数 1
EN

Stack Overflow用户

发布于 2017-08-01 23:52:04

以下是我发现的一种解决方法:

代码语言:javascript
复制
# Define the instruments to download. We would like to see Apple, Microsoft and the S&P500 index.
tickers = ['AAPL', 'MSFT', 'SPY']

# Define which online source one should use
data_source = 'google'

# We would like all available data from 01/01/2000 until 12/31/2016.
start_date = '2010-01-01'
end_date = '2016-12-31'

# User pandas_reader.data.DataReader to load the desired data. As simple as that.
panel_data = data.DataReader(tickers, data_source, start_date, end_date)

# Getting just the adjusted closing prices. This will return a Pandas DataFrame
# The index in this DataFrame is the major index of the panel_data.
close = panel_data.ix['Close']

# Getting all weekdays between 01/01/2000 and 12/31/2016
all_weekdays = pd.date_range(start=start_date, end=end_date, freq='B')

# How do we align the existing prices in adj_close with our new set of dates?
# All we need to do is reindex close using all_weekdays as the new index
close = close.reindex(all_weekdays)

close.head(10)

来自http://www.learndatasci.com/python-finance-part-yahoo-finance-api-pandas-matplotlib/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44751606

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档