Add fallback to prevDay quote for polygon prices #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, seehttps://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).