Skip to content

Commit 9a15617

Browse files
committed
Use faster Data._current_value in a few more places
1 parent f88baff commit 9a15617

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

backtesting/backtesting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def unrealized_pl(self) -> float:
838838
@property
839839
def last_price(self) -> float:
840840
""" Price at the last (current) close. """
841-
return self._data.Close[-1]
841+
return self._data._current_value('Close')
842842

843843
def _adjusted_price(self, size=None, price=None) -> float:
844844
"""
@@ -869,7 +869,7 @@ def next(self):
869869
if equity <= 0:
870870
assert self.margin_available <= 0
871871
for trade in self.trades:
872-
self._close_trade(trade, self._data.Close[-1], i)
872+
self._close_trade(trade, self.last_price, i)
873873
self._cash = 0
874874
self._equity[i:] = 0
875875
raise _OutOfMoneyError

0 commit comments

Comments
 (0)