Multi-bot trading command center built with React, TypeScript, Tailwind, shadcn/ui, Firebase and Supabase.
Production deploy: https://loicm.github.io/xMarket-bots/ (SPA served under /xMarket-bots/ on GitHub Pages).
This repository hosts the dashboard and automation scripts that monitor several trading strategies:
| Bot | Style | Tech / Logic |
|---|---|---|
| Momentum Scalper | Intraday momentum | TypeScript runner + Python heuristic |
| Mean Reversion Pro | FX/Equities mean reversion | TypeScript runner + Python logic |
| Trend Follower Elite | Medium-term trends | TypeScript runner + Python logic |
| ML Mean (ml-mean) | Logistic regression | Consumes ml-models/mean_reversion_model.json |
| ML Trend (ml-trend) | Gradient boosting regressor | Consumes ml-models/trend_model.pkl |
Each bot has a dedicated folder under src/bots/<slug> with the runner (bot.ts), the human-readable strategy (strategy.md) and history.json that feeds activation timelines in the UI.
The SPA (React/Vite) surfaces live P&L, ROI, trades, open/closed positions, code/strategy panels, localized in English and French. It pulls real-time metrics from Firebase Firestore and Supabase when credentials are provided; otherwise it falls back to mock data.
- Frontend: React 18 + Vite + TypeScript, shadcn/ui, Tailwind CSS, i18next for i18n (English/French).
- Data: Firebase Auth + Firestore for bot state, Supabase for historical OHLC (table
stock_market_history). - Automation: Node (tsx) scripts, Python helpers for model inference and training, GitHub Actions workflows.
git clone <repo-url>
cd xMarket-bots
npm install
npm run devCopy .env.local from .env.example (if present) or create it manually with the required Firebase, Supabase, and bot credentials (see below). The Vite dev server runs on http://localhost:5173 by default.
src/bots runners load both .env and .env.local. The UI reads variables prefixed with VITE_. Required keys include:
VITE_FIREBASE_API_KEY=...
VITE_FIREBASE_AUTH_DOMAIN=...
VITE_FIREBASE_PROJECT_ID=...
VITE_FIREBASE_STORAGE_BUCKET=...
VITE_FIREBASE_MESSAGING_SENDER_ID=...
VITE_FIREBASE_APP_ID=...
VITE_SUPABASE_URL=...
VITE_SUPABASE_ANON_KEY=...
BOT_MOMENTUM_EMAIL=...
BOT_MOMENTUM_PASSWORD=...
VITE_BOT_MOMENTUM_UID=...
BOT_MEAN_EMAIL=...
BOT_MEAN_PASSWORD=...
VITE_BOT_MEAN_UID=...
BOT_TREND_EMAIL=...
BOT_TREND_PASSWORD=...
VITE_BOT_TREND_UID=...
BOT_MLMEAN_EMAIL=...
BOT_MLMEAN_PASSWORD=...
VITE_BOT_MLMEAN_UID=...
BOT_MLTREND_EMAIL=...
BOT_MLTREND_PASSWORD=...
VITE_BOT_MLTREND_UID=...
Optional overrides (symbols, lot sizes, thresholds) are documented at the top of each runner.
npm run bot:momentum
npm run bot:mean-reversion
npm run bot:trend
npm run bot:ml-mean
npm run bot:ml-trend- All runners are TypeScript scripts executed via
tsx. - ML Trend also spawns
src/bots/ml-trend/trend_predictor.py. Install Python requirements before running:
python -m pip install -r scripts/ml/requirements.txtUse npx tsx scripts/admin/provision-bots.ts to create/authenticate bot users in Firebase. Configure bot entries in scripts/admin/bots.json and ensure FIREBASE_ADMIN_CREDENTIALS plus BOT_* env vars are set before running the script. The script writes new UIDs to scripts/admin/bots-output.json; copy them into .env.local / GitHub secrets.
Located in scripts/ml:
train_models.pyfetches OHLC data from Supabase, prepares features, trains:- A Logistic Regression mean-reversion classifier (StandardScaler + LogisticRegression).
- A HistGradientBoostingRegressor trend model.
- Best models are saved under
ml-models/(JSON for logistic, Pickle/JSON pair for trend). - Requirements: pandas, numpy, scikit-learn, requests, joblib, python-dotenv.
.github/workflows/train-ml-bots.yml runs daily (CRON) or on demand. Steps:
- Setup Python 3.11 and install
scripts/ml/requirements.txt. - Run
python scripts/ml/train_models.pywith Supabase secrets. - Commit the new
ml-models/*artifacts when they change.
Runs every hour (or via workflow_dispatch):
npm run bot:momentumnpm run bot:mean-reversionnpm run bot:trendnpm run bot:ml-mean(requires Python deps installed beforehand)npm run bot:ml-trend- Records activation history for each bot via
npm run bot:record-activation -- <slug> activated - Commits changes to the related
history.jsonfiles.
Builds and deploys the SPA to GitHub Pages on pushes to main:
- Checkout, install Node deps via
npm ci. - Export all
VITE_*env vars, runnpm run build(outputsdist/). - Copy SPA fallback
dist/404.html, upload artifact, deploy viaactions/deploy-pages.
An auxiliary workflow that triggers deploy.yml after certain updates (see file for details).
src/
├─ bots/ # Bot logic, history, strategies
├─ components/ # Reusable UI elements (shadcn-based)
├─ hooks/ # Data-fetch hooks (live stats, wealth history)
├─ data/mockBots.ts # Mock dataset used when no live data is available
├─ i18n/locales/ # en/fr translations
├─ pages/ # Router pages (Dashboard, BotDetail)
├─ lib/ # Utility modules (Firebase, Supabase clients, lifecycle helpers)
scripts/
├─ admin/ # Provisioning utilities for Firebase
└─ ml/ # ML training scripts + requirements
ml-models/ # Serialized ML artifacts committed by CI
.github/workflows/ # Automation workflows (run bots, deploy, train ML, etc.)
- i18n is powered by
react-i18next. Language switcher is available on the dashboard and bot detail pages. - Translations live under
src/i18n/locales/en.jsonandfr.json. All UI labels, button captions, table headers and chart tooltips are covered.
npm run build # type-check + bundle
npm run lint # ESLintNo automated component/unit tests are included yet; monitoring is done via CI runs and manual dashboard verification.
- Ensure GitHub secrets contain matching Firebase/Supabase credentials and bot UIDs (including ML bots).
- Verify
scripts/ml/train_models.pyhas run recently (models stored underml-models/). - Run
npm run buildlocally if needed, then push tomainto trigger GitHub Pages deployment.
- Fork the repo and create a branch (
git checkout -b feature/amazing-feature). - Make changes, add tests if applicable, run
npm run build. - Commit (
git commit -m "feat: amazing feature") and push. - Submit a Pull Request.
Please keep code in TypeScript, respect shadcn UI patterns, and update translations when adding UI strings.
This project is licensed under the MIT License. *** End Patch