Skip to content

Commit a402ed6

Browse files
committed
Add parameters check for vector backtest
1 parent 9adbc51 commit a402ed6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

investing_algorithm_framework/services/backtesting/backtest_service.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,20 @@ def create_vector_backtest(
144144
portfolio_configurations = self._portfolio_configuration_service\
145145
.get_all()
146146

147-
if (portfolio_configurations is None
147+
if (
148+
portfolio_configurations is None
148149
or len(portfolio_configurations) == 0
149-
and initial_amount is None
150+
) and (
151+
initial_amount is None
150152
or trading_symbol is None
151-
or market is None):
153+
or market is None
154+
):
152155
raise OperationalException(
153-
"No portfolio configurations found, please register a "
154-
"portfolio configuration before running a backtest."
156+
"No initial amount, trading symbol or market provided "
157+
"for the backtest and no portfolio configurations found. "
158+
"please register a portfolio configuration "
159+
"or specify the initial amount, trading symbol and "
160+
"market parameters before running a backtest."
155161
)
156162

157163
if portfolio_configurations is None \
@@ -238,10 +244,6 @@ def create_vector_backtest(
238244
signal[buy_signal] = 1
239245
signal[sell_signal] = -1
240246
signal = signal.replace(0, np.nan).ffill().shift(1).fillna(0)
241-
242-
# Portfolio value for this asset
243-
returns = close.pct_change().fillna(0)
244-
returns = returns.astype(float)
245247
signal = signal.astype(float)
246248

247249
if pos_size_obj is None:

0 commit comments

Comments
 (0)