Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions core/src/exchanges/gemini-titan/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,19 @@ export class GeminiNormalizer implements IExchangeNormalizer<GeminiRawEvent, Gem
// Extract prices
const bestBid = contract.prices?.bestBid ? parseFloat(contract.prices.bestBid) : 0.5;
const bestAsk = contract.prices?.bestAsk ? parseFloat(contract.prices.bestAsk) : 0.5;
const buyYes = contract.prices?.buy?.yes ? parseFloat(contract.prices.buy.yes) : undefined;
const sellYes = contract.prices?.sell?.yes ? parseFloat(contract.prices.sell.yes) : undefined;
const buyNo = contract.prices?.buy?.no ? parseFloat(contract.prices.buy.no) : undefined;
const sellNo = contract.prices?.sell?.no ? parseFloat(contract.prices.sell.no) : undefined;
const lastPrice = contract.prices?.lastTradePrice
? parseFloat(contract.prices.lastTradePrice)
: (bestBid + bestAsk) / 2;

const yesPrice = roundPrice(Math.max(0, Math.min(1, lastPrice)));
const noPrice = roundPrice(Math.max(0, Math.min(1, 1 - yesPrice)));
const yesPriceSource = buyYes ?? sellYes ?? lastPrice;
const noPriceSource = buyNo ?? sellNo ?? (1 - yesPriceSource);

const yesPrice = roundPrice(Math.max(0, Math.min(1, yesPriceSource)));
const noPrice = roundPrice(Math.max(0, Math.min(1, noPriceSource)));

const outcomes: MarketOutcome[] = [
{
Expand Down Expand Up @@ -258,7 +265,7 @@ export class GeminiNormalizer implements IExchangeNormalizer<GeminiRawEvent, Gem
outcomes,
resolutionDate,
volume24h: 0,
liquidity: event.liquidity ? parseFloat(event.liquidity) : 0,
liquidity: event.liquidity ? parseFloat(event.liquidity) : (event.volume24h ? parseFloat(event.volume24h) : (event.volume ? parseFloat(event.volume) : 0)),
url: buildExchangeUrl(event.ticker),
category: event.category,
tags,
Expand Down
2 changes: 2 additions & 0 deletions core/src/exchanges/hyperliquid/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,13 @@ export class HyperliquidNormalizer implements IExchangeNormalizer<HyperliquidRaw
const bids = rawBids.map(level => ({
price: parseFloat(level.px),
size: parseFloat(level.sz),
orderCount: level.n,
}));

const asks = rawAsks.map(level => ({
price: parseFloat(level.px),
size: parseFloat(level.sz),
orderCount: level.n,
}));

return {
Expand Down
2 changes: 2 additions & 0 deletions core/src/exchanges/kalshi/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface KalshiRawMarket {
last_price_dollars?: string;
yes_ask_dollars?: string;
yes_bid_dollars?: string;
yes_ask_size_fp?: string;
yes_bid_size_fp?: string;
rules_primary?: string;
rules_secondary?: string;
expiration_time: string;
Expand Down
7 changes: 6 additions & 1 deletion core/src/exchanges/kalshi/normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ export class KalshiNormalizer implements IExchangeNormalizer<KalshiRawEvent, Kal
sourceMetadata: buildSourceMetadata(
market as unknown as Record<string, unknown>,
KALSHI_PROMOTED_MARKET_KEYS,
{ series_ticker: event.series_ticker, series_title: event.series_title },
{
yes_ask_size_fp: market.yes_ask_size_fp,
yes_bid_size_fp: market.yes_bid_size_fp,
series_ticker: event.series_ticker,
series_title: event.series_title,
},
),
} as UnifiedMarket;

Expand Down
4 changes: 4 additions & 0 deletions core/src/exchanges/limitless/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export interface LimitlessRawMarket {
description?: string;
tokens?: Record<string, string>;
prices?: number[];
tradePrices?: {
buy?: { market?: number[]; limit?: number[] };
sell?: { market?: number[]; limit?: number[] };
};
expirationTimestamp?: string;
volumeFormatted?: number;
volume?: number;
Expand Down
6 changes: 3 additions & 3 deletions core/src/exchanges/limitless/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export function mapMarketToUnified(market: any, context: LimitlessMarketContext
throw new Error(`[limitless] Market "${market.slug}" is missing token addresses`);
}

const prices = Array.isArray(market.prices) ? market.prices : [];
const yesPrice = prices[0] || 0;
const noPrice = prices[1] || 0;
const legacyPrices = Array.isArray(market.prices) ? market.prices : [];
const yesPrice = market.tradePrices?.buy?.market?.[0] ?? legacyPrices[0] ?? 0.5;
const noPrice = market.tradePrices?.sell?.market?.[0] ?? legacyPrices[1] ?? Math.max(0, Math.min(1, 1 - yesPrice));
const yesLabel = hasParentContext ? rawTitle : 'Yes';
const noLabel = hasParentContext ? `Not ${rawTitle}` : 'No';

Expand Down
Loading
Loading