Data inconsistencies with sparklines

Getting different numbers using the Sparklines API for simliar time ranges and the same end date. For example:

https://api.nomics.com/v1/currencies/sparkline?key=API_KEY_HERE&ids=ETH&start=2020-04-22T17%3A00%3A00-07%3A00&end=2020-04-24T17%3A00%3A00-07%3A00

Will return this:

[
{
“currency”: “ETH”,
“timestamps”: [
“2020-04-23T00:00:00Z”,
“2020-04-24T00:00:00Z”, (NOTE THIS NUMBER HERE - A)
“2020-04-25T00:00:00Z” (NOTE THIS NUMBER HERE - B)
],
“prices”: [
“186.10807708”,
“187.52075974”,(NOTE THIS NUMBER HERE - A)
“194.27126481”(NOTE THIS NUMBER HERE - B)
]
}
]

And this returns something different:
https://api.nomics.com/v1/currencies/sparkline?key=API_KEY_HERE&ids=ETH&start=2020-04-23T17%3A00%3A00-07%3A00&end=2020-04-24T17%3A00%3A00-07%3A00

[
{
“currency”: “ETH”,
“timestamps”: [
“2020-04-24T00:00:00Z”, (THIS NEEDS TO BE SAME AS ABOVE - A)
“2020-04-24T01:00:00Z”,
“2020-04-24T02:00:00Z”,
“2020-04-24T03:00:00Z”,
“2020-04-24T04:00:00Z”,
“2020-04-24T05:00:00Z”,
“2020-04-24T06:00:00Z”,
“2020-04-24T07:00:00Z”,
“2020-04-24T08:00:00Z”,
“2020-04-24T09:00:00Z”,
“2020-04-24T10:00:00Z”,
“2020-04-24T11:00:00Z”,
“2020-04-24T12:00:00Z”,
“2020-04-24T13:00:00Z”,
“2020-04-24T14:00:00Z”,
“2020-04-24T15:00:00Z”,
“2020-04-24T16:00:00Z”,
“2020-04-24T17:00:00Z”,
“2020-04-24T18:00:00Z”,
“2020-04-24T19:00:00Z”,
“2020-04-24T20:00:00Z”,
“2020-04-24T21:00:00Z”,
“2020-04-24T22:00:00Z”,
“2020-04-24T23:00:00Z”,
“2020-04-25T00:00:00Z” (THIS NEEDS TO BE SAME AS ABOVE - B)
],
“prices”: [
“186.41211307”, (THIS NEEDS TO BE SAME AS ABOVE - A)
“186.75803804”,
“188.49231777”,
“188.37077407”,
“188.93834582”,
“186.97587531”,
“188.45571272”,
“189.59574757”,
“188.82913512”,
“188.97050905”,
“188.21736068”,
“186.34957832”,
“186.96475578”,
“186.61794128”,
“187.07732368”,
“187.51685560”,
“188.22368638”,
“187.92424866”,
“188.45004150”,
“188.56178517”,
“188.13049627”,
“187.40693536”,
“186.60230969”,
“187.60282332”,
“186.88284561” (THIS NEEDS TO BE SAME AS ABOVE - B)
]
}
]

Expected behavior is that I get the same numbers for those ranges given that I put in the same end date.

Hi Shelby,

Under the hood, this uses our 1d and 1h candles, which is why you get different granularities for those requests.

The prices come from the “close” field of the candle, and are “volume weighted averages” of different time ranges, so the prices differ due to the difference in volumes aggregated over separate time periods.

This more accurately “smooths” the data over the larger time period to have a more stable and consistent price. When you get down to lower granularities, you have something fresher but less stable.

For example, let’s say you have two markets to price BTC, they are both BTC/USD markets on exchange A and exchange B. Let’s say A has a lot of volume in the first half of the day, and less in the second half, and B has a lot of volume in the second half of the day, and less in the first half.

A’s market will affect the price in the morning hours stronger than B, and vice versa in the afternoon. However, when you look at the whole day, they have about equal volume and affect the price equally. This yields different prices at the 1h and 1d mark.

We find this provides more accurate and stable price values by using all available data at higher granularities, but like you’ve noticed, it produces inconsistencies.

This only occurs because we are VWAPing the price across thousands of markets. If you look at our Exchange Market Candles that are only for a single market, they are consistent in their pricing because there is no averaging.

Let me know if that answers your question and if you have any others. Thanks!

1 Like