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.

361

from qstrader import settings

from monthly_rebalance_run import run_monthly_rebalance

if __name__ == "__main__":

ticker_weights = {

"SPY": 0.6,

"AGG": 0.4,

}

run_monthly_rebalance(

settings.DEFAULT_CONFIG_FILENAME, False, "",

"SPY", ticker_weights, "US Equities/Bonds 60/40 Mix ETF Strategy",

datetime.datetime(2003, 9, 29), datetime.datetime(2016, 10, 12),

500000.00

)

The code for other portfolio compositions can be found in the "Full Code" section at the end

of the chapter, although they are very similar to the above snippet.

To run any of the backtests it is necessary to change directory to the location of the monthly_rebalance_run.py

file and then type the following into the console:

$ python equities_bonds_60_40_etf_portfolio_backtest.py

Remember to change the filename depending upon which backtest you wish to run.

25.5 Strategy Results

25.5.1 Transaction Costs

The strategy results presented here are given net of transaction costs. The costs are simulated

using Interactive Brokers US equities fixed pricing for shares in North America. They do not

take into account commission differences for ETFs, but they are reasonably representative of

what could be achieved in a real trading strategy.

25.5.2 US Equities/Bonds 60/40 ETF Portfolio

The strategy itself is carried out for SPY and AGG with historic data stretching back to 2003.

The tearsheet for the strategy is presented in Figure 25.1.

The benchmark is provided by a buy-and-hold portfolio (i.e. no monthly rebalancing) solely

of the SPY ETF.

The Sharpe Ratio of the benchmark and this portfolio are identical at 0.4. Hence a corresponding

cost is paid in maximum drawdown by only investing in SPY. The CAGR of the

strategy is 4.43%, lower than the 5.92% of SPY, due to transaction costs of carrying out the

rebalancing as well as the underperformance of AGG with respect to SPY.

AGG did somewhat cushion the vast drawdown of 2008 for the portfolio but the recent underperformance

of AGG over the last five years drags the results of the portfolio down significantly.

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

Saved successfully!

Ooh no, something went wrong!