Regime Trading Bot
Adapts strategy based on HMM regime classification — mean-revert in neutral, trend-follow in trending. Framework: Python + pandas.
Live Output Preview
If you ran this bot right now, the API would return:
# Live API output — June 17, 2026 Market Regime: Trending Safety Score: 96.1 (HIGH) Composite Signals: BTC: sell (score: -0.269)\n ETH: neutral (score: -0.094)\n SOL: sell (score: -0.135)\n HYPE: strong_sell (score: -0.357)\n # The bot would use this data to make trading decisions
Complete Source Code
Copy this code and run — no API key required:
import requests, time
BASE = "https://algotick.dev"
def get_regime_strategy():
"""Adapt trading strategy based on HMM regime classification."""
regime = requests.get(f"{{BASE}}/v3/signals/regime",
params={{}}).json()
composite = requests.get(f"{{BASE}}/v1/signals/composite",
params={{}}).json()
for r in regime.get("regimes", []):
coin = r.get("coin")
label = r.get("regime_label", "UNKNOWN")
confidence = r.get("confidence_score", 0)
# Get composite signal for this coin
comp = next((s for s in composite.get("signals", [])
if s.get("coin") == coin), {{}})
score = comp.get("composite_score", 0)
if "trending" in label.lower():
# Trend-following: trade in direction of composite
if score > 0.3:
print(f"[LONG] {{coin}}: Trending regime, bullish composite ({{score:.3f}})")
elif score < -0.3:
print(f"[SHORT] {{coin}}: Trending regime, bearish composite ({{score:.3f}})")
elif "mean" in label.lower() or "revert" in label.lower():
# Mean-reversion: fade extreme moves
if score > 0.4:
print(f"[SHORT] {{coin}}: Mean-reverting, fade overbought ({{score:.3f}})")
elif score < -0.4:
print(f"[LONG] {{coin}}: Mean-reverting, fade oversold ({{score:.3f}})")
else:
print(f"[FLAT] {{coin}}: Regime={{label}}, staying neutral")
while True:
get_regime_strategy()
time.sleep(60)
Setup Instructions
- Install dependencies:
pip install requests(Python) ornpm install node-fetch(TypeScript) - Run the script and monitor the output
- Connect your exchange API for live trading
API Endpoints Used
Framework
Python + pandas
Data Source
Algo Tick API
# No API key required. All endpoints used by this template:
curl https://algotick.dev/v3/signals/regime
curl https://algotick.dev/v1/signals/composite
curl https://algotick.dev/v3/signals/safety
curl https://algotick.dev/v1/signals/volatility?coin=BTCDon't just stare at the dashboard. Automate it.
Every metric on this page is available via our sub-millisecond API.
Build trading bots, backtest strategies, and power AI agents with institutional-grade data.
More Python Templates
Liquidation Sniper Bot
A Python bot that monitors liquidation levels and places limit orders at cascade zones
Funding Arbitrage Bot
Automated funding rate harvester that captures extreme funding payments delta-neutral
Whale Alert System
Real-time notification system for large order placement and smart money movements
Portfolio Rebalancer
Signal-driven portfolio rebalancer using composite scores and regime filters