cryptoqween / cryptoqween.github.io

CryptoCompare API tutorials
194 stars 114 forks source link

MaskInt #5

Closed akeslo closed 7 years ago

akeslo commented 7 years ago

What is the purpose of MaskInt? How exactly should this be used?

It appears to be a hex which is being converted into a decimal in the example code. Does the decimal value have significance? The sample code just appears to check that its a valid Int.

Thanks.

vcealicu commented 7 years ago

The Mask is used to unpack the message from the streamer: A few example messages would be:

"5~CCCAGG~XMR~BTC~2~0.02782~354491.32226344~10126.815630822775~c01"
"5~CCCAGG~XMR~BTC~4~354494.97580696~10126.917122608218~c00"
"5~CCCAGG~ETC~USD~4~1504364606~79~1508.9158~1504364606.5228~2968816.884724402~63051687.659204~Kraken~40ce8"

Without the mask, you could not unpack the message, you would not know what the numbers represent. The mask helps unpack it and make sense of the numbers.

akeslo commented 7 years ago

Thanks for the response! I'm just having a hard time understanding how the mask is calculated / translated to the fields within the message. Will c01 always represent the fields in the example you shared? Are there known mask values that should be checked against? I.e C01 will always represent 8 fields in that order so check if mask = C01 and then populate an array based on that? Thanks

vcealicu commented 7 years ago

This should help: https://github.com/cryptoqween/cryptoqween.github.io/blob/master/streamer/ccc-streamer-utilities.js#L353

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.