Skip to content

FMATheNomad/trading-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

567 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ FMA ALPHA QUANT LABS β€” The Blast Engine v3

"I don't need to know which way the market will move. I just need to be the ONLY ONE who knows when it moves." β€” Nathan Mayer Rothschild

Bot trading kripto 100% engineering, zero AI cost untuk Indodax.
396 commits. Fully autonomous. Zero human intervention.


πŸ“‚ File Structure

File Fungsi
main.py Orchestrator β€” portfolio cycle, momentum scanner, state machine, Telegram poller, deadman
rules.py Regime-gated decision engine β€” BULL/BEAR β†’ momentum, SIDEWAYS β†’ mean-reversion, HIGH_VOL β†’ survival
risk_manager.py ATR SL/TP, per-regime Kelly, circuit breaker, validate_allocation
executor.py Indodax HMAC-SHA512 signing, market/maker_first/maker orders
data_layer.py Indodax REST API (ticker, pairs, depth, OHLCV)
market_ws.py WebSocket realtime tickers (24h summary)
private_ws.py WebSocket order fill notification
deadman.py /countdownCancelAll safety net (15 menit)
indicators.py Teknikal indikator (RSI, MACD, BB, EMA, ADX, MFI, Hurst, Skew)
hmm_regime.py HMM regime detector (4 states)
momentum.py Velocity-aware momentum engine
patterns.py Paradiddle pattern matching (RLRL reversal detection)
persist.py JSON state persistence (semua survive restart)
db.py SQLite trade log + chat history
notifier.py Telegram sender
config.py Semua konfigurasi
.env Environment variables (gitignored)

🧠 Arsitektur β€” State Machine + Regime Gate

BUY β†’ MARKET (keisi pasti, fee taker 0.31%)
  ↓
STATE MACHINE (kelola exit)
  β”œβ”€β”€ SIDEWAYS β†’ TP_ACTIVE: pasang TP limit @ ATRΓ—2, SL @ ATRΓ—1.2
  β”œβ”€β”€ BULL β†’ TRAILING: initial SL @ ATRΓ—0.5, trailing SL @ ATRΓ—1.5
  └── HIGH_VOL β†’ survival (no entry)
       ↓
Transisi otomatis via WS tick:
  TP_ACTIVE β†’ harga turun ke SL? β†’ cancel TP, place SL
  SL_ACTIVE β†’ harga balik? β†’ cancel SL, place TP
  TRAILING  β†’ harga naik? β†’ trailing SL ikut naik
       ↓
FILLED β†’ closed, cooldown 24h (gak ambil coin user)

HMM sebagai HARD Gate

State Strategi Entry Exit Kelly
BULL (β‰₯5 cycle β†’ πŸ”΄ Rothschild) Momentum + trailing Market buy Trailing SL (ATRΓ—1.5) + pyramid 25%
BEAR Momentum defensif Market buy TP limit @ ATRΓ—2 15%
SIDEWAYS Mean-reversion (BB fade, RSI) Market buy TP limit @ ATRΓ—0.5 10%
HIGH_VOL Survival ❌ No entry Exit only 5%

πŸ”¬ State Machine β€” Mekanisme Utama

Setiap posisi punya state yang di-track di _position_states:

State Deskripsi
NEW Init, segera overwrite
PENDING TP/SL gagal β†’ retry tiap cycle
TP_ACTIVE TP fixed @ entry + ATRΓ—2. Harga turun? β†’ cancel TP, place SL
SL_ACTIVE SL active. Harga balik? β†’ cancel SL, place TP
TRAILING No TP, trailing SL. Harga naik? β†’ SL ikut naik. Pyramid ON

Transisi realtime via WS tick (bukan nunggu cycle 60 detik):

  • TP limit order nangkring di exchange β€” keisi otomatis
  • SL limit order nangkring β€” keisi kalau harga turun
  • HARD SL: kalau harga >3% di bawah SL β†’ force close di bid

πŸ”¬ Penemuan 1: Mean-Reversion Module

Aktif saat HMM = SIDEWAYS:

