PlatformsDocumentation

Know-Defeat Documentation

High-frequency algorithmic trading system with 126 bots across multiple tickers

Overview

The Know-Defeat trading system is a high-frequency algorithmic trading platform that executes sub-minute trades through Interactive Brokers. The system manages 126 trading bots across multiple tickers (TSLA, COIN, NVDA, etc.), using 8 distinct trading algorithms to generate entry and exit signals. A dynamic fund allocation system ranks bots by performance and limits concurrent trades to 10.

126
Trading Bots
8
Algorithm Types
10
Max Concurrent Trades
25+
Performance Metrics

System Purpose

  • Automated trading execution through Interactive Brokers via IB Gateway API
  • Multi-bot management with 126 independently configured bots
  • Performance-based allocation using weighted ranking metrics
  • Real-time analytics calculating 25+ performance metrics
  • Trade capacity management enforcing max 10 concurrent positions

Getting Started

Prerequisites

ComponentRequirementPurpose
Python3.8+ with AnacondaCore runtime
PostgreSQLWith TimescaleDBTime-series storage
Interactive BrokersTWS or IB GatewayMarket data & execution
System Resources32GB RAM, 350GB+Tick data & bots

Setup Steps

  1. 1

    Environment Installation

    Install PostgreSQL with TimescaleDB extension. Create the tick_data database. Install Python dependencies (asyncpg, ib_insync).

  2. 2

    Database Initialization

    Create tables: tick_data, bot_tick_data, sim_bot_trades, bot_metrics, bot_rankings, variable_weights.

  3. 3

    Bot Configuration

    Create YAML configs in src/bots/ with bot_id, algo_id, ticker, trade_direction, position_size, trailing_stop_pct.

  4. 4

    Bot Registration

    Run initialize_all_bots.py to register bots in the database.

  5. 5

    IB Configuration

    Enable API connections on port 4002 in IB Gateway/TWS settings.

  6. 6

    Run the System

    Start IB Controller, launch bots, monitor via Streamlit dashboard.

System Architecture

Core Components

IB Controller (IBDataIngestion)

Connects to IB Gateway on port 4002. Subscribes to real-time market data for tickers (TSLA, COIN, NVDA, ARWR, ROOT, JANX, AMZN, FLYW, AAPL, AMD, PYPL).

Trading Bots (BaseBot)

126 independently configured bots. Each runs via YAML config with algo_id, ticker, position_size, trailing_stop_pct.

Algorithm Modules

8 algorithm types: Momentum, Breakout, Mean Reversion, Minute Momentum, Price Pattern, Support/Resistance, Volatility Breakout, Volume Surge.

Trade Manager

Enforces 10-trade limit. Manages dynamic allocation. Opens/closes trades based on bot rankings.

Performance & Ranking

Bot Ranker (BotRanker)

Calculates weighted scores for all bots based on 25+ metrics. Updates rankings after each trade.

Metrics Calculator

Time-based: one_hour_performance, one_day_performance, one_week_performance. Risk: sharpe_ratio, profit_factor, max_drawdown.

Database Schema

TablePurposeKey Columns
tick_dataMarket data from IBtimestamp, ticker, price, volume
bot_tick_dataBot-specific tick databot_id, timestamp, ticker, price
sim_bot_tradesTrade recordstrade_id, bot_id, entry_price, exit_price, pnl
bot_metricsPerformance metricsbot_id, total_pnl, sharpe_ratio, win_rate
bot_rankingsBot rankingsbot_id, rank_score, rank, is_active
variable_weightsRanking weightsvariable_name, weight, description

User Interfaces

Streamlit Dashboard

Primary interface with 9 tabs for system control and monitoring.

1. Controls2. Logs3. Tables4. Trade Data5. Parameters6. Bot Rankings7. Account Info8. Data Export9. Documentation

Remix Web Frontend

Secondary Node.js/React frontend for web-based dashboard. Queries PostgreSQL through server-side API layer. Deployable to Google Cloud Run.

Deployment

Local Development

  • • PostgreSQL on localhost:5432
  • • IB Gateway on port 4002
  • • Streamlit dashboard
  • • Direct asyncpg connections

Cloud (GCP)

  • • Cloud SQL PostgreSQL
  • • Cloud Run for Remix frontend
  • • Cloud SQL Proxy
  • • GitHub Actions CI/CD
  • • Secret Manager

Key System Constraints

Max Concurrent Trades10
Trade Allocation$2,000
Configured Bots126
Algorithm Types8
Performance Metrics25+
Data Retention30+ days