value.detect
Identify up to 3 value betting opportunities by comparing market odds to fair value odds with a minimum 5% edge.
Instructions
Confronta quote mercato vs fair per trovare fino a 3 value pick (edge >= 5%).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| match_id | Yes | Fixture id |
Implementation Reference
- src/services/valueDetector.ts:9-43 (handler)Core handler function that detects value picks by comparing best market odds to computed fair odds, filtering for edge >= 5% and odds >= 1.5, sorting and taking top 3.export const detectValue = async (matchId: number): Promise<ValueDetectionResult> => { const snapshot = await buildMatchSnapshot(matchId); const fair = computeFairOddsFromSnapshot(snapshot); const odds = await oddsApi.getMarketOddsForFixture(snapshot.match); const picks: ValuePick[] = odds .map((market) => { if (!market.bookmakers.length) return undefined; const bestBook = market.bookmakers.reduce((best, current) => current.oddsDecimal > best.oddsDecimal ? current : best, ); const fairOdds = fair.fairOdds[market.selection]; const edge = bestBook.oddsDecimal / fairOdds - 1; if (edge < EDGE_THRESHOLD || bestBook.oddsDecimal < MIN_ODDS) return undefined; return { market: market.market, selection: market.selection, bookmaker: bestBook.book, offeredOdds: Number(bestBook.oddsDecimal.toFixed(3)), fairOdds, edge: Number(edge.toFixed(3)), rationale: buildRationale(snapshot.home.form, snapshot.away.form, fair.lambdaHome, fair.lambdaAway, market.selection), } satisfies ValuePick; }) .filter(Boolean) .sort((a, b) => (b!.edge - a!.edge)) .slice(0, 3) as ValuePick[]; return { matchId, picks, fair, odds, }; };
- src/tools/value.ts:5-17 (registration)Registers the 'value.detect' tool with FastMCP server, including name, description, input schema, and execute wrapper calling detectValue.export const registerValueTool = (server: FastMCP) => { server.addTool({ name: "value.detect", description: "Confronta quote mercato vs fair per trovare fino a 3 value pick (edge >= 5%).", parameters: z.object({ match_id: z.number().describe("Fixture id"), }), execute: async (args) => { const payload = await detectValue(args.match_id); return JSON.stringify(payload, null, 2); }, }); };
- src/tools/value.ts:9-11 (schema)Zod schema defining the input parameter 'match_id' as a number.parameters: z.object({ match_id: z.number().describe("Fixture id"), }),
- src/services/valueDetector.ts:45-58 (helper)Helper function to generate rationale for value picks based on form and lambda values.const buildRationale = ( homeForm: string | undefined, awayForm: string | undefined, lambdaHome: number, lambdaAway: number, selection: ValuePick["selection"], ): string => { const lambdaNote = `λ_home=${lambdaHome.toFixed(2)} λ_away=${lambdaAway.toFixed(2)}`; const homeNote = homeForm ? `home form ${homeForm}` : undefined; const awayNote = awayForm ? `away form ${awayForm}` : undefined; const formSnippet = [homeNote, awayNote].filter(Boolean).join(", "); return `${selection} boosted by ${lambdaNote}${formSnippet ? ` (${formSnippet})` : ""}`; };