get_trending
Identify prediction markets with significant probability swings to detect momentum in trending events. Use to find actionable opportunities and volatile markets where consensus is rapidly changing.
Instructions
Get prediction markets with the biggest probability swings — momentum detection for trending events.
Finds markets where odds moved most in the last 1h, 24h, 7d, or 30d. Surfaces breaking events, sentiment shifts, and market-moving news. Use when looking for actionable opportunities, volatile markets, or events where consensus is rapidly changing. Returns markets ranked by absolute probability change with direction (up/down) and current odds.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeframe | No | Lookback window for detecting swings (default: 24h) | |
| limit | No | Maximum markets to return (default: 10, max: 25) |
Implementation Reference
- worker/src/tools.ts:600-660 (handler)The implementation of the get_trending tool, which fetches market probability history to calculate trending markets.
async function getTrending( supabase: SupabaseClient, args: { timeframe?: string; limit?: number }, ): Promise<ToolResult> { const { timeframe = "24h", limit = 10 } = args; const effectiveLimit = Math.min(Math.max(1, limit), 25); const timeframeMs: Record<string, number> = { "1h": 3600000, "24h": 86400000, "7d": 604800000, "30d": 2592000000, }; const startTime = new Date( Date.now() - (timeframeMs[timeframe] || timeframeMs["24h"]), ).toISOString(); const { data: historyData } = await supabase .from("telekash_probability_history") .select("market_id, probability, recorded_at") .gte("recorded_at", startTime) .order("recorded_at", { ascending: true }); if (!historyData?.length) { // Fallback: recently updated markets const { data: recent } = await supabase .from("telekash_markets") .select("id, title, category, source, external_odds, updated_at") .eq("status", "active") .order("updated_at", { ascending: false }) .limit(effectiveLimit); // eslint-disable-next-line @typescript-eslint/no-explicit-any return json({ timeframe, trending: (recent || []).map((m: any) => ({ market_id: m.id, title: m.title, category: m.category, source: m.source, current_probability: Math.round((m.external_odds?.yes || 0.5) * 100), last_updated: m.updated_at, })), total: (recent || []).length, _note: "Showing recently updated. Historical tracking building up.", }); } // Group by market and compute swings with noise filter const snapshots: Record<string, number[]> = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any for (const h of historyData as any[]) { if (!snapshots[h.market_id]) snapshots[h.market_id] = []; snapshots[h.market_id].push(h.probability); } const swings = Object.entries(snapshots) .map(([mid, probs]) => { const change = probs[probs.length - 1] - probs[0]; let reversals = 0, sustained = 0; for (let i = 2; i < probs.length; i++) { - worker/src/tools.ts:181-185 (registration)The registration/dispatch logic for the get_trending tool within the tool handler.
case "get_trending": return getTrending( supabase, args as { timeframe?: string; limit?: number }, ); - worker/src/schema.ts:234-250 (schema)The JSON schema definition for the get_trending tool, including input arguments.
name: "get_trending", description: `Markets with biggest probability swings — momentum detection for trending events.`, inputSchema: { type: "object", properties: { timeframe: { type: "string", enum: ["1h", "24h", "7d", "30d"], description: "Lookback window (default: 24h)", }, limit: { type: "number", description: "Max markets (default: 10, max: 25)", }, }, required: [], },