python监控股价_如何使用Python下载股价数据?

I have installed pandas-datareader but I'm wondering if there are alternatives.

So far, I'm using this:

import pandas_datareader.data as web

start_date = '2018-01-01'

end_date = '2018-06-08'

panel_data = web.DataReader('SPY', 'yahoo', start_date, end_date)

解决方案

Yahoo Finance is one of the free sources to get stock data. You can get the data either using pandas datareader or can get using yfinance library. The method to get data from yfinance library is shown below.

import yfinance as yf

# Get the data of the stock AAPL

data = yf.download('AAPL','2016-01-01','2019-08-01')

Wiki is one of the free source available on quandl to get the data for the 3000+ US equities. This is a community maintained data. Recently it is stopped being maintained but however, it is a good free source to backtest your strategies.

To get the data, you need to get the free API key from quandl and replace the in the below code with your API key.

# Import the quandl package

import quandl

# Get the data from quandl

data = quandl.get("WIKI/KO", start_date="2016-01-01", end_date="2018-01-01",

api_key=)

Note:

Quandl requires NumPy (v1.8 or above) and pandas (v0.14 or above) to work.

To get your API key, sign up for a free Quandl account. Then, you can find your API key on Quandl account settings page.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值