File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1343,6 +1343,11 @@ def run(self, **kwargs) -> pd.Series:
1343
1343
# strategy iteration. Use the same OHLC values as in the last broker iteration.
1344
1344
if start < len (self ._data ):
1345
1345
try_ (broker .next , exception = _OutOfMoneyError )
1346
+ elif len (broker .trades ):
1347
+ warnings .warn (
1348
+ 'Some trades remain open at the end of backtest. Use '
1349
+ '`Backtest(..., finalize_trades=True)` to close them and '
1350
+ 'include them in stats.' , stacklevel = 2 )
1346
1351
1347
1352
# Set data back to full length
1348
1353
# for future `indicator._opts['data'].index` calls to work
Original file line number Diff line number Diff line change @@ -433,7 +433,8 @@ def next(self):
433
433
elif len (self .data ) == len (SHORT_DATA ):
434
434
self .position .close ()
435
435
436
- self .assertTrue (Backtest (SHORT_DATA , S , finalize_trades = False ).run ()._trades .empty )
436
+ with self .assertWarnsRegex (UserWarning , 'finalize_trades' ):
437
+ self .assertTrue (Backtest (SHORT_DATA , S , finalize_trades = False ).run ()._trades .empty )
437
438
self .assertFalse (Backtest (SHORT_DATA , S , finalize_trades = True ).run ()._trades .empty )
438
439
439
440
def test_check_adjusted_price_when_placing_order (self ):
You can’t perform that action at this time.
0 commit comments