Skip to content

Repository files navigation

📈 IBKR Automated Trading Architecture A fully autonomous, modular Python algorithmic trading engine designed for Interactive Brokers (TWS / Gateway).

Built for stability, risk management, and complete transparency, this system executes trades without human emotion. It features dynamic position sizing, automated trailing stops, live Telegram telemetry, and a fail-safe auto-healing Watchdog.

🚀 Core Modules

  1. The Strategy Engine (Smart Buyer)
  • Macro Trend Filtering: Executes trades only when the asset is mathematically confirmed to be in a macro uptrend using custom moving average thresholds.
  • Precision Entries: Triggers market orders exclusively on highly specific, data-driven oversold conditions using momentum oscillators.
  • Dynamic Position Sizing: Automatically adjusts capital allocation based on signal conviction (scales up position size dynamically when technical conditions reach extreme algorithmic thresholds).

Dynamic Position Sizing: Automatically adjusts capital allocation based on signal conviction (scales up position size when conditions are extreme).

  1. The Security Director (Risk Management) Dynamic Trailing Stops: Continuously tracks live price peaks and automatically adjusts the stop-loss to lock in secured profits.

Automated Liquidation: Sells positions immediately when the trailing stop threshold is breached, ensuring consistent profit-taking.

  1. 🗃️ The "Black Box" Trade Recorder Immutable Audit Trail: Every API request, market tick, sizing calculation, and execution is meticulously recorded locally.

Complete Transparency: Never guess why a trade was triggered or skipped. The Black Box provides full data history for post-trade analysis, debugging, and strategy optimization.

  1. The Watchdog (Auto-Healing System) Connection Resilience: Actively monitors the IBKR Gateway/TWS connection with a continuous keep-alive heartbeat.

Automatic Reconnection: Safely manages disconnects and handles error loops to ensure the bot remains operational without manual intervention.

  1. Telegram Telemetry Live Push Notifications: Receive instant alerts directly on your phone.

Detailed Trade Data: Get real-time updates for Order Sent, Order Executed (including IBKR fees), Trailing Stop Armed, and Final Net Profit.

🛠️ Technical Specifications Language: Python 3.9+

Broker Interface: Interactive Brokers via ib_insync

Connectivity: Supports both Paper Trading (Port 7497) and Live Accounts (Port 7496)

Supported Assets: Equities, Leveraged ETFs and Crypto

Security: Strict decoupling of sensitive data (API keys, Telegram tokens) via isolated configuration files.

Setup & Installation Please refer to the requirements.txt file for dependencies and config.example.py to securely set up your broker and Telegram credentials.

🛒 Get the Full Source Code

Ready to deploy your own algorithmic trading engine? You can purchase the complete, ready-to-run source code (including setup instructions and the exact strategy logic) on any of the platforms below:


About

Production-ready automated Python trading architecture for Interactive Brokers (TWS/Gateway) using ib_insync. Features quantitative execution (EMA/RSI), dynamic risk & position sizing, auto-healing reconnection watchdog, trailing stop profit protection, and live multi-asset P&L telemetry with instant Telegram alerts.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages