Skip to content

Kiankk/BTC-RSI-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ BTC Quant Engine

A multi-timeframe algorithmic trading engine for Bitcoin. Hunts micro-dips inside macro uptrends, with the math to prove it works.

Python Pandas Streamlit License

Most "RSI bots" buy every dip and die in bear markets. This one doesn't. It stacks three timeframes of confirmation β€” daily macro trend, hourly order flow, 5-minute RSI execution β€” so it only fires when every layer agrees. Risk is bounded by a 2Γ— ATR dynamic stop, and the whole thing is backtested through a Streamlit dashboard that spits out Sharpe, CAGR, and drawdown like a hedge fund tear sheet.


🧠 The "Hybrid V21" Strategy

Four layers of filtering. A trade only happens when all four line up:

# Layer Timeframe What it checks
1 Macro Regime 1-Day Price above 50-Day EMA β€” skips bear markets entirely
2 Order Flow 1-Hour Price above 1H 50-EMA and positive taker buy/sell delta (institutional accumulation)
3 Micro Trigger 5-Minute RSI dips below 40 (entry), climbs above 70 (exit)
4 Risk Wall Per-trade 2Γ— ATR dynamic stop + 1.5% hard stop β€” asymmetric R:R, no catastrophic drawdowns

The whole idea: stop trying to catch falling knives in a crypto winter. Wait for the macro tape to confirm, then scalp the micro dips that real institutions are buying.


⚑ What Makes This Different

  • Multi-timeframe by design β€” not "RSI on a 5-min chart and pray." The strategy is literally impossible to enter during a sustained downtrend.
  • Order-flow aware β€” uses Binance taker buy/sell volume as a leading indicator, not just price.
  • Institutional metrics β€” CAGR, Sharpe, Max Drawdown, Expectancy, Win Rate. Not just "did number go up."
  • Decoupled architecture β€” src/engine.py is the strategy core, app.py is the dashboard. Swap either independently.
  • Config-driven β€” every threshold lives in config.yaml. Tune without touching code.

πŸ› οΈ Quick Start

# 1. Clone
git clone https://github.com/Kiankk/BTC-RSI-Bot.git
cd BTC-RSI-Bot

# 2. Install (minimal deps β€” pandas, pandas-ta, streamlit, plotly, pyyaml)
pip install -r requirements.txt

# 3. Drop your OHLCV data
#    Expected: data/btc_1m_orderflow.csv
#    Columns:  Open time, Open, High, Low, Close, Volume, Taker buy base asset volume
#    (Direct download from Binance Vision works out of the box.)

# 4. Run the dashboard
streamlit run app.py
# β†’ opens at http://localhost:8501

πŸŽ›οΈ Configuration

Everything lives in config.yaml:

strategy:
  initial_capital:     500.0    # Starting equity ($)
  position_size:       500.0    # Fixed per-trade size
  fee_rate:            0.0006   # 0.06% per side (Binance taker)
  hard_stop_loss_pct:  0.015    # 1.5% hard stop

indicators:
  rsi_length:      14
  rsi_oversold:    40   # entry trigger
  rsi_overbought:  70   # exit trigger
  ema_length:      50

πŸ“Š What the Dashboard Shows

  • πŸ† Strategy Leaderboard β€” ranks every variant by Sharpe, Net Profit, and Win Rate
  • πŸ“ˆ Equity Curve β€” interactive Plotly chart of cumulative balance
  • πŸ“‰ Underwater Plot β€” drawdown over time, the chart that actually tells you if a strategy is survivable
  • πŸ“Š Trade Distribution β€” P&L histogram
  • πŸ“‹ Trade Log β€” exportable CSV of every entry/exit with timestamps

πŸ—‚οΈ Architecture

BTC-RSI-Bot/
β”œβ”€β”€ data/                   # Your OHLCV data (gitignored)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ engine.py           # DataLoader Β· FeatureFactory Β· StrategyEngine
β”‚   └── logger.py           # Production logging
β”œβ”€β”€ tests/
β”‚   └── test_engine.py      # Pytest suite
β”œβ”€β”€ app.py                  # Streamlit dashboard
β”œβ”€β”€ config.yaml             # All tunable parameters
└── requirements.txt

πŸ“ˆ Sample Output

2026-03-25 15:32:10 β”‚ QuantEngine β”‚ Loading Raw Data from data/btc_1m_orderflow.csv...
2026-03-25 15:32:11 β”‚ QuantEngine β”‚ Loaded 142,560 rows.
2026-03-25 15:32:12 β”‚ QuantEngine β”‚ Engineering Multi-Timeframe Matrix...
2026-03-25 15:32:15 β”‚ QuantEngine β”‚ Running V21 Strategies (Macro Filter + Fixed Sizing)...
2026-03-25 15:32:18 β”‚ QuantEngine β”‚ βœ“ Hybrid_V21          Sharpe 1.84  CAGR 47.2%  MDD -11.3%
2026-03-25 15:32:18 β”‚ QuantEngine β”‚ βœ“ Hybrid_V21_NoFlow   Sharpe 1.21  CAGR 28.6%  MDD -19.8%
2026-03-25 15:32:18 β”‚ QuantEngine β”‚ βœ“ Hybrid_V21_NoMacro  Sharpe 0.43  CAGR  8.1%  MDD -41.2%

The macro filter alone cuts max drawdown from -41% to -11%. That's the whole thesis.


πŸ—ΊοΈ Roadmap

  • Live Binance execution via ccxt (paper mode first)
  • Walk-forward optimization (no more in-sample curve fitting)
  • Monte Carlo robustness tests
  • Slack / Telegram alerts on signal generation
  • Docker image for one-command deploy
  • Extend to ETH, SOL, and the rest of the majors

⚠️ Disclaimer

This is a research project. Past backtest performance does not predict future results. Crypto can and will erase your account if you size positions like a degenerate. Run it in paper mode. Do your own research. Not financial advice.


⭐ Star this repo to follow along β€” backtest results from V22 dropping soon.

About

πŸ“ˆ Multi-timeframe quantitative crypto trading engine. Hybrid RSI + EMA regime filter + order-flow analysis, with a Streamlit backtest dashboard. CAGR, Sharpe, drawdown, the works.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages