cryptoqween / cryptoqween.github.io

CryptoCompare API tutorials
194 stars 114 forks source link

How do I calculate the volume when the tradeID repeats more than once? #31

Closed slidenerd closed 4 years ago

slidenerd commented 6 years ago

I understand your are packing values and splitting the stream to send the same trade details more than once over the websocket, I am trying to generate OHLCV from the stream prices and OHLC is not the problem but the volume is.

Below is an example illustrating the problem, notice how the same trade ID has been streamed more than once. If I add the volume separately each time, it would be incorrect for sure. Even though the last volume is the same, the volume hour is changing by a small margin. Should I ignore this change in volume hour and consider the second value from the stream, or should I keep track of trade IDS. I want to just resample socket prices into 1 min OHLCV


TYPE 5
MARKET CCCAGG
FROMSYMBOL BTC
TOSYMBOL USD
FLAGS 1
PRICE 7192.47
LASTUPDATE 1535896593
LASTVOLUME 0.005
LASTVOLUMETO 35.932
**LASTTRADEID 288448864**
VOLUMEHOUR 48290.10139092038
VOLUMEHOURTO 351613292.0049536
VOLUME24HOUR 75295.16502406063
VOLUME24HOURTO 546351070.9446084
OPENHOUR 7203.46
HIGHHOUR 7384.38
LOWHOUR 7144.71
OPEN24HOUR 7060.66
HIGH24HOUR 7392.05
LOW24HOUR 7042.61
LASTMARKET Bitfinex
CHANGE24HOUR 131.8100000000004
CHANGE24HOURPCT 1.87

TYPE 5
MARKET CCCAGG
FROMSYMBOL BTC
TOSYMBOL USD
FLAGS 2
PRICE 7192.33
LASTUPDATE 1535896593
LASTVOLUME 0.005
LASTVOLUMETO 35.932
**LASTTRADEID 288448864**
VOLUMEHOUR 48290.12198587038
VOLUMEHOURTO 351613439.9668156
VOLUME24HOUR 75295.18561901062
VOLUME24HOURTO 546351218.9064704
OPENHOUR 7203.46
HIGHHOUR 7384.38
LOWHOUR 7144.71
OPEN24HOUR 7060.66
HIGH24HOUR 7392.05
LOW24HOUR 7042.61
LASTMARKET Bitfinex
CHANGE24HOUR 131.67000000000007
CHANGE24HOURPCT 1.86
cryptoqween commented 4 years ago

Hi there, just wanted to let you know that this version of the streaming API is being sunset in the next couple of weeks as we are moving to version 2, that has a lot more features and better support. Please visit our documentation page which provides code examples in javascript, node, python and golang: https://min-api.cryptocompare.com/documentation/websockets.