Fix : exit if no losing trades before applyting slippage
This commit is contained in:
parent
6958160ae6
commit
78ae177a5b
@ -32,6 +32,10 @@ class CalmarHyperOptLoss(IHyperOptLoss):
|
||||
Objective function, returns smaller number for better results
|
||||
"""
|
||||
|
||||
# exclude the case when no trade was lost
|
||||
if(results.profit_percent.min() >= 0):
|
||||
return MAX_LOSS
|
||||
|
||||
simulated_drawdowns = []
|
||||
|
||||
backtest_duration_years = ((max_date-min_date).days/365.2425)
|
||||
@ -44,10 +48,6 @@ class CalmarHyperOptLoss(IHyperOptLoss):
|
||||
|
||||
sample_size = round(trade_count_average_per_year * SIMULATION_YEAR_DURATION)
|
||||
|
||||
# exclude the case when no trade was lost
|
||||
if(results.profit_percent.min() >= 0):
|
||||
return MAX_LOSS
|
||||
|
||||
# simulate n years of run to define a median max drawdown
|
||||
for i in range(0, NB_SIMULATIONS):
|
||||
randomized_result = results.profit_percent.sample(n=sample_size,
|
||||
|
Loading…
Reference in New Issue
Block a user