MockDataService decimal overflow in strategy testing

Resolved 💬 1 comment Opened Sep 6, 2025 by DerivativesDev Closed Sep 7, 2025

Description

CreateStrategyTest fails with a System.OverflowException: Value was either too large or too small for a Decimal in the MockDataService during mock data generation.

Steps to Reproduce

  1. Navigate to Strategy Test page
  2. Select a market scenario
  3. Start a strategy test
  4. Exception occurs in MockDataService.GenerateBarForScenario

Error Details

System.OverflowException: Value was either too large or too small for a Decimal.
   at System.Number.ThrowOverflowException(String message)
   at System.Decimal.DecCalc.ScaleResult(Buf24* bufRes, UInt32 hiRes, Int32 scale)
   at System.Decimal.DecCalc.DecAddSub(DecCalc& d1, DecCalc& d2, Boolean sign)
   at System.Decimal.op_Addition(Decimal d1, Decimal d2)
   at TickHint.Infrastructure.Services.MockDataService.GenerateBarForScenario(MockMarketScenario scenario, String symbol, DateTime timestamp, Decimal previousClose, TimeFrame timeFrame, Decimal volatility, Decimal trendStrength) in MockDataService.cs:line 191

Root Cause Location

MockDataService.GenerateBarForScenario() at line 191 - decimal arithmetic is causing overflow during mock price calculation.

Environment

  • User: 144516c2-5b85-4a73-98c8-205f6ad77fba
  • Strategy: 43a60b3e-921e-46e3-8fad-8464c4b7f945
  • .NET 9

Expected Behavior

Mock data generation should complete successfully with realistic market data values.

Actual Behavior

Decimal overflow exception prevents strategy testing from starting.

Impact

  • High - Completely blocks strategy testing functionality
  • Affects all users trying to test strategies

Potential Solution Areas

  1. Add decimal overflow protection in MockDataService
  2. Validate input parameters (volatility, trend strength) for reasonable ranges
  3. Implement decimal arithmetic safeguards
  4. Add bounds checking for generated price values

Priority

Critical - Core functionality completely broken

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