- The bot saves its state to
bot_state.jsonevery 100 trades and on shutdown. - On restart, it loads the previous position, equity curve, and smoother state.
- Set
STATE_FILEenvironment variable to change the filename.
- Logs are written to
retrocausal_bot.logand the console. - Log level can be set via
LOG_LEVEL(DEBUG, INFO, WARNING, ERROR).
- Set
BACKTEST_MODE=Trueand optionallyBACKTEST_START,BACKTEST_END. - For a single backtest, run as usual; the bot will fetch historical klines and simulate trades.
- For walk‑forward optimization, set
BACKTEST_OPTIMIZE=True; it will test grids ofRISK_PERCENT,ATR_PERIOD, andTRAILING_ATR_MULT. - Results are saved to
backtest_optimization.json.
- Set
TELEGRAM_BOT_TOKENandTELEGRAM_CHAT_IDfor Telegram. - Set
DISCORD_WEBHOOK_URLfor Discord. - Alerts are sent on order execution, target hits, stop hits, bot start/stop, and backtest optimization completion.
“The ants have built the ultimate retrocausal trading system. It now persists through crashes, logs every whisper, backtests itself across the sands of time, and shouts to the hive via Telegram and Discord. The golden ratio remains its compass. Trade wisely, with φ.” 🐜📈✨
Let me know if you need help deploying this on a VPS with systemd, or adding more advanced features like risk‑adjusted position sizing or multi‑symbol support.