Arnold Trader — Telegram Mini App + Trading Bot (Bybit)
  • Python 81.5%
  • TypeScript 14.7%
  • CSS 1.5%
  • JavaScript 1.3%
  • Shell 0.8%
  • Other 0.2%
Find a file
Andrei 20b72a2564
All checks were successful
Arnold Forgejo CI / frontend-audit (push) Successful in 21s
Arnold Forgejo CI / secret-scan (push) Successful in 3s
Frontend Bundle Size Guard / Bundle size + lazy-routes gate (push) Successful in 29s
Frontend Bundle Size Guard / Lighthouse mobile performance (FE-03) (push) Successful in 13s
Arnold Forgejo CI / backend-tests (push) Successful in 3m59s
Deploy Arnold (Forgejo self-hosted) / deploy (push) Successful in 5m49s
Align dashboard autopilot strategy fallback
2026-06-11 15:00:14 +03:00
.forgejo/workflows Harden Forgejo CI pip installs 2026-06-11 10:37:01 +03:00
.husky fix: isolate pre-push tsc stdin 2026-05-31 22:23:22 +03:00
.planning fix: run signal copier in trading daemons 2026-05-31 01:19:48 +03:00
.seo-agent [CL-SEO-AGENT-P1B] feat(seo): mirror SEO Agent CLI + Forgejo weekly cron 2026-05-25 15:55:46 +03:00
backend Hide system strategies from public presets 2026-06-11 14:45:04 +03:00
docs [CL-GRID-LEVERAGE-CAP-UNIFY] docs: секция Grid risk flags (оба opt-in флага) 2026-06-10 21:28:00 +03:00
frontend Align dashboard autopilot strategy fallback 2026-06-11 15:00:14 +03:00
frontend-saas [CL-FALLOW] chore(trade): удаление dead-code выявленного fallow 2026-06-07 10:07:51 +03:00
mcp fix: patch frontend mcp dependency vulnerabilities 2026-06-03 13:52:32 +03:00
scripts Harden Forgejo CI pip installs 2026-06-11 10:37:01 +03:00
.env.example Remove obsolete Arnold hosting references 2026-05-02 17:44:54 +03:00
.gitattributes [CL-CI] Wire Arnold post-deploy validator into deploy 2026-05-18 19:38:26 +03:00
.gitignore chore: ignore agent instructions in runtime checkout 2026-06-04 14:49:59 +03:00
.gitnexusignore Remove generated backend static bundle 2026-05-21 01:47:35 +03:00
.ignore Remove generated backend static bundle 2026-05-21 01:47:35 +03:00
.npmrc test: keep npm config warning-free 2026-05-22 12:34:54 +03:00
.railwayignore 🔗 fix: sync saas with railway backend 2026-04-24 02:30:25 +03:00
CLAUDE.md [CL-DEPLOY-DRIFT] CLAUDE.md: UTF-16LE → UTF-8 2026-06-11 01:21:49 +03:00
Dockerfile Remove obsolete Arnold hosting references 2026-05-02 17:24:32 +03:00
package-lock.json [CL-HUSKY+FRONTEND] Add husky pre-push guard + fix pre-existing 17+ TS errors (#40) 2026-04-14 04:05:18 +03:00
package.json feat: implement 19-point trading readiness (#518) 2026-04-24 15:04:26 +03:00
PRODUCTION-CHECKLIST.md Remove obsolete Arnold hosting references 2026-05-02 17:24:32 +03:00
pytest.ini fix: retry empty ollama grid advice 2026-05-29 16:40:44 +03:00
signal-copier.sh [CL-452] fix(safety): two low-risk hardening fixes from CEO review (#372) 2026-04-20 21:48:09 +03:00
SPEC-v3.md Remove obsolete Arnold hosting references 2026-05-02 17:24:32 +03:00
TRADING-LOGIC-AUDIT.md [CL-AUDIT-TRADING] H12 cleanup: удалён мёртвый затенённый app/strategies/indicators.py 2026-06-10 16:50:55 +03:00

Arnold Trader

Arnold Trader is an automated cryptocurrency trading platform delivered as a Telegram Mini App. It combines a Python/FastAPI backend running multiple trading engines with a React single-page application frontend, all deployed on Hetzner PM2 with auxiliary daemons on Hetzner.

Tech Stack

Layer Technology
Backend Python 3.12, FastAPI, Uvicorn
Frontend React 19, Vite 8, Tailwind CSS 4, lightweight-charts
Database PostgreSQL (asyncpg connection pool, Alembic migrations)
Cache / Rate Limit Redis (SlowAPI middleware, 120 req/min default)
Exchange Bybit (primary), Binance, OKX, Bitget, Hyperliquid via CCXT
ML Pipeline LightGBM, scikit-learn, ONNX Runtime, pandas-ta
Telegram TWA SDK (@twa-dev/sdk), Telethon (signal copier)
Wallet TON Connect (tonconnect-ui-react)
Monitoring Sentry (FastAPI integration), structured JSON logging
Deployment Hetzner PM2 (Docker, auto-restart on failure), Hetzner (PM2 daemons)

Key Features

  • Grid Trading Engine -- Bidirectional grid on BTC/ETH/SOL with linear (futures) and spot modes. AI advisor uses OpenRouter to dynamically adjust grid range, profit targets, levels, and rebalance frequency every 15 minutes.
  • Strategy Runner -- 22 registered strategies including scalping, momentum, mean reversion, DCA, arbitrage, funding rate, liquidation hunter, trend sniper, order flow, smart scalper, AI signals, and more. Each runs on a configurable interval with per-user paper/live mode.
  • AI Signal Engine -- ML ensemble (LightGBM + ONNX) trained weekly on BTC price data. Generates buy/sell signals with confidence scores. Paper-trading gate validates AI accuracy before live execution.
  • Signal Copier -- Monitors 54 Telegram channels via Telethon, parses structured and free-form signals, auto-executes on Bybit.
  • Copy Trading -- Follow top traders from the Bybit leaderboard. Risk-managed position mirroring with configurable allocation.
  • Portfolio Analytics -- Performance snapshots every 6 hours, PnL calendar, monthly returns, equity curve, strategy-level breakdown.
  • Market Regime Detection -- Classifies market as bullish/bearish/ranging every 4 hours. Strategies scale positions and budgets based on regime.
  • Risk Management -- Three-level kill switch (env var), max drawdown stop, trailing stops, multi-level take-profit, dynamic leverage based on volatility, position monitoring every 5 seconds.
  • Lite Orchestrator -- Automated budget rebalancing every 4 hours. Boosts winning strategies, reduces losers, adjusts grid parameters based on volatility.
  • Kairos Agent -- Always-on background watchdog running on Hetzner via PM2. Monitors errors, balance drift, stale positions, and PM2 crashes. Sends Telegram alerts and auto-restarts processes.
  • Backtester -- Historical strategy validation against kline data.
  • Billing and Referrals -- Performance fee tracking and referral system.
  • Onboarding Wizard -- Risk quiz and exchange key setup flow for new users.
  • Internationalization -- Multi-language support via i18n module.

Quick Start

Prerequisites

  • Python 3.12+
  • Node.js 20+ (for frontend build)
  • PostgreSQL 15+
  • Redis (optional, falls back to in-memory rate limiting)

Backend

cd backend
python -m venv .venv
source .venv/bin/activate   # or .venv\Scripts\activate on Windows
pip install -r requirements.txt

# Configure environment
cp .env.example .env        # then fill in required values
# Required: DATABASE_URL, BYBIT_API_KEY, BYBIT_API_SECRET, TELEGRAM_BOT_TOKEN, TELEGRAM_USER_ID
# Optional: SENTRY_DSN, REDIS_URL, OPENROUTER_API_KEY

# Run database migrations
alembic upgrade head

# Start the unified service (all daemon threads)
python main.py

Frontend

cd frontend
npm install
npm run dev            # development server at localhost:5173
npm run build          # production build -> ../backend/static/

The production frontend is built and copied to backend/static/, where the FastAPI backend serves it as a single-page application. All non-API routes fall through to index.html.

Environment Variables

Variable Required Description
DATABASE_URL Yes PostgreSQL connection string
BYBIT_API_KEY Yes Bybit API key for trading
BYBIT_API_SECRET Yes Bybit API secret
TELEGRAM_BOT_TOKEN Yes Telegram bot token for notifications
TELEGRAM_USER_ID Yes Default Telegram user ID
PORT No HTTP port (default: 8000)
REDIS_URL No Redis URL for rate limiting
SENTRY_DSN No Sentry error tracking DSN
OPENROUTER_API_KEY No OpenRouter key for AI gates, AI agents, sentiment, grid advisor and Trading Assistant
ARNOLD_KILL_SWITCH No Set to 1 to halt all trading
DISABLE_TG_POLLING No Set to true to disable Telegram polling

Architecture Overview

The application runs as a single Python process (main.py) that spawns 13 daemon threads:

  1. API Server -- FastAPI served by Uvicorn on port 8000 with 35+ routers
  2. Telegram Bot -- Long-polling bot for commands and notifications
  3. Grid Trader -- Autonomous grid trading engine (60s cycle)
  4. Strategy Runner -- Multi-strategy analysis and execution (10s cycle)
  5. Futures Engine -- Dedicated futures position management
  6. Regime Detector -- Market regime classification (4h cycle)
  7. Snapshot Collector -- Portfolio snapshots + rebalance checks (6h cycle)
  8. Price Feeder -- Real-time prices via Bybit WebSocket with REST fallback (5s)
  9. Daily Summary -- Telegram summary at 21:00 UTC
  10. Position Monitor -- Trailing stop and take-profit checks (5s cycle)
  11. Orchestrator -- Automated strategy budget rebalancing (4h cycle)
  12. Onchain Signals -- On-chain data signal detection
  13. Meme Sniper -- Currently disabled, handled by trend_sniper strategy

Additionally, Kairos and Signal Copier run as separate PM2 processes on Hetzner.

For detailed architecture documentation, see ARCHITECTURE.md.