From 0569f34e1f95c0c042eff4fee5b523058947a5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Rodr=C3=ADguez=20Chatruc?= Date: Fri, 20 Mar 2020 11:53:14 -0300 Subject: [PATCH] Balance now has stock qty disaggregated by symbol --- backtester/backtester.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backtester/backtester.py b/backtester/backtester.py index dd39223..96ed9de 100644 --- a/backtester/backtester.py +++ b/backtester/backtester.py @@ -304,6 +304,10 @@ class Backtest: add['puts capital'] = puts_value add['stocks qty'] = self._stocks_inventory['qty'].sum() + for _index, row in self._stocks_inventory.iterrows(): + symbol = row['symbol'] + add[symbol + ' qty'] = row['qty'] + # sort=False means we're assuming the updates are done in chronological order, i.e, # the dates in add are the immediate successors to the ones at the end of self.balance. # Pass sort=True to ensure self.balance is always sorted chronologically if needed.