Trading
Algorithmic Trading Bot (Simulated Arena)
A two-language trading MVP in which Python generates synthetic market data, trains a classifier and backtests a momentum strategy, then streams signals to a C++ execution engine. The engine fills simulated orders over a plain POSIX TCP socket and logs each fill with a nanosecond steady_clock timestamp.
Overview
Install
Run these in order. The C++ server must be listening before the Python client connects.
# 1. Build the C++ execution engine (nlohmann-json is header-only, via Homebrew)
brew install nlohmann-json # skip if already installed
cd cpp
g++ -std=c++17 -O2 -Wall -I/opt/homebrew/opt/nlohmann-json/include -o server server.cpp
cd ..
# 2. Start the execution engine (foreground terminal A, or background with &)
./cpp/server 9009
# 3. In a second terminal, run the Python side in live mode against it
# (uses the shared repo-root venv, not a new one)
../.venv10projects/bin/python python/trading_bot.py --mode live --host 127.0.0.1 --port 9009
Backtest only, no C++ server needed:
../.venv10projects/bin/python python/trading_bot.py --mode backtest
CLI flags: --mode {backtest,live}, --host, --port, --delay (seconds
between streamed signals, default 0.02), --seed.
Docs
The full documentation covers how it works, configuration and results.