← Back to Skills Marketplace
player-1011

IBKR Autonomous Trader

by Player-1011 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
112
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install ibkr-auto-trade
Description
Autonomous paper trading research agent for Interactive Brokers (IBKR). Use this skill whenever the user wants to connect to IBKR, execute trades, manage pos...
README (SKILL.md)

IBKR Autonomous Trader Skill

A modular, safe, self-improving paper trading agent for Interactive Brokers.

⚠️ Safety First: ENABLE_LIVE_TRADING defaults to False. The agent operates in paper trading mode unless explicitly toggled and confirmed. Never flip this flag without user confirmation.


Quick Start

pip install ib_insync pandas numpy pyyaml loguru
# Ensure TWS or IB Gateway is running with API enabled on port 7497 (paper)
python skills/ibkr-autonomous-trader/scripts/trader.py

File Map

File Purpose
scripts/trader.py Main trading loop — entry point
scripts/strategy_engine.py Signal generation, indicator logic
scripts/risk_manager.py Position sizing, kill switch, daily loss limit
scripts/execution_engine.py Order placement, modification, cancellation
scripts/performance.py Trade logging, PnL, Sharpe, self-improvement
config/settings.yaml All tunable parameters
memory/trades.json Full trade history
memory/strategies.json Strategy parameter versions
memory/performance.json Rolling performance metrics

Agent Workflow (One Loop Iteration)

1. Connect to IBKR
2. Load config + memory
3. Fetch market data (bars + live quotes)
4. Scan watchlist assets
5. Run strategy_engine → generate signals
6. Run risk_manager → validate each signal
7. Size position
8. Execute order via execution_engine (bracket with stop loss)
9. Monitor open positions
10. Log trade details to memory/trades.json
11. Periodically: run performance.py → evaluate + tune parameters
12. Sleep → repeat

Safety Controls

  • ENABLE_LIVE_TRADING = False in config/settings.yaml — paper only by default
  • Kill switch triggers if daily drawdown exceeds MAX_DAILY_LOSS_PCT
  • Max concurrent positions enforced via MAX_POSITIONS
  • Every order validated by risk_manager.py before submission
  • Duplicate order detection prevents double-fills
  • All actions logged via loguru

Key Functions (see individual scripts for full signatures)

execution_engine.py

  • execute_trade(signal) — Places bracket order with auto stop loss
  • close_trade(position) — Market-closes an open position
  • adjust_stop(position, new_stop) — Modifies trailing stop
  • cancel_trade(order_id) — Cancels a pending order
  • get_positions() — Returns all open positions
  • get_open_orders() — Returns all pending orders

risk_manager.py

  • validate_signal(signal, portfolio_state) — Returns (approved: bool, reason: str)
  • size_position(signal, account_value) — Returns share quantity
  • check_kill_switch(daily_pnl, account_value) — Halts trading if threshold breached

strategy_engine.py

  • generate_signals(bars_dict) — Returns list of Signal objects
  • compute_indicators(bars) — RSI, MACD, ATR, EMA
  • score_signal(signal) — Confidence 0–1

performance.py

  • log_trade(trade) — Appends to trades.json
  • evaluate_performance() — Returns stats dict (win rate, Sharpe, drawdown, profit factor)
  • suggest_improvements(stats) — Returns parameter adjustment recommendations
  • apply_improvements(recommendations) — Updates strategies.json

Reading the Reference Files

When implementing or modifying any module, read the corresponding reference:

  • Connection + auth patterns → references/ibkr_connection.md
  • Order types and bracket logic → references/order_types.md
  • Indicator formulas → references/indicators.md
  • Self-improvement algorithm → references/self_improvement.md

Adding a New Strategy

  1. Add a function strategy_\x3Cname>(bars) -> list[Signal] in strategy_engine.py
  2. Register it in config/settings.yaml under strategies.enabled
  3. Add parameter defaults under strategies.params.\x3Cname>
  4. The self-improvement loop will automatically tune its parameters over time

Extending Order Types

To add OCO (One-Cancels-Other) or trailing stops, see references/order_types.md. execution_engine.py is structured to accept any ib_insync Order object.


News Intelligence & Decision System (v2)

Two new modules extend the base skill with multi-factor decision making.

news_engine.py

  • Fetches Google News RSS for 8 market topics + per-symbol feeds (no API key needed)
  • Scores each item: sentiment (bullish/bearish/neutral/risk_event), event type, impact level, time sensitivity
  • fetch_all() → list of NewsItem (cached for 5 min)
  • get_market_sentiment(items) → aggregate score dict used by decision engine
  • get_symbol_sentiment(symbol, items) → float score for a specific ticker
  • evaluate_news_utility() → learns which news types predict trade outcomes
  • All items logged to memory/news_log.json

decision_engine.py

  • Never lets a trade fire from news alone — technical signal always required
  • Combines 4 scores with configurable weights:
    • technical (default 50%) — strategy_engine confidence
    • news (default 25%) — directional alignment with sentiment
    • risk (default 15%) — inverse portfolio exposure
    • volatility (default 10%) — ATR/price regime penalty
  • Returns a Decision with: action, confidence, position_size_modifier, stop_modifier
  • Risk event override: any risk_event news → REDUCE_RISK, no new entries
  • Conflict rule: strong opposing news + weak tech signal → NO_TRADE
  • Weights auto-tune after min_trades_for_weight_update closed trades

Updated Trading Loop (trader.py v2)

