System Guide

Complete reference for every file, function, and workflow in the IBKR Options Income System.

Weekly Workflow
Monday 09:35 ET GitHub Actions triggers main.py monday
market_intel.py computes composite score (almanac + macro + technical + LLM + human)
strategy.py selects SPX strikes and builds recommendation
docs/data/trade_state.json updated and pushed to GitHub
ibkr-options-income.pages.dev auto-updates (Cloudflare, ~60 seconds)
alerts.py sends Telegram message to Professor Dr. Tan's phone
Professor Dr. Tan reviews on website and clicks APPROVE
executor.py connects to IBKR TWS and places the order
Telegram confirmation: trade filled, premium received
Daily 15:45 ET risk_manager.py checks 50% profit target or stop loss
Thursday 15:45 ET All positions force-closed, week P&L recorded
Python Files
config.py Python

Central configuration file. Every trading parameter lives here — nothing is hardcoded elsewhere. To change strategy behavior (number of spreads, strike distance, profit targets), edit only this file.

market_intel.py Python

The intelligence layer — connects CP3405 market prediction agents to trading decisions. Computes a composite score (0–100) from five sources. Score above 55 = proceed, below 45 = skip, below 35 = hard veto.

strategy.py Python

Bull put spread construction logic. Takes market intel composite score and current SPX price, selects optimal strikes, checks all trade gates, and builds the weekly recommendation object.

risk_manager.py Python

Enforces all risk rules. Never risks more than 3% of account per week. Monitors open positions daily and triggers closes when profit targets or stop losses are hit.

executor.py Python

IBKR TWS API integration. Connects to Trader Workstation on port 7496 and places the spread order. Requires TWS running with API enabled. Will NOT execute without Professor Dr. Tan's approval flag set.

alerts.py Python

Telegram notification system. Every significant trade event sends a formatted message to Professor Dr. Tan's phone. Credentials stored as GitHub Secrets — never in code.

main.py Python

Master controller. Entry point for all GitHub Actions workflows and manual runs. Orchestrates the full pipeline by calling the other modules in sequence.

Data & Configuration Files
docs/data/trade_state.json JSON

Single source of truth for all live system state. Updated by GitHub Actions after every run. The website reads this file to display the dashboard. Professor Dr. Tan's approval is also written here, which triggers execution on the next Actions run.

.github/workflows/monday_open.yml YAML

GitHub Actions workflow. Runs automatically every Monday at 09:35 ET (14:35 UTC). Can also be triggered manually via workflow_dispatch for testing. Calls main.py monday.

.github/workflows/daily_check.yml YAML

GitHub Actions workflow. Runs Monday–Friday at 15:45 ET (20:45 UTC) to check profit targets. Thursday run includes forced close of all open positions. Calls main.py check.

Website Files (docs/ folder → ibkr-options-income.pages.dev)
docs/index.html HTML

Trading Command Center dashboard. Reads trade_state.json and renders live KPIs, this week's recommendation, market intelligence bars, open positions, and trade log. Approve button sets approved flag and triggers execution workflow.

docs/master-prompt.html HTML

This system's resume prompt for Claude. Paste the prompt into any new Claude chat session to instantly restore full context — strategy, architecture, pending items, and credentials reference.

docs/system-guide.html HTML

This page. Complete file-by-file reference for the entire system.

Pending Setup Items
1 Set up Telegram bot — get TELEGRAM_BOT_TOKEN from @BotFather and TELEGRAM_CHAT_ID from getUpdates API PENDING
2 Enable IBKR TWS API — TWS → Edit → Global Configuration → API → Settings → Enable ActiveX and Socket Clients → Port 7496 PENDING
3 Add GitHub Secrets — repo Settings → Secrets → TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID PENDING
4 Wire approval button — update trade_state.json via GitHub API when Professor Dr. Tan clicks Approve PENDING
5 Live SPX price feed — replace placeholder in strategy.py with live IBKR market data call PENDING
6 First paper trade test — run main.py monday manually to validate full pipeline end-to-end PENDING
7 Cloudflare Pages connected to GitHub repo — auto-deploys from /docs folder ✅ DONE
8 All Python modules built and pushed to GitHub ✅ DONE
9 GitHub Actions schedules configured (Monday + Daily) ✅ DONE