Wednesday, 29 January 2014

Retrieving historical financial data with python

Requirements

  • ystockquote 
  • pandas

Here is the sample python code, which will retrieve historical data from yahoo on any financial instrument (e.g. Google).

import pandas as pd
from pandas import Series, DataFrame
import ystockquote
his1 = ystockquote.get_historical_prices('GOOG', '2013-01-01', '2014-01-01')
stock1 = DataFrame(his1)
print stock1
##if you just want e.g. the closing price
close_s1 = stock1.ix['Close']
print close_s1
view raw ystockquote1 hosted with ❤ by GitHub

No comments:

Post a Comment

How to download a portion of Youtube Video with youtube-dl

First make you have both youtube-dl and ffmpeg installed: sudo apt install youtube-dl ffmpeg Then download a portion of your desired...