Skip to content

Commit 354f090

Browse files
committed
Fix ranking
1 parent 0618a85 commit 354f090

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

investing_algorithm_framework/app/analysis/ranking.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def compute_score(metrics, weights, ranges):
3434
if not hasattr(metrics, key):
3535
continue
3636
value = getattr(metrics, key)
37-
if value is None or (
38-
isinstance(value, float) and
39-
(math.isnan(value) or math.isinf(value))
40-
):
37+
# Skip non-numeric values (e.g., Trade objects for best_trade/worst_trade)
38+
if not isinstance(value, (int, float)):
39+
continue
40+
if value is None or math.isnan(value) or math.isinf(value):
4141
continue
4242
if key in ranges:
4343
value = normalize(value, ranges[key][0], ranges[key][1])

investing_algorithm_framework/app/eventloop.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,14 @@ def _run_iteration(
553553
else:
554554
data = {}
555555

556+
for on_strategy_run_hook in \
557+
self._algorithm.on_strategy_run_hooks:
558+
on_strategy_run_hook.execute(
559+
strategy=strategy,
560+
context=self.context,
561+
data=data
562+
)
563+
556564
logger.info(f"Running strategy {strategy.strategy_id}")
557565
strategy.run_strategy(context=self.context, data=data)
558566

investing_algorithm_framework/domain/backtesting/backtest_evaluation_focuss.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def get_weights(self):
162162
"cagr": 2.5,
163163
"total_net_gain": 2.0,
164164
"average_trade_return_percentage": 1.5,
165-
"best_trade": 1.0,
165+
"average_trade_gain_percentage": 1.0,
166166

167167
# Profit consistency
168168
"win_rate": 2.0,
@@ -217,7 +217,6 @@ def get_weights(self):
217217
"max_drawdown": -3.0,
218218
"max_drawdown_duration": -1.5,
219219
"annual_volatility": -2.0,
220-
"worst_trade": -1.0,
221220

222221
# Consistent performance
223222
"win_rate": 2.0,

0 commit comments

Comments
 (0)