Skip to content

fix: guard against anomalous ask prices in backtest fill engine#28

Merged
davison merged 1 commit intomainfrom
fix/anomalous-ask-price-guard
Apr 1, 2026
Merged

fix: guard against anomalous ask prices in backtest fill engine#28
davison merged 1 commit intomainfrom
fix/anomalous-ask-price-guard

Conversation

@davison
Copy link
Copy Markdown
Collaborator

@davison davison commented Apr 1, 2026

Summary

  • Adds a 5% relative-divergence guard in _compute_fill_price — when |ask - bid| / bid > 0.05, logs a warning and falls back to bid-only pricing
  • Prevents corrupted Dukascopy ask files (raw decimal vs pipettes) from producing wildly incorrect fill prices
  • Two new tests covering anomalous detection and normal spread pass-through

Context

15 out of 5,136 AUDNZD ask data files from Dukascopy have prices in raw decimal format (~1.025) instead of pipettes (~10,250). Discovered during RAD-31 investigation where bid/ask pricing destroyed portfolio alpha (+84,840 → -94,793 PnL).

Test plan

  • mypy --strict: zero errors
  • ruff: zero errors
  • pytest: 588/588 pass (including 2 new tests)
  • QA review approved by Testy

🤖 Generated with Claude Code

Co-Authored-By: Paperclip noreply@paperclip.ing

Corrupted Dukascopy ask data files (raw decimal instead of pipettes)
cause wildly incorrect fill pricing. Add a 5% relative-divergence
guard in _compute_fill_price that falls back to bid-only pricing
when ask/bid divergence exceeds the threshold.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@davison davison merged commit 22e5a10 into main Apr 1, 2026
5 checks passed
@davison davison deleted the fix/anomalous-ask-price-guard branch April 1, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant