Files
trading-bot/GEMINI.md
T

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)

  1. Identify the Opening Candle: Capture the High, Low, Open, and Close of the first 15-minute candle of the session (09:30 to 09:45 EST).
  2. 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.
  3. 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.
  4. Calculate Targets (Fibonacci):
    • The target price is the 38.2% Fibonacci level of the opening candle's range.
  5. 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).
  6. 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

  1. Setup Environment:
    pip install -r requirements.txt
    
  2. Configuration:
    • Set TRADING212_API_KEY and TRADING212_BASE_URL in your .env file.
    • Ensure your system clock is accurate or handle timezone conversions to EST.

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).