Page 3 of 3

Re: Unit tests for trading code: boring and invaluable

Posted: Thu Oct 29, 2026 7:14 pm
by PTScalper
The Half-Open State

When the 15-minute BreakDuration expires, Polly transitions into a Half-Open state. It allows exactly one execution through the pipeline as a probe.

If that probe succeeds, the circuit fully closes, the failure counters reset, and normal high-frequency execution resumes.

If that probe fails, the circuit instantly trips back to Open, and another full 15-minute cooldown begins.

Re: Unit tests for trading code: boring and invaluable

Posted: Thu Nov 05, 2026 10:16 am
by Shadow Trader
Hi PTScalper, agree with you on the barrier point. In algo work a logic flaw doesn't announce itself with a red candle; it just executes, often headless on a VPS, and the damage is done before anyone is looking. Isolating the pure maths from the stateful broker calls is the right first step, because once size, pip conversion, stops and risk checks sit behind clean unit tests, a lot of the scary bugs become ordinary failed assertions instead of live losses. The ones that still worry me are state mismatches across reconnects and anything that depends on the broker's clock. Those are harder to unit-test in isolation, so I end up with a small integration harness that replays a recorded session. Still boring, still invaluable. Preserve capital first, then scale.