Fixed exit costs being computed incorrectly and filter tests not working

This commit is contained in:
Javier Rodríguez Chatruc
2020-03-16 12:12:49 -03:00
parent e014840fb1
commit 98ea3dd12b
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -371,7 +371,7 @@ class Backtest:
self._options_inventory = self._options_inventory.append(entries, ignore_index=True)
self.trade_log = self.trade_log.append(entries, ignore_index=True)
self.current_cash += options_allocation - total_costs[0] * qty[0]
self.current_cash += options_allocation - np.sum(entries['totals']['cost'] * entries['totals']['qty'])
def _execute_option_exits(self, date, options):
"""Exits option positions according to `self._options_strategy`.
@@ -395,7 +395,7 @@ class Backtest:
filter_masks.append(flt(current_options_quotes[i]) | missing_contracts_mask)
fields = self._signal_fields((~leg.direction).value)
current_options_quotes[i] = current_options_quotes[i].reindex(columns=fields.keys())
current_options_quotes[i] = current_options_quotes[i].reindex(columns=fields.values())
current_options_quotes[i].rename(columns=fields, inplace=True)
current_options_quotes[i].columns = pd.MultiIndex.from_product([[leg.name],
current_options_quotes[i].columns])
+1 -1
View File
@@ -1,4 +1,4 @@
from backtester.datahandler import Field
from backtester.datahandler.schema import Field
def test_strike_eq_100():