Created
January 1, 2018 01:19
-
-
Save khuangaf/7c362bd27e587ec64dda0688086e4302 to your computer and use it in GitHub Desktop.
CrytocurrencyPrediction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import numpy as np | |
import os | |
import pandas as pd | |
import urllib2 | |
# connect to poloniex's API | |
url = 'https://poloniex.com/public?command=returnChartData¤cyPair=USDT_BTC&start=1356998100&end=9999999999&period=300' | |
# parse json returned from the API to Pandas DF | |
openUrl = urllib2.urlopen(url) | |
r = openUrl.read() | |
openUrl.close() | |
d = json.loads(r.decode()) | |
df = pd.DataFrame(d) | |
original_columns=[u'close', u'date', u'high', u'low', u'open'] | |
new_columns = ['Close','Timestamp','High','Low','Open'] | |
df = df.loc[:,original_columns] | |
df.columns = new_columns | |
df.to_csv('data/bitcoin2015to2017.csv',index=None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment