feat: implement CoinPaprika quote source (.CP suffix) - #380
Open
donbagger wants to merge 1 commit into
Open
Conversation
The QuoteSource enum has declared crypto sources that were never wired up and the CoinCap hosted API has since shut down. This adds a working aggregated crypto source: symbols suffixed with .CP resolve to the highest ranked matching coin on CoinPaprika and are polled via the free API with no key required. Mirrors the Yahoo poll-only monitor structure and the Coinbase unary client conventions.
Author
|
Checking in on this. No CI has run on the PR at all, which I assume is the first-time-contributor approval gate, so there are no test results for you to look at yet. The change is additive: a new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this adds
internal/common/common.gohas carriedQuoteSourceCoingeckoandQuoteSourceCoinCapin theQuoteSourceenum for a while, but neither was ever implemented, and the README notes.CCand.CGwere dropped in v5.0.0. CoinCap also can't come back in its old form: while working on this I checked andapi.coincap.iono longer resolves in DNS, and the v3 replacement atrest.coincap.ioreturns 401 without an API key.This PR implements a working aggregated crypto source instead: CoinPaprika, behind a new
.CPsymbol suffix. The free API needs no key, covers 12,000+ cryptocurrencies, and fills the gap for assets that aren't listed on Coinbase (KAS, and so on).How it works
BTC.CPin a watchlist resolves to the highest ranked active coin on CoinPaprika whose symbol matches exactly (btc-bitcoin) viaGET /v1/search/. Multiple coins share symbols on CoinPaprika, which is why rank is the tiebreaker.GET /v1/tickers/{id}(price,percent_change_24h,market_cap,volume_24hfromquotes.USD). Unknown ids 404 and are skipped rather than failing the whole watchlist, matching how the other sources treat unknown symbols.interval. A 5 second stock watchlist won't hammer CoinPaprika for no benefit.currency: EURconversion works the same as it does for Coinbase.Config example:
Enum note
I appended
QuoteSourceCoinPaprikaat the end of the enum so existing iota values don't shift, and leftQuoteSourceCoingeckoandQuoteSourceCoinCapuntouched. Happy to mark those two as deprecated in a follow-up if you want, I just didn't want to bundle that decision in here.Testing
go build ./...,go tool golangci-lint run(0 issues) andgo tool ginkgo -skip="GetQuotes Response" -cover ./...all pass locally on Go 1.26.4, 24 suites green. New packages: unary 100%, poller 100%, monitor 91.2% statement coverage. Tests use ginkgo, gomega and ghttp like the neighboring monitors, with fixtures copied from live API responses.ticker printandticker print summarywith.CPlots return correct prices and position math, and a monitor-level run with the 30 second poller received a live poll update (an ETH price change) end to end. Search resolution verified live for BTC, ETH and KAS, including the case sensitivity gotcha:/v1/tickers/BTC-BITCOIN404s, ids must be lowercase, which the client normalizes.NewMonitorwiring thatprintuses, so the untested surface is small, but flagging it honestly.govulncheckreports one Go stdlib finding that is also present on a clean master checkout, so it's pre-existing and not introduced by this change.Disclosure: I do DevRel for CoinPaprika. Everything here uses the public free API, no key or account involved.