From de0fed75cde2f8f5c9b15f446e50ca7eae567037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Rodr=C3=ADguez=20Chatruc?= Date: Fri, 20 Mar 2020 15:04:58 -0300 Subject: [PATCH] Modified test_backtest to keep only the balance columns used for the test --- backtester/test/backtester/test_backtester.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backtester/test/backtester/test_backtester.py b/backtester/test/backtester/test_backtester.py index 1aaacbf..fe91edf 100644 --- a/backtester/test/backtester/test_backtester.py +++ b/backtester/test/backtester/test_backtester.py @@ -13,7 +13,14 @@ def test_backtest(sample_stock_portfolio, sample_stocks_datahandler, sample_opti stocks=sample_stock_portfolio) tl_long, balance_long = bt.trade_log, bt.balance - last_day_balance_long = balance_long.iloc[-1].values + symbols = [stock.symbol for stock in sample_stock_portfolio] + balance_columns = ['total capital', 'cash'] + symbols + [ + 'options qty', 'calls capital', 'puts capital', 'stocks qty', 'options capital', 'stocks capital', '% change', + 'accumulated return' + ] + + last_day_balance_long = balance_long.iloc[-1] + last_day_balance_long = last_day_balance_long[balance_columns].values leg_1_costs = tl_long['leg_1']['cost'] leg_2_costs = tl_long['leg_2']['cost'] @@ -40,7 +47,8 @@ def test_backtest(sample_stock_portfolio, sample_stocks_datahandler, sample_opti stocks=sample_stock_portfolio) tl_short, balance_short = bt.trade_log, bt.balance - last_day_balance_short = balance_short.iloc[-1].values + last_day_balance_short = balance_short.iloc[-1] + last_day_balance_short = last_day_balance_short[balance_columns].values leg_1_costs = tl_short['leg_1']['cost'] leg_2_costs = tl_short['leg_2']['cost']