13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

410

’--testing/--no-testing’, default=False,

help=’Enable testing mode’

)

@click.option(’--tickers’, default=’SP500TR’, help=’Tickers (use comma)’)

@click.option(

’--filename’, default=’’,

help=’Pickle (.pkl) statistics filename’

)

def main(config, testing, tickers, filename):

tickers = tickers.split(",")

config = settings.from_file(config, testing)

run(config, testing, tickers, filename)

if __name__ == "__main__":

main()

As long as QSTrader is correctly installed and the data has been downloaded from Yahoo

Finance the code can be executed via the following command in the terminal:

$ python kalman_qstrader_backtest.py --tickers=TLT,IEI

Thanks to the efforts of many volunteer developers, particularly @ryankennedyio, @femtotrader

and @nwillemse, the code is well-optimised for OHLCV bar data and carries out the

backtesting rapidly.

28.3 Strategy Results

The equity curve is presented in Figure 28.1. It begins relatively flat for the first year of the

strategy but rapidly escalates during the latter half of 2010 and 2011. During 2012 the strategy

becomes significantly more volatile remaining "underwater" until 2015 and reaching a maximum

daily drawdown percentage of 17.46%. The performance gradually increases from the maximum

drawdown in late 2013 through to 2016.

The strategy has a CAGR of 7.66% with a Sharpe Ratio of 0.65. It also has a long maximum

drawdown duration of 817 days–well over two years! Note that this strategy is carried out net

of transaction costs so is reasonably reflective of real-world performance, under the assumption

of achieving closing prices of assets.

28.4 Next Steps

There is a lot of research work necessary to turn this into a profitable strategy that we would

deploy in a live setting. Potential avenues of research include:

• Parameter Optimisation - Varying the parameters of the Kalman Filter via crossvalidation

grid search or some form of machine learning optimisation. However, this introduces

the distinct possibility of overfitting to historical data.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!