Skip to content

Commit

Permalink
n_positions is min(len(coins), n_positions)
Browse files Browse the repository at this point in the history
  • Loading branch information
enarjord committed Feb 24, 2025
1 parent a64223d commit 95208f8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,9 @@ def prep_backtest_args(config, mss, exchange, exchange_params=None, backtest_par
coins = sorted(set(config["backtest"]["coins"][exchange])) # sort for consistency
bot_params = {k: config["bot"][k].copy() for k in ["long", "short"]}
for pside in bot_params:
n_positions = max(0, min(bot_params[pside]["n_positions"], len(coins)))
bot_params[pside]["wallet_exposure_limit"] = (
bot_params[pside]["total_wallet_exposure_limit"] / bot_params[pside]["n_positions"]
if bot_params[pside]["n_positions"] > 0
else 0.0
bot_params[pside]["total_wallet_exposure_limit"] / n_positions if n_positions > 0 else 0.0
)
if exchange_params is None:
exchange_params = [
Expand Down

0 comments on commit 95208f8

Please sign in to comment.