The mathematical formula for calculating maximum drawdown and recovery requirements.
Account peak: $10,000, Trough: $7,000 Drawdown = ($10,000 - $7,000) / $10,000 x 100% = 30% Recovery needed = 100 / (100 - 30) x 100% - 100% = 42.86% You need a 42.86% gain to recover from a 30% drawdown
from gfil_calculators.position_size import calculate_recovery_needed
result = calculate_recovery_needed(30)
print(f"Recovery needed: {{result['gain_percent']}}%")