History logo

History

CommunityPopular
alsk1992
history

Trade history tracking, sync, and performance analytics

Overview

Publisheralsk1992
RepositoryCloddsBot
Skill namehistory
Stars
2.8K
Forks
336
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by alsk1992 on GitHub. Read the source before you install it.

Installation

Install the History AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/alsk1992/CloddsBot.git /tmp/CloddsBot
mkdir -p .claude/skills
cp -r /tmp/CloddsBot/src/skills/bundled/history .claude/skills/history
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable History in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads History on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so History is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

P&L Analysis

/history daily-pnl                          # Daily P&L
/history weekly-pnl                         # Weekly P&L
/history monthly-pnl                        # Monthly P&L
/history by-market                          # P&L by market category

Export

/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

typescript
import { createTradeHistoryService } from 'clodds/history';

const history = createTradeHistoryService({
  polymarket: {
    apiKey: process.env.POLY_API_KEY,
    address: process.env.POLY_ADDRESS,
  },
  kalshi: {
    apiKey: process.env.KALSHI_API_KEY,
  },

  // Local storage
  dbPath: './trade-history.db',
});

Fetch Trades from APIs

typescript
// Fetch all trades from exchange APIs
const trades = await history.fetchTrades({
  platforms: ['polymarket', 'kalshi'],
  from: '2024-01-01',
});

console.log(`Fetched ${trades.length} trades`);

// Fetch from specific platform
const polyTrades = await history.fetchTrades({
  platforms: ['polymarket'],
  limit: 100,
});

Sync to Database

typescript
// Sync fetched trades to local database
await history.syncToDatabase();

console.log('Trades synced to database');

Get Trades

typescript
// Get trades from local storage
const trades = await history.getTrades({
  platform: 'polymarket',
  from: '2024-01-01',
  to: '2024-12-31',
  limit: 100,
});

for (const trade of trades) {
  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'}`);
}

Statistics

typescript
// Get comprehensive statistics
const stats = await history.getStats({
  period: '30d',
  platform: 'polymarket',
});

console.log(`=== Trading Statistics (30d) ===`);
console.log(`Total trades: ${stats.totalTrades}`);
console.log(`Winning trades: ${stats.winningTrades}`);
console.log(`Losing trades: ${stats.losingTrades}`);
console.log(`Win rate: ${(stats.winRate * 100).toFixed(1)}%`);
console.log(`\nP&L:`);
console.log(`  Total: $${stats.totalPnl.toLocaleString()}`);
console.log(`  Gross profit: $${stats.grossProfit.toLocaleString()}`);
console.log(`  Gross loss: $${stats.grossLoss.toLocaleString()}`);
console.log(`  Profit factor: ${stats.profitFactor.toFixed(2)}`);
console.log(`\nTrade sizes:`);
console.log(`  Average: $${stats.avgTradeSize.toFixed(2)}`);
console.log(`  Largest win: $${stats.largestWin.toFixed(2)}`);
console.log(`  Largest loss: $${stats.largestLoss.toFixed(2)}`);
console.log(`\nRisk metrics:`);
console.log(`  Sharpe ratio: ${stats.sharpeRatio.toFixed(2)}`);
console.log(`  Max drawdown: ${(stats.maxDrawdown * 100).toFixed(1)}%`);

Daily P&L

typescript
// Get daily P&L breakdown
const dailyPnl = await history.getDailyPnL({
  days: 30,
  platform: 'polymarket',
});

console.log('=== Daily P&L ===');
for (const day of dailyPnl) {
  const sign = day.pnl >= 0 ? '+' : '';
  const bar = day.pnl >= 0
    ? '█'.repeat(Math.min(Math.floor(day.pnl / 10), 20))
    : '▓'.repeat(Math.min(Math.floor(Math.abs(day.pnl) / 10), 20));

  console.log(`${day.date} | ${sign}$${day.pnl.toFixed(2).padStart(8)} | ${bar}`);
}

Performance by Market

typescript
// Get performance breakdown by market category
const byMarket = await history.getPerformanceByMarket({
  period: '30d',
});

console.log('=== Performance by Market Category ===');
for (const [category, data] of Object.entries(byMarket)) {
  console.log(`\n${category}:`);
  console.log(`  Trades: ${data.trades}`);
  console.log(`  Win rate: ${(data.winRate * 100).toFixed(1)}%`);
  console.log(`  P&L: $${data.pnl.toLocaleString()}`);
  console.log(`  Avg trade: $${data.avgTrade.toFixed(2)}`);
}

Export

typescript
// Export to CSV
await history.exportCsv({
  path: './trades.csv',
  from: '2024-01-01',
  to: '2024-12-31',
  columns: ['timestamp', 'platform', 'market', 'side', 'size', 'price', 'pnl'],
});

// Export to JSON
const json = await history.exportJson({
  from: '2024-01-01',
});

Database Schema

sql
CREATE TABLE trades (
  id TEXT PRIMARY KEY,
  platform TEXT NOT NULL,
  market_id TEXT NOT NULL,
  market_question TEXT,
  side TEXT NOT NULL,  -- 'buy' or 'sell'
  outcome TEXT,        -- 'YES' or 'NO'
  size REAL NOT NULL,
  price REAL NOT NULL,
  fee REAL DEFAULT 0,
  pnl REAL,
  timestamp INTEGER NOT NULL,
  created_at INTEGER DEFAULT (strftime('%s', 'now'))
);

CREATE INDEX idx_trades_platform ON trades(platform);
CREATE INDEX idx_trades_timestamp ON trades(timestamp);
CREATE INDEX idx_trades_market ON trades(market_id);

Best Practices

  1. Sync regularly - Keep local database up to date
  2. Export backups - Periodically export to CSV
  3. Review weekly - Analyze performance patterns
  4. Track by category - Identify strong/weak areas
  5. Monitor drawdown - Set alerts for max drawdown

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the History AI skill do?

Trade history tracking, sync, and performance analytics

Why use History on TypingMind?

Because you install it once and use it with any model. History is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install History in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/alsk1992/CloddsBot/tree/main/src/skills/bundled/history. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use History?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with History?

As many as you like. As long as a model supports skills, you can use History with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the History AI skill free?

Yes. It is published on GitHub by alsk1992 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