Skip to content

Instantly share code, notes, and snippets.

@khuangaf
Created January 1, 2018 01:19
Show Gist options
  • Save khuangaf/7c362bd27e587ec64dda0688086e4302 to your computer and use it in GitHub Desktop.
Save khuangaf/7c362bd27e587ec64dda0688086e4302 to your computer and use it in GitHub Desktop.
CrytocurrencyPrediction
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&currencyPair=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