Skip to content

Commit ecc652b

Browse files
committed
🐛: Don't handle constant params
1 parent cc7df06 commit ecc652b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

backtesting/backtesting.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,13 +1562,9 @@ def _optimize_openbox() -> Union[pd.Series,
15621562
# TODO: save dtype and convert back later
15631563
values = values.astype(int)
15641564

1565-
if len(values) == 1:
1566-
variables.append(sp.Constant(value=float(values[0]), name=key))
1567-
elif values.dtype.kind in 'iumM':
1565+
if values.dtype.kind in 'iumM':
15681566
variables.append(sp.Int(lower=values.min(), upper=values.max(), name=key))
1569-
elif values.dtype.kind == 'f':
1570-
variables.append(sp.Real(lower=values.min(), upper=values.max(), name=key))
1571-
elif values.dtype.kind == 'O' and all([isinstance(v, Decimal) for v in values]):
1567+
elif values.dtype.kind == 'f' or (values.dtype.kind == 'O' and all([isinstance(v, Decimal) for v in values])):
15721568
variables.append(sp.Real(lower=values.min(), upper=values.max(), name=key))
15731569
else:
15741570
variables.append(sp.Categorical(choices=values.tolist(), name=key))

0 commit comments

Comments
 (0)