Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Yahoo!Finance data on ScraperWiki
#!/usr/bin/env python
Save stock ticker data from Yahoo! Finance to sqlite.
import datetime as d
import sqlite3
import as web
import as sql
# Get the data
frame = (web.DataReader('FB', # ticker symbol
'yahoo', # web service
d.datetime(2010, 3, 1), #start date #end date
# Wrangle the date field
frame = frame.reset_index()
frame[['Date']] = frame[['Date']].applymap(lambda x: x.isoformat())
# Write to the database
sql.write_frame(frame, 'stockdata', sqlite3.connect("scraperwiki.sqlite"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.