Menu

Your moneyline parser can reverse the odds ranking
📰

Your moneyline parser can reverse the odds ranking

DEV Community: typescript·Nimbryxo-studio·3 days ago
#Pim68Kql
#devtotypescript#devto#dev#const#probability
Reading 0:00
15s threshold

Your dashboard puts a long shot above the favorite. You check the sorting function. It's fine. The damage happened before the rows reached it.

A field named homeMoneyline looks reassuringly numeric. But the Actor preserves published prices, including fractional strings. Applying parseFloat before identifying the notation can reverse your implied-probability ranking.

Example: this assertion shows a fractional long shot incorrectly outranking an American-priced favorite after a permissive conversion.

import assert from 'node:assert/strict' ;

const americanProbability = ( price : number ) => price > 0 ? 100 / ( price + 100 ) : - price / ( - price + 100 ) ;

const fractionalLongShot = '20/1' ; const americanFavorite = - 110 ;

assert . ok ( americanProbability ( parseFloat ( fractionalLongShot ) ) > americanProbability ( americanFavorite ) , ) ;

Enter fullscreen mode

Exit fullscreen mode

Nothing throws.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.