Untitled
unknown
plain_text
22 days ago
3.4 kB
4
Indexable
Never
// returns "win", "loss", or "push" based on the result of the bet // This doesn't have to use the current/market lines // ex: You can override the "spread" value in oddData on a spread bet and the result will be based off of that spread const determineResult = (oddData, opposingOddData) => { const score = oddData.score || 0; const oppScore = opposingOddData.score || 0; const betTypeID = oddData.betTypeID; const sideID = oddData.sideID; // Unless otherwise mentioned, score represents raw score for the given statEntityID + periodID + statID combo // Example 1: statEntityID=LEBRON_JAMES_LA_LAKERS periodID=2q statID=rebounds => score will be Lebron James' 2nd quarter rebounds // Then the score will be Lebron James' rebounds in the 2nd quarter // Example 2: statEntityID=home periodID=game statID=points => score will be the total points scored by the home team in the game // (in the above example note that "points" statID means goals for soccer/hockey, sets for tennis, points for football, etc.) // Example 3: statEntityID=all periodID=reg statID=bothTeamsScored => score is 1 if both teams scored in regulation, 0 otherwise if (betTypeID === "ml" || betTypeID === "prop") { // For moneyline and custom prop bets: higher score wins return score > oppScore ? "win" : score < oppScore ? "loss" : "push"; } if (betTypeID === "sp") { // For spread bets: Add the spread to one of the sides before comparing scores. Higher score wins. const scoreWithSpread = score + oddData.spread; return scoreWithSpread > oppScore ? "win" : scoreWithSpread < oppScore ? "loss" : "push"; } if (betTypeID === "ml3way") { // For 3-way moneyline bets. There are no pushes. Result is based on the side picked. Draws are not pushes. if (sideID === "home" || sideID === "away") return score > oppScore ? "win" : "loss"; if (sideID === "home+draw" || sideID === "away+draw") return score >= oppScore ? "win" : "loss"; // For "draw" & "not_draw" sideIDs score represents the score difference (home - away) between the 2 teams if (sideID === "draw") return score === 0 ? "win" : "loss"; // draw wins if the score diff is 0 if (sideID === "not_draw") return score !== 0 ? "win" : "loss"; // not_draw wins if the score diff isn't 0 } if (betTypeID === "ou") { // For over-under bets: Compare the score to the overUnder value. Then determine winner based on the side picked const overUnder = oddData.overUnder; if (sideID === "over") return score > overUnder ? "win" : score < overUnder ? "loss" : "push"; if (sideID === "under") return score > overUnder ? "loss" : score < overUnder ? "win" : "push"; } if (betTypeID === "eo") { // For even-odd bets: Check if the score is even or odd. Then determine winner based on the side picked if (sideID === "even") return score % 2 === 0 ? "win" : "loss"; if (sideID === "odd") return score % 2 === 0 ? "loss" : "win"; } if (betTypeID === "yn") { // For yes-no bets: Check if the score has a value (non-0). Then determine winner based on the side picked if (sideID === "yes") return score ? "win" : "loss"; if (sideID === "no") return score ? "loss" : "win"; } // Defaults to a push in cases where an unknown betTypeID or sideID is provided (ex: a new betTypeID is added) return "push"; };
Leave a Comment