more fixes...
This commit is contained in:
parent
951a19fb00
commit
a46b7bcd6d
@ -47,11 +47,13 @@ class SortinoHyperOptLossDaily(IHyperOptLoss):
|
||||
)
|
||||
|
||||
total_profit = sum_daily["profit_percent_after_slippage"] - risk_free_rate
|
||||
total_downside = sum_daily['downside_returns'] - risk_free_rate
|
||||
expected_returns_mean = total_profit.mean()
|
||||
|
||||
results['downside_returns'] = 0
|
||||
results.loc[total_profit < 0, 'downside_returns'] = results['profit_percent_after_slippage']
|
||||
down_stdev = results['downside_returns'].std()
|
||||
sum_daily['downside_returns'] = 0
|
||||
sum_daily.loc[total_profit < 0,
|
||||
'downside_returns'] = sum_daily['profit_percent_after_slippage']
|
||||
down_stdev = total_downside.std()
|
||||
|
||||
if (down_stdev != 0.):
|
||||
sortino_ratio = expected_returns_mean / down_stdev * math.sqrt(days_in_year)
|
||||
|
@ -380,9 +380,9 @@ def test_sortino_loss_prefers_higher_profits(default_conf, hyperopt_results) ->
|
||||
|
||||
def test_sortino_loss_daily_prefers_higher_profits(default_conf, hyperopt_results) -> None:
|
||||
results_over = hyperopt_results.copy()
|
||||
results_over['profit_percent'] = hyperopt_results['profit_percent'] * 2
|
||||
results_over['profit_percent_after_slippage'] = hyperopt_results['profit_percent_after_slippage'] * 2
|
||||
results_under = hyperopt_results.copy()
|
||||
results_under['profit_percent'] = hyperopt_results['profit_percent'] / 2
|
||||
results_under['profit_percent_after_slippage'] = hyperopt_results['profit_percent_after_slippage'] / 2
|
||||
|
||||
default_conf.update({'hyperopt_loss': 'SortinoHyperOptLossDaily'})
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
|
Loading…
Reference in New Issue
Block a user