Closed ebma closed 4 months ago
So this 0 value can happen at any time ?
I think it shouldn't but for some reason it seemed to happen on that day for TZS and BRL. So we should assume that it can happen any time, yes.
I would worry that the previous day close would be much lower/higher than the previous non-zero fetched value for that day.
I don't think this should be the case because I would assume that in the cases where the lastQuote
for the current day is 0
, I would assume that the close of the previous day would then be equal to the previous non-zero fetched value. At least I would understand the problem to be such that the lastQuote
is only empty because there is no trade yet for that new day.
We can also go for this solution but monitor the prices to check when this null entry happens during the day.
I can add a log statement, should I?
I would understand the problem to be such that the lastQuote is only empty because there is no trade yet for that new day.
That would make the most sense to be honest, especially since it is not mentioned on the docs. So let's go for it. Yeah let's add just a println
for when the 0
value happens to confirm our theory.
Added the logs and will merge now.
Amends the changes made in #21.
prevDay
quote in case thelastQuote
does not contain any non-zero values.I noticed that the batching server returns a price of
0
for the TZS and NGN currencies. This is because thelastQuote
returned by the 'all-tickers' endpoint returns 0 values for all fields of those currencies. I suppose this is either because there is not much activity or maybe they were not traded on that day yet, see https://api.polygon.io/v2/snapshot/locale/global/markets/forex/tickers?tickers=C:TZSUSD&apiKey={apiKey}.In case the
lastQuote
is empty we will now fall back to theprevDay
values instead.I compared them to the response of the currency-conversion endpoint here https://api.polygon.io/v1/conversion/TZS/USD?amount=1&precision=5&apiKey={apiKey}
and I think using the
c
(-> 'close') value of the previous day makes the most sense in this case. It also matches the result of the conversion (though to be fair, all values seem to do in this example due to the low precision).