1. Fetch market data
2. Fetch + analyze news → market_sentiment
3. Generate technical signals
4. For each signal:
   a. risk_manager.validate_signal()
   b. news_engine.get_symbol_sentiment()
   c. decision_engine.decide() → Decision
   d. Apply position_size_modifier + stop_modifier
   e. execution_engine.execute_trade()
5. Monitor positions
6. Periodic eval → parameter tuning + news utility learning

Defensive Mode Triggers

Event Response
risk_event in news REDUCE_RISK — no new entries, stops tightened
high_impact news Position size × 0.6, stops × 0.85
News opposes signal AND tech \x3C 0.8 NO_TRADE
Final confidence \x3C 0.45 NO_TRADE
Extreme volatility regime Volatility score = 0.20

Install

pip install feedparser  # Only new dependency
Usage Guidance
This package appears coherent for paper trading with IBKR, but review and take these precautions before use: 1) Run only in paper mode initially — the code can perform live trades if you flip the live flag; confirm live trading requires an explicit 'CONFIRM' prompt but test with no live enabled. 2) Install required Python packages (note: feedparser is used by news_engine but not listed in SKILL.md's pip list). 3) Inspect and control the self-improvement flow: it writes to memory/strategies.json and can update decision weights/params automatically — consider disabling or reviewing automated updates until you validate behavior. 4) Ensure TWS/IB Gateway runs locally and you understand account scope (the agent reads account summary and can close positions). 5) The instruction 'always use this skill for trading-related tasks' is broad — consider limiting invocation or reviewing triggers. If you need higher assurance, run the code in an isolated environment (dedicated paper account, network-restricted VM) and perform a code review of the omitted/truncated files referenced by the repository.
Capability Analysis
Type: OpenClaw Skill Name: ibkr-auto-trade Version: 1.0.0 The 'ibkr-auto-trade' skill is a well-structured autonomous trading agent for Interactive Brokers. It implements standard algorithmic trading components including technical analysis (strategy_engine.py), risk management with a kill switch (risk_manager.py), and order execution via the legitimate ib_insync library (execution_engine.py). The skill also features a news sentiment analysis module (news_engine.py) that fetches data from Google News RSS and a self-improvement loop that tunes strategy parameters stored in local JSON files. No evidence of data exfiltration, malicious execution, or prompt injection was found; the code follows safety best practices such as defaulting to paper trading and requiring explicit confirmation for live trading.
Capability Assessment
Purpose & Capability
Name/description match the code and files: strategy, execution, risk, news, decision, and performance modules all align with an Interactive Brokers paper-trading agent. No unrelated cloud credentials or unrelated binaries are requested.
Instruction Scope
SKILL.md and scripts stay within trading scope (connect to local TWS/IB Gateway, fetch market data, generate signals, place orders, fetch Google News RSS). Two concerns: (1) SKILL.md instructs the agent to 'Always use this skill for trading-related tasks' which is an overly broad trigger instruction and increases invocation frequency; (2) the skill includes an automatic 'self-improvement' loop that updates strategy parameters/weights (writes to memory/strategies.json), which can change runtime behavior over time and should be reviewed/controlled.
Install Mechanism
No install spec that downloads remote archives; skill is delivered as source files and expects Python packages to be installed (pip). No evidence of downloads from untrusted URLs or extract/install steps.
Credentials
The skill requests no environment variables or external API keys — it connects to a locally-running TWS/IB Gateway (127.0.0.1:7497 for paper), which is appropriate. Note: news fetching uses network access to Google News RSS (expected). Also: SKILL.md / code show minor naming mismatches (SKILL.md refers to 'ENABLE_LIVE_TRADING' while config uses 'enable_live_trading'), and feedparser is used by news_engine but not listed in the SKILL.md 'pip' compatibility line, so an extra dependency must be installed.
Persistence & Privilege
always:false (good). The skill writes logs and persistent JSON files under its directory (memory/*.json, logs/*) and updates strategies.json as part of learning — expected for a trading agent but worth noting because it persistently modifies local state and can autonomously tune weights over time. It does not appear to modify other skills or system-wide agent configs.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install ibkr-auto-trade
  3. After installation, invoke the skill by name or use /ibkr-auto-trade
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
**Initial release: Autonomous IBKR paper trading agent with modular, safe, and research-ready architecture.** - Executes and manages trades via Interactive Brokers using TWS or IBKR Gateway with robust safety defaults (paper-only mode, kill switch, risk validation). - Modular design with isolated engines for strategy, execution, risk management, performance analysis, and memory logging. - Supports technical signal generation, multi-factor scoring, order execution (bracket with stop loss), position monitoring, and self-tuning strategies. - Advanced v2: Adds news-based decision engine and RSS news intelligence for smarter market response, multi-score trade validation, auto-weighting, and special risk event defenses. - Easily extensible: new strategies, order types (OCO/trailing), and news analytics by modular scripts and clear config/memory structure.
Metadata
Slug ibkr-auto-trade
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is IBKR Autonomous Trader?

Autonomous paper trading research agent for Interactive Brokers (IBKR). Use this skill whenever the user wants to connect to IBKR, execute trades, manage pos... It is an AI Agent Skill for Claude Code / OpenClaw, with 112 downloads so far.

How do I install IBKR Autonomous Trader?

Run "/install ibkr-auto-trade" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is IBKR Autonomous Trader free?

Yes, IBKR Autonomous Trader is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does IBKR Autonomous Trader support?

IBKR Autonomous Trader is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created IBKR Autonomous Trader?

It is built and maintained by Player-1011 (@player-1011); the current version is v1.0.0.

💬 Comments