lagerfeuer / cryptocompare

Python3 Wrapper for the CryptoCompare API
MIT License
181 stars 73 forks source link

Incorrect historical data #62

Closed bgits closed 1 year ago

bgits commented 1 year ago

Calling: cryptocompare.get_historical_price_day('ETH') seems to have price errors compared with the REST api.

library returns most recent as:

{'time': 1675814400,
 'high': 1580.22,
 'low': 1552.67,
 'open': 1557.99,
 'volumefrom': 12791.86,
 'volumeto': 19984578.54,
 'close': 1561.35,
 'conversionType': 'direct',
 'conversionSymbol': ''}

https://min-api.cryptocompare.com/data/v2/histoday?fsym=ETH&tsym=USD&limit=10 - return

time: 1674950400
high: 1658.36
low: 1566.99
open: 1572.46
volumefrom: 502089.89
volumeto: 812096302.45
close: 1645.46
conversionType: "direct"
conversionSymbol: ""
lagerfeuer commented 1 year ago

That's because it's actually not the same request, the timestamps are different. They are a week apart.

bgits commented 1 year ago

Ok, why does the response end there?

When I do:

eth_daily = cryptocompare.get_historical_price_day('ETH')
eth_daily[-1]

This is the last entry:

{'time': 1675814400,
 'high': 1580.22,
 'low': 1521.66,
 'open': 1557.99,
 'volumefrom': 32914.83,
 'volumeto': 51043125.43,
 'close': 1536.68,
 'conversionType': 'direct',
 'conversionSymbol': ''}
lagerfeuer commented 1 year ago

What do you mean? Every time you comment on here, if I go and send the same request, I'll get a different result. Please describe any issues with more detail or I won't be able to help.

bgits commented 1 year ago

The timestamp corresponds to Feb 07, 2023, however those prices are not from that date. They are not from the day prior either as the OHLC were all above 1600.

lagerfeuer commented 1 year ago

Are you aware that there is an e parameter that selects the exchange? Because if you send a request for one exchange, but check the price on another, those probably don't match down to decimals.

See https://min-api.cryptocompare.com/documentation?key=Historical&cat=dataHistoday