2026-05-09 00:18:42 +01:00

Trading212 "Touch & Turn" Scalping Bot

This project implements the "Touch & Turn" scalping strategy (Opening Range Liquidity Reversal) in Python for the Trading212 API. It is optimized for UK traders using ISA and optional CFD accounts.

⚠️ Disclaimer

This software is for educational purposes only. Trading in financial markets involves a high degree of risk. Always use the practice/demo environment (demo.trading212.com) to test strategies before using real money.


Strategy Overview

The strategy capitalizes on the initial liquidity and volatility of the US market open (09:30 EST).

  1. The Setup: Captures the 15-minute opening candle.
  2. The Filter: Minimum range of 25% of 14-day ATR.
  3. The Trigger (Split-Account Optimized):
    • LONG (Bearish candle): Bot executes a Market BUY in the ISA account.
    • SHORT (Bullish candle):
      • ISA Option: Buys a 3x Inverse ETP (if available).
      • CFD Option: Performs a Direct SELL in the CFD account (if SPLIT_ACCOUNT_MODE=True).
  4. The Targets:
    • Stop Loss (SL): Physical broker-side order with ATR-based padding.
    • Take Profit (TP): Manually monitored by the bot to hit 38.2% Fibonacci retracement.
  5. Time Exit: All positions forcefully closed at 11:00 EST.

Installation & Setup

  1. Setup environment:

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    
  2. Configure .env:

    # Primary Account (ISA)
    TRADING212_API_KEY_ID=...
    TRADING212_API_KEY=...
    TRADING212_BASE_URL=https://demo.trading212.com/api/v0/
    
    # Secondary Account (CFD - Optional for Shorting)
    CFD_API_KEY_ID=...
    CFD_API_KEY=...
    CFD_BASE_URL=...
    
    SPLIT_ACCOUNT_MODE=True
    VIRTUAL_STARTING_BALANCE=250
    ISA_MODE=True
    

Split-Account Mode

To overcome the lack of Inverse ETPs for certain stocks, the bot can use a Trading212 CFD account for shorting.

  • How it works: When a Short signal is found, the bot checks if an Inverse ETP exists. If not (or if Split-Account mode is preferred), it routes the trade to the CFD account as a direct SELL order.
  • Benefit: 100% coverage of all market opportunities.

Risk Management

  • 5% Risk Rule: Risks 5% of the Virtual Balance (£250 starting point) per trade.
  • Capital Partitioning: Automatically divides capital among active trades to prevent over-exposure.
  • ATR Padding: Stop losses are automatically widened to at least 10% of daily ATR to avoid premature stop-outs from noise.

Monitoring

  • Journal: Monitor via journalctl -u touchturn.service.
  • Logs: Real-time mirrored logs in logs/bot_YYYY-MM-DD.log.
  • PnL: Performance ledger in pnl_tracking.csv.

Architecture

  • main.py: Daily orchestrator with dual-account routing.
  • src/execution/manager.py: Hybrid exit management (Broker SL / Bot TP).
  • src/strategy/touch_turn.py: Logic engine with ATR padding.
  • src/strategy/inverse_mapping.py: ISA-specific shorting map.
S
Description
No description provided
Readme 172 KiB
Languages
Python 100%