-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
TWS Headless is an asyncio-native trading engine for Interactive Brokers. It connects to TWS or IB Gateway, manages a fleet of independently-funded trading plugins, and exposes a Unix-socket CLI (ibctl) for live control.
| Page | Description |
|---|---|
| Theory of Operation | How the system works end-to-end: startup, market data, plugin execution, order lifecycle, state persistence |
| CLI — Task Guide | How to do common tasks from the command line: fund plugins, transfer assets, place orders, manage plugins |
| Plugin Design | Concise guide to writing plugins: lifecycle, streams, signals, callbacks, holdings, MessageBus, full example |
| Plugin Manual | Complete authoring reference: every method, every field, every option |
IB TWS / Gateway
│ TCP
▼
AsyncIBTransport ← single asyncio reader coroutine
│
▼
Portfolio ← positions, orders, account, P&L
│
▼
PluginExecutive ← loads plugins, routes signals → orders
┌───┴───┐
Plugin Plugin ... ← isolated funding, state, instruments
│
▼
DataFeed ← tick/bar buffers, stream ref-counting
│
▼
MessageBus ← pub/sub between plugins
│
▼
CommandServer ← Unix socket → ibctl CLI
Plugins are the unit of strategy. Each plugin has its own cash balance, position inventory, and state. The engine routes signals from plugins to IB orders.
Holdings track what a plugin "owns" — cash and positions — independently of the real IB account. They persist across restarts via SQLite.
Transfers move cash or positions between plugins bookkeeping-side; no IB trades are placed.
Signals (TradeSignal) are returned from calculate_signals(). The executive reconciles signals across plugins and sends orders to IB.
Streams are reference-counted. Multiple plugins can subscribe to the same symbol; IB sees only one subscription.
MessageBus lets plugins share indicators, alerts, and signals without coupling.
TWS Headless
- Startup sequence
- Market data & streams
- Plugin execution
- Holdings & bookkeeping
- Order lifecycle
- State persistence
- See what's going on
- Fund a plugin
- Transfer assets
- Load and start a plugin
- Stop or pause a plugin
- Place a manual trade
- Send a plugin request
- Manage instrument list
- Reconcile holdings
- Move paper → live
- Shut down
- Full command reference
Plugin Manual ← complete reference
- File layout
- Lifecycle methods
- State persistence
- Market data streams
- Trade signals
- Order callbacks
- Holdings management
- MessageBus
- ContractBuilder
- Instrument compliance
- Multiple instances (slots)
- CLI help & messaging
- Threading rules
- Full example