From 06e155060942d0b72ed47440c56215edac019557 Mon Sep 17 00:00:00 2001 From: Joel Brass Date: Tue, 3 Feb 2026 20:04:33 -0800 Subject: [PATCH] Update bars.py I am getting index errors using the get_last_price function. Adding iloc to make it more robust. --- lumibot/entities/bars.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lumibot/entities/bars.py b/lumibot/entities/bars.py index 14a29ec68..08876fc3e 100644 --- a/lumibot/entities/bars.py +++ b/lumibot/entities/bars.py @@ -555,7 +555,7 @@ def get_last_price(self) -> Union[float, Decimal, None]: float, Decimal or None """ - return self.df["close"][-1] + return self.df["close"].iloc[-1] def get_last_dividend(self): """Return the last dividend of the last bar @@ -569,7 +569,7 @@ def get_last_dividend(self): float """ if "dividend" in self.df.columns: - return self.df["dividend"][-1] + return self.df["dividend"].iloc[-1] else: logger.debug("Unable to find 'dividend' column in bars") return 0