Multi-component research and live-trading sandbox for FX, crypto, and equities using reinforcement learning, genetic algorithms, and walk‑forward optimization.
forex-rl/– Python trading research & execution stack (actor‑critic, GA, TCN policies, walk‑forward optimization, tools).local-broker/– Go-based local broker that emulates an OANDA‑style REST/streaming surface for fast offline and paper trading.streamer/– Market data ingestion and account state utilities (OANDA FX, Bitunix crypto) with QuestDB integration.bkup-forex-rl-YYYYMMDD/– Snapshots of earlierforex-rltrees kept for reference.ref/– Reference code and vendor SDKs used during experiments (e.g. Alpaca examples).
Key pieces:
- Offline and live trading runners (e.g.
online_trader.py,multi_instrument_box_trading.py,tpsl_trader.py). - Actor‑critic and TCN research code under
actor-critic/plus GA stacks underga-multi20/,ga-ness/, andga-trailing-20/. - Walk‑forward optimization framework under
wfo/(seeforex-rl/wfo/README.mdfor detailed CLI docs). - Feature engineering and hybrid models under
hybrid-agnostic/and the autoencoder scripts insupervised-ae/andunsupervised-ae/. - Tools for universe construction, account PnL, and OANDA/Alpaca connectivity under
tools/.
There is intentionally no single pinned requirements.txt for the Python stack; dependencies are managed per experiment. A typical setup is:
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
# Core libraries (adjust as needed for a given script)
pip install numpy pandas scipy torch matplotlib oandapyV20 requestsRunning tests (quick smoke over loaders, simulators, and strategies):
cd forex-rl
pytest -qFor walk‑forward experiments, see the examples in forex-rl/wfo/README.md. For GA Trailing‑20 work, see forex-rl/ga-trailing-20/ROADMAP.md.
A Go service that exposes an OANDA‑compatible REST + streaming surface backed by an in‑memory engine and pluggable pricing sources.
High level:
- Pricing sources for OANDA streams and synthetic ticks (
internal/pricing). - In‑memory engine with TP/SL/trailing‑stop enforcement (
internal/state). - File‑backed store for equity/time‑series snapshots (
internal/storage). - HTTP server wiring + config loader under
cmd/brokerandinternal/server.
Development loop:
cd local-broker
go test ./...
go run ./cmd/brokerMore details live in local-broker/LOCAL_BROKER_PLAN.md.
Utilities to ingest and explore market data, with scripts to push OANDA FX and Bitunix crypto into QuestDB and to track account state.
Examples:
forex-stream.py– OANDA FX tick/stream recorder.bitunix_to_questdb.py,oanda_to_questdb.py– ingestion to QuestDB.questdb_ingest.py,questdb_admin.py– admin/helpers for QuestDB tables.orders.py,account_state.py– simple account/order abstractions used by the streaming tools.
Systemd unit examples for long‑running ingestion live under streamer/systemd/.
- Local secrets (API keys, account IDs, etc.) live under
.secrets/and are not intended to be committed. - Most Python entrypoints read credentials from environment variables or
.env‑style files in.secrets/; see the relevant script’s docstring for exact names.
- See
streamer/forex-stream.py(requiresoandapyV20and env vars likeOANDA_DEMO_ACCOUNT_ID,OANDA_DEMO_KEY).