You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fetch, sync, and analyze trade history from Polymarket and Kalshi with P&L breakdowns, win-rate stats, and CSV/JSON export. Use when users mention trade history, performance analytics, daily P&L, trade sync, or export trades.
emoji
📊
gates
envs
anyOf
POLY_API_KEY
KALSHI_API_KEY
Trade History - Complete API Reference
Fetch, sync, and analyze trade history from Polymarket and Kalshi with detailed performance metrics.
Chat Commands
Fetch & Sync
/history fetch # Fetch all trades from APIs
/history fetch poly # Fetch Polymarket only
/history fetch --from 2024-01-01 # From specific date
/history sync # Sync to local database
View History
/history list # Recent trades
/history list --limit 50 # Last 50 trades
/history list --platform poly # Polymarket only
/history list --market <id> # Specific market
Statistics
/history stats # Overall statistics
/history stats --period 30d # Last 30 days
/history stats --platform kalshi # Platform-specific
/history export # Export to CSV
/history export --format json # Export as JSON
/history export --from 2024-01-01 # Date range
Filtering
/history filter --side buy # Only buys
/history filter --pnl positive # Only winners
/history filter --pnl negative # Only losers
/history filter --min-size 100 # Min $100 trades
TypeScript API Reference
Create History Service
import{createTradeHistoryService}from'clodds/history';consthistory=createTradeHistoryService({polymarket: {apiKey: process.env.POLY_API_KEY,address: process.env.POLY_ADDRESS,},kalshi: {apiKey: process.env.KALSHI_API_KEY,},// Local storagedbPath: './trade-history.db',});
Fetch Trades from APIs
// Fetch all trades from exchange APIsconsttrades=awaithistory.fetchTrades({platforms: ['polymarket','kalshi'],from: '2024-01-01',});console.log(`Fetched ${trades.length} trades`);// Fetch from specific platformconstpolyTrades=awaithistory.fetchTrades({platforms: ['polymarket'],limit: 100,});
Sync to Database
// Sync fetched trades to local databaseawaithistory.syncToDatabase();console.log('Trades synced to database');
Get Trades
// Get trades from local storageconsttrades=awaithistory.getTrades({platform: 'polymarket',from: '2024-01-01',to: '2024-12-31',limit: 100,});for(consttradeoftrades){console.log(`${trade.timestamp}: ${trade.side}${trade.market}`);console.log(` Size: $${trade.size}`);console.log(` Price: ${trade.price}`);console.log(` P&L: $${trade.pnl?.toFixed(2)||'open'}`);}