Skip to content

About

Quantitativer Marktanalyse-Algorithmus — RSI, Fear & Greed, Smart Money Concepts. Live Paper Trading via Alpaca Markets.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Quantitativer Marktanalyse-Algorithmus

Python · Finanzmarktanalyse · KI-gestützte Entwicklung

Automatische Auswertung von Marktstruktur und Indikatoren — entwickelt als eigenständiges Lernprojekt mit strukturiertem Prompting und schrittweisem Implementierungsverständnis.

Status: Paper Trading live auf Alpaca Markets seit Mai 2026


Projektschwerpunkte

RSI & Technische Indikatoren

Eigenständige Implementierung klassischer Indikatoren ohne externe Bibliotheken:

# RSI via Wilder Smoothing — selbst implementiert
delta = df["Close"].diff()
gain  = delta.clip(lower=0).ewm(alpha=1/period, min_periods=period).mean()
loss  = (-delta.clip(upper=0)).ewm(alpha=1/period, min_periods=period).mean()
rsi   = 100 - 100 / (1 + gain / loss)
  • RSI Failure Swing Erkennung (Trendumkehr-Signal)
  • RSI Divergenz zu Preis (bullish/bearish)
  • Stochastic Crossover als Bestätigung
  • TTM Squeeze (Bollinger Bands innerhalb Keltner Channels)

Greed & Fear Index

Automatische Marktsentiment-Auswertung als Positionsgrößen-Filter:

# Dynamischer Positions-Multiplikator
if score < 20:    multiplier = 1.5   # Extreme Fear  → contrarian long
elif score < 35:  multiplier = 1.2   # Fear
elif score < 55:  multiplier = 1.0   # Neutral
elif score < 75:  multiplier = 0.8   # Greed
else:             multiplier = 0.5   # Extreme Greed → kein long entry

Smart Money Concepts (SMC)

Institutionelles Marktverhalten eigenständig analysiert und als Handelslogik implementiert:

  • Liquidity Sweeps — Erkennung von Stop-Hunt Bewegungen vor echten Ausbrüchen
  • Order Blocks — Identifikation institutioneller Einstiegszonen
  • Break of Structure (BOS) — Trendwechsel-Bestätigung auf Higher Timeframe
  • HTF Regime Filter — 4H EMA als Makro-Richtungsfilter für 15min Entries

Systemarchitektur

┌──────────────┐   ┌──────────────────┐   ┌──────────────────┐   ┌─────────────┐
│  Data Layer  │──▶│  Strategy Core   │──▶│  Risk Controller │──▶│  Broker API │
│              │   │                  │   │                  │   │             │
│ • Parquet    │   │ • TTM Breakout   │   │ • FTMO Guard     │   │ • Alpaca    │
│ • Indicators │   │ • Murphy Trend   │   │ • Equity Sizing  │   │ • Paper     │
│ • HTF EMA    │   │ • News/Sentiment │   │ • Daily DD Cap   │   │ • Live      │
└──────────────┘   └──────────────────┘   └──────────────────┘   └─────────────┘

Technische Kernentscheidungen:

  • Next-Bar Execution — Signal auf Bar i wird auf Bar i+1 Open ausgeführt. Kein Lookahead-Bias.
  • Equity-basiertes Sizing — Positionsgröße auf Floating Equity, nicht statische Balance.
  • FTMO Hard Guard — Bot stoppt bei -4.5% Tages-Drawdown (vor FTMO Limit -5%).
  • Max 3 freie Parameter — Verhindert Overfitting mathematisch. WF-Grid ≤18 Kombinationen.

Strategien

TTM Breakout (15min)

Squeeze-Energie-Release mit Momentum-Bestätigung und HTF Macro-Filter.

State Machine:
  [Squeeze ON]  → Bars zählen, Zone High/Low merken
  [Squeeze OFF] → Execution Window öffnet (8 Bars)
  [Im Window]   → Breakout über Zone + Momentum + 4H EMA
  [Entry]       → SL = 2.2×ATR, TP = 4.4×ATR (RR 1:2)

Murphy Trend (Daily)

Trend-Following auf GLD mit RSI Recovery Signalen und Stochastic Crossover.

Walk-Forward Ergebnisse:

Strategie Symbol WFE OOS Return OOS MaxDD
Murphy Trend GLD Daily 3.21 +3.00% -0.95%
TTM Squeeze SP500 15m 0.92 +12.15% -7.49%

WFE (Walk-Forward Efficiency) > 0.6 = robuste Strategie

News & Sentiment Filter

Dreischichtiger Filter vor jedem Trade:

