trade_bot: The Trading System That Tries to Disprove Itself First

A PowerShell-driven multi-strategy framework that allocates capital by risk, stress-tests edges with PSR and DSR, and keeps itself alive with crash-only automation.

9 min read • View on GitHub • More from Valyarov-Marat

A watchmaker-like portfolio manager sits at a desk with multiple clocks, gauges, and stamped pages. Each clock stands for a strategy track, while a central dial controls how much capital each track receives. The scene explains that this trading system spends as much effort on validation and allocation as it does on entry signals.
trade_bot behaves less like a single bot and more like a skeptical portfolio manager, constantly judging which strategies deserve capital.
Key Takeaways

Most open-source trading bots want to prove they can enter. `trade_bot` wants to prove a strategy deserves to survive. That difference changes everything: how the code is organized, how capital is sized, how the system is tested, and how it recovers when something goes wrong.

The bot that treats every strategy like a suspect

The repository is built around a simple but unusual idea: a strategy is not trusted just because it backtests well once. It has to survive statistical skepticism, compete for capital against other tracks, and stay within operational guardrails once it goes live.

That makes `trade_bot` feel closer to a risk committee than a retail bot. The system is not asking, Can this strategy make money? It is asking, Does this edge survive stress, and if so, how much capital should it get?

That posture shows up everywhere. The codebase keeps strategy logic isolated, pushes portfolio judgment into the allocator, and treats uptime as a first-class feature instead of an afterthought.

A fleet of Tracks, not one monster script

The repository is structured as a set of Tracks. Each `track-*` folder holds a separate strategy, while `multibot/` acts like the portfolio brain. `server/` handles supervision, and `dashboard/` provides a local control surface.

The allocator is the real brain. It turns portfolio statistics into executable configuration, then sends those settings downstream to the live engine.

The important thing is not just that the tracks are separate. It is that they are supervised as a portfolio. Strategy code can fail without taking the whole system down, and the allocator can keep reshaping capital exposure without rewriting the underlying strategy engines.

Typical open-source bottrade_bot
A few strategies glued togetherIsolated Tracks with a central allocator
Entry and exit logic get most of the attentionValidation, allocation, and supervision get equal weight
Signals map directly to ordersPortfolio statistics compile into live config
Runtime recovery is often manualCrash-only recovery is part of the design

Why PowerShell is the weirdly right choice

PowerShell is the most surprising part of the stack, but it is not a gimmick. It works because the project is as much about orchestration as it is about trading. The code has to pull API data, manage JSON, spawn processes, supervise logs, and rewrite runtime config without much ceremony.

That is exactly the kind of problem PowerShell is good at. It handles structured objects cleanly, fits system-style automation, and makes local process control feel native rather than bolted on. For a long-running trading system, that matters more than language fashion.

There is also a practical advantage: the repo reads like infrastructure code with a financial model embedded in it. That makes the project easier to reason about than a monolithic strategy script, even when the strategy logic itself is sophisticated.

The live allocator is the real brain

`multibot-live.ps1` is where the project becomes a portfolio system. It reads track return streams, estimates volatility, and assigns capital with inverse-volatility weighting so lower-volatility tracks get more exposure and higher-volatility tracks get less.

That is a risk-parity instinct, translated into deployment logic. The allocator is not predicting the future. It is trying to make sure no single track dominates the portfolio just because it recently looked lucky.

The script also uses hysteresis. That matters because live systems can flap when equity hovers near a threshold. Hysteresis gives the bot a buffer, so it does not keep bouncing between real and dry-run behavior every time the numbers wobble.

Allocator stepWhat it doesWhy it matters
Volatility estimateMeasures how noisy each track has beenNoisy tracks deserve less capital
Inverse-volatility weightingAllocates more to steadier tracksTurns risk into sizing
Hysteresis gateAdds a switching buffer near thresholdsPrevents mode flapping
Config emissionWrites the live strategy configConverts portfolio judgment into execution

Seen plainly, the allocator is a compiler. It takes portfolio data as input, runs a rule set over it, and emits a config file that the execution engine can consume. That is a more interesting abstraction than a bot that simply sprays orders.

A close-up workbench shows strategy reports, a bootstrap drum, a sharpened gauge, and a pressure valve marked deflated. One report is being clipped away while weighted tokens are sorted into a capital tray. The image explains that the project tests ideas statistically before it allocates money to them.
The robustness battery is the anti-hype engine. It filters out lucky curves before they become funded behavior.

The robustness battery that keeps the bot honest

`mb-tests.ps1` is the project’s anti-hype layer. It does not just report backtest returns. It asks how fragile those returns might be once you account for luck, overfitting, and sample noise.

That is where PSR, DSR, and block bootstrap enter the picture. PSR adjusts for the shape of returns. DSR tries to discount data mining bias. Block bootstrap resamples chunks of history so the test respects streaks and serial dependence instead of pretending every day is independent.

The big idea is simple: a strategy is not impressive because it won one backtest. It is impressive if it still looks viable after the code has tried hard to break its confidence.

# Metric names that matter in the robustness battery
$metrics = @(
  'PSR',   # Probabilistic Sharpe Ratio
  'DSR',   # Deflated Sharpe Ratio
  'BootstrapCI',
  'MaxDD',
  'WinRate',
  'TailRisk'
)

Track C and the anatomy of a fade

Track C, in `track-C/newcomers.ps1`, gives the abstraction a concrete shape. It is built around fresh listings, wick filtering, and post-only execution. The edge lives in a narrow age window, and the code treats that window as something measurable rather than mystical.

That is a good example of the repo’s temperament. It looks for a very specific market condition, tests it aggressively, and then tries to express it with execution discipline instead of brute force.

The result is a strategy that feels surgical. It does not want every move. It wants the right kind of exhaustion, in the right kind of market, with the right kind of order placement.

Track C design choiceWhat it signals
Fresh listings onlyThe edge is time-sensitive
Wick filteringNot every spike is worth fading
Post-only ordersExecution quality matters
Narrow age windowThe strategy depends on market microstructure

The self-healing layer nobody brags about

The `server/` scripts are easy to overlook, but they are central to the story. `watchdog.sh` monitors heartbeats, kills stuck processes, and lets the supervisor restart them. That is crash-only thinking applied to trading infrastructure.

This is the kind of plumbing that separates a demo from a system you can leave alone. Hanging processes, stale sessions, and silent failures are treated as normal failure modes, not rare disasters.

The design is blunt, which is a compliment. If the process is unhealthy, kill it. If it can restart cleanly, the system can recover without drama.

Why this is not a beginner bot

This repository is mature, but it is not friendly in the plug-and-play sense. It expects a disciplined environment, a fixed directory layout, and a willingness to think in terms of logs, config files, supervisors, and risk budgets.

That makes it a better fit for a serious hobbyist, a small team, or a builder who wants a production-flavored framework rather than a toy example. The code is opinionated because the problem is opinionated.

If you want...trade_bot is a fit if...
A quick starter botYou want architecture more than convenience
A signal toyYou do not need portfolio-level risk control
A production-style frameworkYou are comfortable with orchestration and monitoring
A black-box strategyYou prefer transparent, testable components