It uses deep reinforcement learning to learn market patterns and automatically make buy, sell, or hold decisions, training itself by testing strategies and learning from outcomes.
Warning
Disclaimer: It is an experimental system; do not use it for actual investment decisions.
Checkout this repository if you want to learn more about Deep Reinforcement Learning.
Here's a guide for setting up Interactive Brokers for the Deep Reinforcement Learning Trading System:
- Visit Interactive Brokers: Go to www.interactivebrokers.co.uk (for UK)
- Open Account: Click "Open Account" and select "Individual"
- Choose Paper Trading: During setup, ensure you enable paper trading (demo account)
- Complete Application: Fill in all required information
- Fund Account: Paper trading accounts come with virtual money (usually $1M USD)
- Download TWS: Go to Client Portal → Trading Platforms → Download TWS
- Install: Run the installer (available for Windows, Mac, Linux)
- Alternative: You can also use IB Gateway (lighter version) instead of full TWS
- Download: Client Portal → Trading Platforms → Download IB Gateway
- Lighter Option: Gateway is better for API-only usage (no GUI trading interface)
- Login to TWS/Gateway
- Go to Configuration:
- TWS: File → Global Configuration → API → Settings
- Gateway: Configure → Settings → API
- Enable API:
- Enable ActiveX and Socket Clients
- Allow connections from localhost only (127.0.0.1)
- Read-Only API (for safety during testing)
- Set Socket Port:
- Paper Trading: 7497 (default)
- Live Trading: 7496 (use only when ready for live trading)
- Client ID: Set to 0 or any number (match this in your Python code)
✅ Enable API
✅ Read-Only API (initially)
✅ Allow connections from localhost (127.0.0.1) only
❌ Don't enable "Download open orders on connection"
❌ Don't enable "Allow connections from anywhere"
- Go to: Account Management → Market Data Subscriptions
- Enable:
- US Securities Snapshot and Futures Value Bundle (if trading US stocks)
- UK Securities (if trading UK stocks)
- Real-time quotes for your target markets
- Note: Some data feeds have monthly costs, but basic delayed data is often free
Daily setup process:
- Start TWS/Gateway:
# Make sure TWS or Gateway is running
# Login with your paper trading credentials
-
Verify API settings:
- Port: 7497 (paper trading)
- API enabled
- Correct client ID
-
Run DRL Trading System:
# In the notebook/script
if ib_conn.connect():
print("✅ Ready for trading!")
# Trading code here
Before running the DRL trading system:
- TWS/Gateway running and logged in
- API settings configured correctly
- Market data permissions enabled
- Test connection script works
- Can retrieve historical data
- Can place paper orders (test manually first)
Connection problems:
# If connection fails, check:
# 1. Port number
ib.connect('127.0.0.1', 7497, clientId=1) # Paper trading
# NOT 7496 (live trading)
# 2. Client ID conflicts
# Try different client IDs: 1, 2, 3, etc.
# 3. API not enabled
# Check TWS: File → Global Configuration → API → Settings
- No real-time data: Enable market data subscriptions
- Delayed data: Normal for free accounts, 15-20 minute delay
- Weekend/holidays: Markets closed, no live data available
Interactive Brokers (IBKR) requires you to maintain a minimum balance of $500 USD (£370 GBP) in your funded account to subscribe to and receive real-time market data, not as a one-time fee for data access. This $500 (£370 GBP) balance is a maintenance requirement, in addition to the monthly fees for the specific market data feeds you choose to subscribe to. Whilst basic delayed data may be available, you must have a funded account and select specific data subscriptions to receive live, timely information for trading.
You need to subscribe to these market data for the Trading Systems (DRL and Non-DRL) to work properly:
- NYSE (Network A/CTA)(L1) - $1.50 / month (£1.11 / month)
- NASDAQ (Network C/UTP)(L1) - $1.50 / month (£1.11 / month)
# Paper Trading (Safe for testing)
PAPER_TRADING_PORT = 7497
# Live Trading (Only when ready!)
LIVE_TRADING_PORT = 7496
# Always start with paper trading!
ib.connect('127.0.0.1', PAPER_TRADING_PORT, clientId=1)
- Always test with paper trading first
- Never use live trading until system is thoroughly tested
- Monitor all trades manually initially
- Start with small position sizes
Once you complete this setup, DRL Trading System will be able to connect to Interactive Brokers and execute paper trades safely for testing and validation.
Use the package manager pip to install required libraries:
# Prerequisites
python3 -m venv .venv
source .venv/bin/activate
uv pip install -r requirements.txt
- DRL Trading System:
- Click the
Run
button to run the individual cell of the interactive brokers deep reinforcement learning notebook.
- Click the
- Day Trading System:
- Click the
Run
button to run the individual cell of the interactive brokers day trading notebook.
- Click the
- Forex Trading System:
- Click the
Run
button to run the individual cell of the interactive brokers forex notebook.
- Click the
Do not run the cell that initializes the Interactive Brokers Live Trading (Live Trading Integration).
This project is licensed under the Modified MIT License.
(c) 2025 Finbarrs Oketunji. All Rights Reserved.
My non-negotiable fee for a custom enterprise trading system is £150,000. Let's talk about your requirements.