From 1de34ffaa3d49c50d88d04b34992a218739059f8 Mon Sep 17 00:00:00 2001 From: Robert Grzesik Date: Fri, 1 Dec 2023 04:54:15 -0500 Subject: [PATCH] fixed test --- tests/backtest/test_example_strategies.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/backtest/test_example_strategies.py b/tests/backtest/test_example_strategies.py index 6f8ee1628..83373b941 100644 --- a/tests/backtest/test_example_strategies.py +++ b/tests/backtest/test_example_strategies.py @@ -208,8 +208,8 @@ def test_options_hold_to_expiry(self): returned along with the correct results. """ # Parameters - backtesting_start = datetime.datetime(2023, 10, 19) - backtesting_end = datetime.datetime(2023, 10, 24) + backtesting_start = datetime.datetime(2023, 10, 16) + backtesting_end = datetime.datetime(2023, 10, 21) # Execute Backtest results, strat_obj = OptionsHoldToExpiry.run_backtest( @@ -224,9 +224,12 @@ def test_options_hold_to_expiry(self): polygon_has_paid_subscription=True, ) - # Check that the results are correct - assert round(results["cagr"] * 100, 1) == 75 - assert round(results["volatility"] * 100, 1) == 11.3 - assert round(results["total_return"] * 100, 1) == 0.9 - assert round(results["max_drawdown"]["drawdown"] * 100, 1) == 0.7 + trades_df = strat_obj.broker._trade_event_log_df + assert not trades_df.empty + # Get all the cash settled orders + cash_settled_orders = trades_df[(trades_df["status"] == "cash_settled") & (trades_df["type"] == "cash_settled")] + + # The first limit order should have filled at $399.71 and a quantity of 100 + assert round(cash_settled_orders.iloc[0]["price"], 0) == 0 + assert cash_settled_orders.iloc[0]["filled_quantity"] == 10