Skip to content

Commit 196daae

Browse files
committed
Ignore assets with null market_cap_rank
Brand new assets added to coingecko are shoved into the middle of the list without a rank and should be ignored
1 parent bb7053d commit 196daae

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/coinrankEngine.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export const coinrankEngine = async (
6262

6363
const reply = await response.json()
6464
const marketsPage = asCoingeckoMarkets(reply)
65-
markets = [...markets, ...marketsPage]
65+
// Filter out assets without a rank (newly listed assets may lack rankings)
66+
markets = [...markets, ...marketsPage.filter(m => m.rank != null)]
6667
page++
6768
if (page > NUM_PAGES) break
6869
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const asCoingeckoAsset = (raw: any) => {
3535
image: asString,
3636
current_price: asOptional(asNumber),
3737
market_cap: asOptional(asNumber),
38-
market_cap_rank: asNumber,
38+
market_cap_rank: asOptional(asNumber),
3939

4040
high_24h: asOptional(asNumber),
4141
low_24h: asOptional(asNumber),

0 commit comments

Comments
 (0)