Execute the following cell to "install" the strategy by moving the file to the /codeload/moonshot
directory:
# make directory if doesn't exist
!mkdir -p /codeload/moonshot
!mv qmom.py /codeload/moonshot/
Due to the large universe size, we use the segment
parameter to tell Moonshot to run the backtest in 1-year segments and concatenate the results.
We've added Jupyter's
%time
magic to provide a gauge of total runtime for this backtest.TIP: open the detailed logs while running the backtest to monitor moonshot's progress through the backtest segments.
from quantrocket.moonshot import backtest
%time backtest("qmom", start_date="2010-01-01", end_date="2018-01-01", segment="A", filepath_or_buffer="qmom_backtest.csv")
from moonchart import Tearsheet
Tearsheet.from_moonshot_csv("qmom_backtest.csv")
import pyfolio as pf
pf.from_moonshot_csv("qmom_backtest.csv")