ttsteiger / cryptocompy

Simple Python 3 wrapper for the public CryptoCompare API.
MIT License
81 stars 36 forks source link

Get Hourly Historical Price Data Since Timestamp #7

Closed vertangelx closed 4 years ago

vertangelx commented 6 years ago

Hello!

Is there a way to get 2000 bars of hourly OHLCV data starting from a given timestamp Currently using get_historical_data('BTC', 'USD', 'hour'), not sure how to use the toTs feature...

rpesche commented 5 years ago

With https://github.com/ttsteiger/cryptocompy/pull/14 you can now use the toTs parameter like this :

import datetime

# using a datetime object
get_historical_data('BTC', 'USD', 'hour', toTs=datetime.datetime(2019, 5, 16, 18, 1, 48))
# or using a timestamp directly
get_historical_data('BTC', 'USD', 'hour', toTs=1558022508)
get_historical_data('BTC', 'USD', 'hour', toTs="1558022508")