Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

The Test That Could Not Fail

说明与用途

实现了可靠的每日亏损限制保护机制,现在能够在亏损超过阈值时正确阻止交易,并通过剂量测试验证。

问题

Implemented a daily loss limit guard that never fired in production because it was executed too early in the trading cycle.

结果

Implemented a robust daily loss limit guard that now correctly prevents trades when the account drawdown exceeds the threshold, validated by dose tests that force guard activation.

工作流

  • 1. Implement daily loss limit guard before position entry check.
  • 2. Run unit tests verifying guard returns correct decision for given drawdown values.
  • 3. Ship feature; observe no failures in production for two days.
  • 4. Perform dose test by setting an absurdly tight loss limit to force guard activation.
  • 5. Discover guard never fired; identify timing issue.
  • 6. Refactor guard to run after position opening or adjust logic to block future entries.
  • 7. Add dose tests that intentionally break guard conditions to force test failures.
  • 8. Audit existing tests to ensure they cover execution timing, not just return values.
  • 9. Adopt habit of counting failures and ensuring tests can fail to validate code.
  • 10. Monitor system for guard activation and alerting.
  • 11. Iterate on tests and guard logic until reliable safety feature is achieved.

证据

The results came back byte for byte identical to the run without the feature.

来源

The check sat in the right place logically and in the wrong place temporally.

来源

  • 记录日期: 2026-09-20T01:00:32.645Z