Entry:  Close ≀ BB_lower + RSI < 35 + volume surge
Exit:   TP ATRΓ—0.5 (0.5-1%)
SL:     ATRΓ—0.8
WR:     65-70%
Maks:   2 posisi

πŸ”¬ Penemuan 2: Paradiddle Pattern

Deteksi pola RLRL (Resistance/Low):

Pola Arti Aksi
RLRR Fake breakout SELL
LRLL Fake breakdown BUY
RRL after RRR Exhaustion SELL
LLR after LLL Exhaustion BUY

πŸ”¬ Penemuan 3: The Rothschild Asymmetry

Power Law: 90% loss rate, 10% home run

Initial SL: ATRΓ—0.5 (2.5%) β€” tight cut
Trailing SL: ATRΓ—1.5 β€” ride runner
Pyramid: profit ATRΓ—0.5 β†’ tambah 50% market buy
Entry_mode per posisi: exit pake aturan saat entry, bukan mode aktif

Matematika:

  • 9 trade rugi 2.5% Γ— 9 = -22.5%
  • 1 trade profit 10% Γ— 1.5 (pyramid) = +15%
  • Masih negatif tanpa trailing. Trailing SL bikin winner bisa 15-20% β†’ NET POSITIF.

πŸ”¬ Penemuan 4: Reflexive Vortex Model (RVM)

Bukan ngukur magnitude sinyal, tapi phase alignment 4 loop:

  1. Price acceleration β€” velocity makin cepat
  2. Volume surge β€” volume > price velocity
  3. Order book imbalance β€” tekanan beli/jual real-time
  4. HMM confidence β€” BULL/BEAR > 0.9
Loop Aligned Aksi Size
β‰₯3 (VORTEX) ALL-IN, trailing ATRΓ—3, no TP 50%+
2 Rothschild normal 15-25%
0-1 Skip 0-10%

πŸ›‘οΈ Circuit Breaker β€” 3 Lapis

Lapis Trigger Aksi Persist
Daily loss Equity turun Rp15k dari peak Stop entry, TP-only βœ…
Consecutive loss 5 hari loss berturut Stop total 72 jam βœ…
Equity floor Equity < Rp10k Shutdown total βœ…
Drawdown 15% dari all-time peak Warning βœ…
Deadman Bot crash 15 menit Exchange cancel order Exchange
SM cooldown 24h setelah SM FILLED Skip re-init (aman buat user) ❌

πŸ’° Fee Struktur (Market Buy + Maker Sell)

Transaksi Fee
BUY market 0.31% (taker)
SELL limit (TP) 0.20% + PPh 0.21% + CFX 0.0111%
Round trip ~0.73%

πŸ“¦ Deployment

Procfile:  worker: python main.py
Runtime:   python-3.12
Platform:  Railway (auto-deploy from GitHub)
Volume:    /data (state.json + trades.db)
Total:     396 commits, ~4000 baris kode

πŸ€– Telegram Commands

Command Fungsi
/status Portfolio & posisi
/ask <coin> Detail sinyal & ATR koin
/atr ATR, SL, TP semua posisi
/greed Bypass daily loss (1Γ—/hari)
/why Alasan bot gak trading
/commands Daftar lengkap
/project Proyeksi harian, bulanan, tahunan
/today Performa hari ini
/perf Win rate & stats

πŸ† Benchmark

Dari riset independen: "Boutique systematic prop-trading system" β€” secara risk-management dan signal architecture, bot ini jauh di atas retail bot (3Commas/Bitsgap/Cryptohopper/Gunbot) dan setara junior prop desk institusional.

Unik: Satu-satunya bot dengan Full Indodax API Coverage β€” tidak ada platform retail besar yang support Indodax.


βš–οΈ License

Copyright (C) 2026 FMA ALPHA QUANT LABS β€” AGPL-3.0


"Yang penting bukan profit di bear market. Yang penting masih idup pas bull datang." β€” FMA

About

πŸ₯ FMA Alpha Quant Labs β€” Systematic crypto trading bot for Indodax. HMM regime gate + state machine + market buy + limit sell + circuit breaker. 396 commits. Fully autonomous. 100% engineering, zero AI cost.

Topics

Resources

License

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages