2.4 KiB
2.4 KiB
Trading212 Python Scalping Bot - "Touch & Turn" (Opening Range Reversal)
This project implements the "Touch & Turn" scalping strategy, originally designed for ProRealTime, translated into Python for the Trading212 API.
Project Overview
- Strategy: Opening Range Liquidity Reversal (Touch & Turn).
- Asset Class: US Stocks (e.g., Netflix, Apple, Tesla).
- Timeframe: 15-minute chart.
- Operating Window: 09:30 - 11:00 EST (Opening of the US Regular Trading Session).
Strategy Logic (The Workflow)
- Identify the Opening Candle: Capture the
High,Low,Open, andCloseof the first 15-minute candle of the session (09:30 to 09:45 EST). - Filter for Liquidity:
- Calculate the 14-day ATR (Average True Range).
- The opening range (
High - Low) must be at least 25% of the ATR. If smaller, the bot stays flat for the day.
- Determine Direction:
- If the candle is Bearish (Close < Open): Prepare for a LONG entry at the
Low. - If the candle is Bullish (Close > Open): Prepare for a SHORT entry at the
High.
- If the candle is Bearish (Close < Open): Prepare for a LONG entry at the
- Calculate Targets (Fibonacci):
- The target price is the 38.2% Fibonacci level of the opening candle's range.
- Risk Management:
- Take Profit (TP): The distance from the entry to the 38.2% Fib level.
- Stop Loss (SL): Half the TP distance (Risk:Reward ratio of 1:2).
- Automatic Exit: Force close any open positions at 11:00 EST.
Technical Architecture
- API Client (
src/api/client.py): Handles REST calls to Trading212. - Strategy Engine (
src/strategy/touch_turn.py):- Monitors the clock for the 09:45 EST trigger.
- Fetches 14-day ATR and the 09:30-09:45 15m candle.
- Calculates entry/TP/SL levels.
- Execution Engine (
src/execution/manager.py): Places the limit orders and manages the position lifetime.
Getting Started
- Setup Environment:
pip install -r requirements.txt - Configuration:
- Set
TRADING212_API_KEYandTRADING212_BASE_URLin your.envfile. - Ensure your system clock is accurate or handle timezone conversions to EST.
- Set
TODOs
- Document the strategy logic.
- Implement ATR calculation in the strategy engine.
- Implement the 15m candle capture logic.
- Implement the entry/exit order placement logic in the execution manager.
- Create a backtesting script (optional but recommended).