VMOT single-strategy Backtest

Next, we run a single-strategy variant of VMOT, which applies the momentum screen to the results of the value screen, and which sells the value/momentum portfolio during downturns rather than hedging with a short position.

Strategy code

The file vmot_combined.py contains the strategy code. Starting with the qval code, we've added the relevant sections of qmom code and vmot-trend code. The value and momentum portfolio is constructed in prices_to_signals. Then, in signals_to_target_weights, we query the spy-1d database to compute and apply our trend filters.

From the standpoint of code organization, it's recommended to first create simpler, single-factor strategies (like qval, qmom, and vmot-trend), then combine them into composite strategies as desired by copying and modifying code from the simpler variants.

Install strategy file

Execute the following cell to "install" the strategy by moving the file to the /codeload/moonshot directory:

In [1]:
# make directory if doesn't exist
!mkdir -p /codeload/moonshot

!mv vmot_combined.py /codeload/moonshot/

Run backtest

Now run the backtest:

In [2]:
from quantrocket.moonshot import backtest
backtest("vmot",
         start_date="1999-01-01", 
         end_date="2010-01-01", 
         segment="A",
         filepath_or_buffer="vmot_combined_backtest_results.csv")
In [3]:
from moonchart import Tearsheet
Tearsheet.from_moonshot_csv("vmot_combined_backtest_results.csv")