Layer 1: Forex Factory Wirtschaftskalender
         → Kein Trade 15min vor/nach NFP, CPI, FOMC

Layer 2: Fear & Greed Index
         → Positionsgröße 0.5x bis 1.5x je nach Score

Layer 3: Social Media Sentiment (RSS)
         → Reduzierte Größe bei extremem Sentiment

Backtesting & Validierung

Eigene Engine gebaut — kein QuantConnect, kein Backtrader.

# Korrekte Next-Bar Execution
for i in range(len(df)):
    if open_trade:
        check_sl_tp(high, low)              # Exit auf aktuellem Bar
    if pending_signal:
        execute_at_open(open_price)         # Entry auf nächstem Bar Open
    pending_signal = strategy.generate_signal(df, i)

Monte Carlo Simulation (1.000 Runs):

SP500 TTM Squeeze:
  P95 MaxDD:    -4.87%   → FTMO sicher (Limit: -10%) ✅
  % Profitable: 100%

Walk-Forward Validation:

[── IS 9 Monate ──][OOS 3 Monate]
         [── IS 9 Monate ──][OOS 3 Monate]
                  [── IS 9 Monate ──][OOS]

WFE = OOS Return / IS Return
WFE > 0.6 ✅  WFE > 0.3 🟡  WFE < 0.3 ❌

Automatisierung & Live Trading

GitHub Actions — läuft alle 15 Minuten während US Marktzeiten:

schedule:
  - cron: '*/15 14-21 * * 1-5'

Synchronisierung zum Kerzen-Close:

def wait_for_candle_close(interval_minutes=15):
    next_close = ((minutes // interval_minutes) + 1) * interval_minutes
    wait       = (next_close - minutes - 1) * 60 + (60 - seconds) + 5
    time.sleep(wait)

KI-gestützte Entwicklung

Dieses Projekt wurde mit strukturiertem Prompting entwickelt:

  • Schrittweise Implementierung mit tiefem Verständnis jeder Komponente
  • Architektur-Reviews durch KI-Feedback (Overfitting-Erkennung, Bug-Analyse)
  • Iterative Verbesserung basierend auf Walk-Forward Ergebnissen
  • Dokumentierter Lernprozess von einfachen RSI-Signalen zur State-Machine Architektur

Projektstruktur

├── ftmo_bot2/                    # Production System (v2)
│   ├── data/loader.py
│   ├── indicators/core.py        # Vektorisierte Indikatoren
│   ├── strategies/
│   │   ├── base.py
│   │   └── ttm_engulfing.py      # TTM Breakout State Machine
│   ├── backtesting/
│   │   ├── engine.py             # Custom Backtesting Engine
│   │   └── walk_forward.py       # Walk-Forward Validierung
│   └── run.py
│
├── strategies/                   # Research & Entwicklung (v1)
│   ├── murphy_strategy_v2.py     # RSI Failure Swing + Divergenz
│   ├── news_strategy.py          # News & Sentiment Filter
│   └── ttm_squeeze.py
│
├── backtesting/
│   └── advanced_analysis.py      # Monte Carlo + Anchored WF
│
├── risk/ftmo_guard.py            # FTMO Risiko-Kontrolle
├── live/alpaca_connector.py      # Broker API
├── run_alpaca.py                 # Live Bot SP500
└── run_gld_daily.py              # Live Bot GLD

Daten Setup

python setup_data.py                           # Daily + Demo
python setup_data.py --tv                      # TradingView Anleitung
python setup_data.py --import XAUUSD datei.csv # CSV importieren

Setup

git clone https://github.com/r3ytr0n1x-png/QuantitativerMarktanalyseAlgorithmus
cd QuantitativerMarktanalyseAlgorithmus        # ← fix
pip install -r requirements.txt
python setup_data.py                           # ← Daten laden

Setup

git clone https://github.com/r3ytr0n1x-png/QuantitativerMarktanalyseAlgorithmus
cd ftmo-bot
pip install -r requirements.txt
cd ftmo_bot2
python run.py           # Backtest
python run.py --wf      # Mit Walk-Forward Validierung
python run.py --symbol XAUUSD --wf

Tech Stack

Python 3.12 Pandas NumPy Alpaca Markets API GitHub Actions Parquet TradingView


Eigenständig entwickeltes Lernprojekt — von einfachen RSI-Signalen zur produktionsreifen State-Machine Architektur mit automatisierter Live-Execution.

About

Quantitativer Marktanalyse-Algorithmus — RSI, Fear & Greed, Smart Money Concepts. Live Paper Trading via Alpaca Markets.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages