Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Last active Sep 14, 2020
Embed
What would you like to do?
Obtain ohlcv data with ccxt library in Python
# consecutive days for ohlcv function
from datetime import datetime, date, timedelta
start_day = "20190101"
start_dt = datetime.strptime(start_day, "%Y%m%d")
end_day = "20200831"
end_dt = datetime.strptime(end_day, "%Y%m%d")
days_num = (end_dt - start_dt).days + 1
datelist = [start_dt + timedelta(days=x) for x in range(days_num)]
datelist = [date.strftime("%Y%m%d") for date in datelist]
df = ohlcv(datelist, 'ETH/BTC', '1h')
# hourly ETH/BTC ohlcv data between Jan 2019 and Aug 2020 from crypto exchange
df.to_csv('data/eth_btc_1hour_2018JanTo2020Aug.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment