Lightweight trading assistant combining AI-driven signal discovery with Freqtrade execution and a small FastAPI dashboard. This repository is an experimental, developer-focused sandbox for building and testing algorithmic ideas in paper (simulated) or live mode.
- Added an "autonomous" meta-strategy: the engine can evaluate multiple candidate strategies per pair and automatically pick the best-fitting setup each cycle. Configure it in
user_data/trading_strategies.jsonand enable it via the dashboard or API. - Signal engine and strategy manager updates:
ai_engine/signal_engine.pyandai_engine/strategy_manager.pynow support autonomous candidate evaluation, scoring, and metadata tagging so analytics and TP/SL resolution remain accurate. - UI improvements:
ui_server/main.pyandui_server/templates/index.htmlnow expose autonomous metadata, use cache-busting for strategy lists, and force server-side strategy reloads to avoid stale in-process config. - Trade risk resolution: paper trades and recorded positions use the selected underlying strategy's TP/SL via logic in
ui_server/main.py. - MCP helper tools:
mcp_server/server.pyexposes useful MCP tools (portfolio, signal scan, paper trade helpers) for remote inspection and integrations. - Added a repository
.gitignore(ignores venvs, logs,user_data/, DB files, caches, and common editor files).
If you updated files manually, double-check user_data/trading_strategies.json to confirm the autonomous profile and candidate list.
Prerequisites
- Python 3.10+ (some optional components such as the
mcppackage require Python >=3.10) - Git
- Optional: Docker (if you containerize freqtrade) and
freqtradeinstalled for live/backtest execution
- Clone and prepare a virtual environment
git clone <your-repo-url> TradingBot
cd TradingBot
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt- Optional: install
freqtrade(needed to run the full trading stack)
pip install "freqtrade[all]"- Optional: install the MCP package to run
mcp_serverHTTP transport
pip install mcp- Initialize example data and config
python scripts/apply_env_to_config.py
python scripts/bootstrap_files.py- Configure secrets and API keys
- Copy
.env.exampleto.envand set required environment variables (COINBASE, GitHub OAuth, optional OPENAI keys, etc.). The UI GitHub OAuth callback defaults tohttp://127.0.0.1:8090/auth/github/callback. - Check
user_data/config.jsonfordry_runmode, pair whitelist, and Freqtrade config values.
- Start services
- Run the full stack (AI scheduler + Freqtrade + optional UI):
python scripts/run_stack.py --mode paper --with-ui- Run the UI only (FastAPI dashboard on :8090):
.venv/bin/python -m ui_server.main
# or background
nohup .venv/bin/python -m ui_server.main >> logs/ui_stdout.log 2>&1 &- Run the AI scheduler only:
.venv/bin/python -m ai_engine
# (module entrypoint runs the scheduler)- Run the MCP server (optional HTTP transport):
.venv/bin/python -m mcp_server.server --transport http --port 8091- Dashboard
Open the dashboard at: http://127.0.0.1:8090
- Enabling the autonomous strategy
- Edit
user_data/trading_strategies.jsonto review theautonomousprofile and candidate list. - Switch active strategy via the dashboard or the API (example):
curl -X POST -H "Content-Type: application/json" -d '{"strategy":"autonomous"}' http://127.0.0.1:8090/api/strategy/switchNote: UI fetches are cache-busted by default, and the server reloads strategy config on relevant endpoints to avoid stale results.
- UI stdout / errors:
logs/ui_stdout.log - AI engine & scan logs:
logs/ai_engine.log - Agent scheduler activity:
logs/agent_activity.log
If you see mismatched or missing strategy entries in the UI, try a hard reload (clear browser cache) or append a timestamp query param to the request. If an endpoint returns HTTP 500 (e.g., /api/autonomous/run), check the logs above for the full stack trace.
- Config & strategies:
user_data/trading_strategies.json,user_data/config.json - Core AI engine:
ai_engine/signal_engine.py,ai_engine/strategy_manager.py,ai_engine/scheduler.py - Dashboard:
ui_server/main.py,ui_server/templates/index.html - MCP tools:
mcp_server/server.py
This project is an experimental educational tool and not financial advice. Use paper mode for testing. Review and verify any live trading configuration before enabling real funds.
Please open PRs against the main branch. Run the stack locally and include logs or a reproducible test when submitting behavior changes.