Module - Portfolio Construction Model With Custom Optimizer (free)

Module - Portfolio Construction Model With Custom Optimizer (free)


Here's a FREE MODULE for you, simply hit the CLONE ALGORITHM button below!

The Portfolio Construction Model calculates the desired targets for each asset in our portfolio. This is a custom implementation of the model that will allow you to use different optimization techniques for your portfolio (maximize portfolio return, minimize portfolio volatility, maximize portfolio sharpe ratio, etc.).

Once the predictions are sent to the Portfolio Construction Model, it will get the daily log-returns of the last 252 trading days and calculate the weights for each individual security that optimize the provided objective function. The model will also plot the optimal allocation for each asset so we can inspect what it's doing.

The below algorithm is a simple example to show how it works with a buy and hold strategy, but this module can be plugged into any other strategy requiring portfolio target calculations.

Ideas to try (user-defined inputs in the main.py script):

  • Change the objectiveFunction parameter to test other objective functions to optimize. Options are: 'return' (maximize portfolio return), 'std' (minimize portfolio standard deviation), 'sharpe' (maximize portfolio sharpe ratio), and also 'equal' (for a standard equal weighting).
  • The rebalancingParam is currently set to 365 days, but it can be set to a discretionary number of days to rebalance the portfolio and go back to optimal weights. For instance, if you want to rebalance every 30 days simply do rebalancingParam = 30
Do you have a strategy of your own that you would like to backtest and automate? Learn about our consulting services and get in touch at admin@innoquantivity.com

Found this product useful? You can support this site by making a donation using the link below!