fix(core): avoid float drift in venue decimal math#955
Conversation
| const bestAsk = contract.prices?.bestAsk ? parseFloat(contract.prices.bestAsk) : 0.5; | ||
| const bestBidRaw = contract.prices?.bestBid ?? '0.5'; | ||
| const bestAskRaw = contract.prices?.bestAsk ?? '0.5'; | ||
| const bestBid = parseFloat(bestBidRaw); |
| const bestBidRaw = contract.prices?.bestBid ?? '0.5'; | ||
| const bestAskRaw = contract.prices?.bestAsk ?? '0.5'; | ||
| const bestBid = parseFloat(bestBidRaw); | ||
| const bestAsk = parseFloat(bestAskRaw); |
PR Review: PASS (NOT VERIFIED)What This DoesIntroduces decimal-string helpers and applies them in venue price/amount arithmetic to reduce floating-point drift in financial fields. Blast RadiusCore normalizers/order helpers for Gemini Titan, Kalshi, Opinion, Polymarket US, Smarkets, plus new decimal-math tests. Consumer VerificationBefore (base branch): After (PR branch): Test Results
FindingsNo blocking findings. PMXT Pipeline Check
Semver Impactpatch -- financial precision bug fix without API shape change. RiskLive venue payloads were not sampled, so this review verifies the arithmetic/unit path rather than real exchange data. |
…l-arithmetic # Conflicts: # core/src/exchanges/gemini-titan/normalizer.ts # core/src/exchanges/kalshi/normalizer.ts
|
Maintenance automation follow-up: I refreshed this branch with origin/main and resolved the two mechanical conflicts in Gemini Titan/Kalshi normalizers, then ran local targeted validation:
I did not merge because generated-sync checks are now red after the base refresh. Running the client/docs generators locally produces broad hosted-client/doc drift unrelated to this focused float-safety PR, so I left that generated drift out of the branch per the focused-PR generator-drift policy. |
PR Review: PASS (NOT VERIFIED)What This DoesAdds decimal-string arithmetic helpers and replaces several floating-point price/amount calculations across Gemini Titan, Kalshi, Opinion, Polymarket US, and Smarkets. This reduces precision drift in prices, balances, order books, and PnL calculations that SDK consumers receive. Blast RadiusCore exchange normalizers/price helpers for five venues plus new Consumer VerificationBefore (base branch): After (PR branch): Test Results
FindingsNo blocking findings. PMXT Pipeline Check
Semver Impactpatch -- precision bug fix with unchanged API shape. RiskLive venue payloads were not exercised; this review verifies helper behavior and call-site replacement, not every external exchange edge case. |
Summary
Fixes #718
Fixes #714
Fixes #709
Fixes #674
Fixes #671
Fixes #666
Fixes #664
Fixes #295
Fixes #286
Fixes #229
Fixes #713
Test Plan