get_history
Retrieve historical probability changes and trend data for prediction markets to analyze shifts in odds, sentiment, and market consensus over time.
Instructions
Get historical probability changes and trend data for a prediction market over time.
Returns probability snapshots showing how odds, sentiment, and market consensus have shifted over 1h, 24h, 7d, or 30d. Use for trend analysis, momentum detection, volatility assessment, and understanding how predictions evolve. Essential for backtesting strategies, identifying probability swings, and spotting market-moving events.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market_id | Yes | The market UUID or external_id (ticker) | |
| timeframe | No | Time range for history (default: 24h) |
Implementation Reference
- worker/src/tools.ts:440-493 (handler)The get_history tool handler, which queries the 'telekash_probability_history' table for historical probability and volume data for a given market.
async function getHistory( supabase: SupabaseClient, args: { market_id: string; timeframe?: string }, ): Promise<ToolResult> { const { market_id, timeframe = "24h" } = args; const market = await findMarket(supabase, market_id); if (!market) return err("Market not found"); 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("probability, volume, recorded_at") .eq("market_id", market.id) .gte("recorded_at", startTime) .order("recorded_at", { ascending: true }); // eslint-disable-next-line @typescript-eslint/no-explicit-any const history = (historyData || []).map((h: any) => ({ probability: Math.round(h.probability * 100), volume: h.volume || 0, timestamp: h.recorded_at, })); let trend = "stable"; if (history.length >= 2) { const change = history[history.length - 1].probability - history[0].probability; trend = change > 1 ? "up" : change < -1 ? "down" : "stable"; } return json({ market_id: market.id, title: market.title, timeframe, data_points: history.length, trend, history, current: { yes_probability: Math.round((market.external_odds?.yes || 0.5) * 100), no_probability: Math.round((market.external_odds?.no || 0.5) * 100), volume: market.raw_data?.volume || 0, timestamp: market.updated_at, }, }); } - worker/src/tools.ts:172-176 (registration)The registration of 'get_history' within the tool dispatcher in worker/src/tools.ts.
case "get_history": return getHistory( supabase, args as { market_id: string; timeframe?: string }, );