diff --git a/core/src/exchanges/kalshi/fetcher.ts b/core/src/exchanges/kalshi/fetcher.ts index 41f250f0..e5d29daf 100644 --- a/core/src/exchanges/kalshi/fetcher.ts +++ b/core/src/exchanges/kalshi/fetcher.ts @@ -14,9 +14,6 @@ export interface KalshiRawMarket { ticker: string; title?: string; status?: string; - last_price?: number; - yes_ask?: number; - yes_bid?: number; subtitle?: string; yes_sub_title?: string; previous_price_dollars?: string; @@ -39,10 +36,8 @@ export interface KalshiRawMarket { rules_secondary?: string; expiration_time: string; volume_24h?: number; - volume?: number; liquidity?: number; liquidity_dollars?: string; - open_interest?: number; volume_24h_fp?: string; volume_fp?: string; open_interest_fp?: string; diff --git a/core/src/exchanges/kalshi/normalizer.ts b/core/src/exchanges/kalshi/normalizer.ts index 470ce2a3..8d124291 100644 --- a/core/src/exchanges/kalshi/normalizer.ts +++ b/core/src/exchanges/kalshi/normalizer.ts @@ -18,11 +18,11 @@ const KALSHI_PROMOTED_SERIES_KEYS = [ const KALSHI_PROMOTED_MARKET_KEYS = [ 'ticker', 'title', 'rules_primary', 'rules_secondary', 'expiration_time', - 'volume_24h_fp', 'volume_24h', 'volume', 'volume_fp', - 'liquidity_dollars', 'liquidity', 'open_interest_fp', 'open_interest', + 'volume_24h_fp', 'volume_24h', 'volume_fp', + 'liquidity_dollars', 'liquidity', 'open_interest_fp', 'status', 'last_price_dollars', 'previous_price_dollars', 'yes_ask_dollars', 'yes_bid_dollars', 'no_ask_dollars', 'no_bid_dollars', - 'response_price_units', 'last_price', 'yes_ask', 'yes_bid', + 'response_price_units', ] as const; function parseKalshiPrice(value: string | number | undefined, responseUnits?: string): number | undefined { @@ -54,8 +54,7 @@ export class KalshiNormalizer implements IExchangeNormalizer sum + (parseFloat(m.volume_fp ?? '') || Number(m.volume || 0)), 0); + return (event.markets || []).reduce((sum: number, m: KalshiRawMarket) => sum + (parseFloat(m.volume_fp ?? '') || 0), 0); } function eventLiquidity(event: KalshiRawEvent): number { - return (event.markets || []).reduce((sum: number, m: KalshiRawMarket) => sum + (parseFloat(m.open_interest_fp ?? '') || parseFloat(String(m.liquidity_dollars || m.open_interest || m.liquidity || '0')) || 0), 0); + return (event.markets || []).reduce((sum: number, m: KalshiRawMarket) => sum + (parseFloat(m.open_interest_fp ?? '') || parseFloat(String(m.liquidity_dollars || m.liquidity || '0')) || 0), 0); } function eventNewest(event: KalshiRawEvent): number { diff --git a/core/test/normalizers/exchange-normalizers.test.ts b/core/test/normalizers/exchange-normalizers.test.ts index 056551ad..fae9248e 100644 --- a/core/test/normalizers/exchange-normalizers.test.ts +++ b/core/test/normalizers/exchange-normalizers.test.ts @@ -388,11 +388,9 @@ describe('KalshiNormalizer', () => { rules_secondary: 'Data source: Federal Reserve', expiration_time: '2025-01-29T18:00:00Z', volume_24h: 12000, - volume: 350000, volume_24h_fp: '12000.00', volume_fp: '350000.00', open_interest_fp: '8500.00', - open_interest: 8500, liquidity: 5000, close_time: '2025-01-29T18:00:00Z', }); @@ -702,22 +700,6 @@ describe('KalshiNormalizer', () => { expect(result!.outcomes[0].price).toBeCloseTo(0.55); }); - it('falls back to legacy cent fields when dollar fields are absent', () => { - const marketCents: KalshiRawMarket = { - ticker: 'TEST-CENTS', - expiration_time: '2025-06-01T00:00:00Z', - last_price: 65, - }; - const eventCents: KalshiRawEvent = { - event_ticker: 'TEST-CENTS-EVT', - title: 'Cent Market', - markets: [marketCents], - }; - const result = normalizer.normalizeRawMarket(eventCents, marketCents); - expect(result).not.toBeNull(); - expect(result!.outcomes[0].price).toBeCloseTo(0.65); - }); - it('maps zero price when no price fields are present', () => { const marketNoPrice: KalshiRawMarket = { ticker: 'TEST-NOPRICE',