The Capital
Published in

The Capital

An Optimised Portfolio with Re-balancing Strategy using Straits Times Index (STI) Stocks

A simple strategy to manage a portfolio

Photo by Stephen Dawson on Unsplash

Blue-chip stocks usually form part of a value investor’s portfolio. Here, I explore the construction of a portfolio that should theoretically provide good returns with relatively low risks.

Disclaimer: This does not constitute investment advice nor do I endorse the use of any related code here to make investment decisions. These are purely exploratory — you can use them at your own risk.

Assumptions

The below strategy is a quantitative one. The major assumption here is that historical prices have some predictive power over future prices and market inefficiencies exist. Other assumptions arise as part of Markowitz’s portfolio theory.

Portfolio strategy

The strategy here is to construct the portfolio with the highest Sharpe ratio with the following rules:

  • Sharpe ratio is computed over a 110 trading day moving window time series*
  • Re-balancing is conducted every 20 trading days and portfolio weights will remain constant until the next re-balancing*
  • Portfolio weights have values [0, 1] (so no short positions are allowed)

*On the day of re-balancing, the Sharpe ratio is determined based on the adjusted close prices of the past 110 trading days

I will be looking at the period 1 Jan 2015 to 1 Jan 2020** using the STI constituents:

sectorToStockMap = {
'Industrials': ['J37.SI', 'J36.SI', 'U96.SI', 'S58.SI', 'C6L.SI', 'S63.SI', 'BS6.SI', 'C52.SI', 'BN4.SI'],
'Consumer Staples': ['D01.SI', 'F34.SI'], #'Y92.SI'***
'Real Estate': ['A17U.SI', 'N2IU.SI', 'H78.SI', 'M44U.SI', 'C09.SI','U14.SI', 'C31.SI', 'C38U.SI', 'C61U.SI', 'ME8U.SI'],
'Consumer Discretionary': ['G13.SI', 'C07.SI'],
'Financials': ['D05.SI', 'O39.SI', 'U11.SI', 'S68.SI'],
'Communication': ['Z74.SI'],
'Technology': ['V03.SI']
}

**Due to the size of the moving window, while the date range of the data starts from 1 Jan 2020, the simulation begins only after the 110th trading day

***ThaiBev was removed as it was giving some wonky results

Implementation

The simulation is done using Python and computations are done using the PyPortfolioOpt library.

Just some notes:

  • As with many multivariate optimisation problems, it is possible that there is no convergence for certain sets of inputs (i.e. window size, securities)
  • Some of the variables chosen (such as window size) are arbitrary — I just happen to be able to obtain a convergence for these combinations of inputs
  • If the PyPortfolioOpt library fails to install (can’t remember the error), it might be because you’re missing some C++ packages, which can be installed via Microsoft Visual Studio

A copy of my code can be found at Github. The codes are in the form of a Jupyter notebook with the data you see here. The scripts accept any securities as long as it can be found using pandas_datareader. In addition, I wrote a more compact version of the script as a PortfolioRebalancer class for iteration studies. Feel free to use and play around with them and feedback is appreciated :)

Performance

The optimal portfolio ranked 8th in terms of market value at the end of the simulation period. Not the strongest but a good result for a simple algorithm.

Symbols
ME8U.SI 215783.222721
V03.SI 205689.492342
N2IU.SI 198987.562674
M44U.SI 193507.683165
S58.SI 162666.178816
A17U.SI 158377.576331
C61U.SI 158111.554278
Portfolio 146842.727974
C38U.SI 140745.013941
D05.SI 135706.107300
S63.SI 128184.005947
F34.SI 125016.077070
S68.SI 125009.847898
U11.SI 122386.550608
O39.SI 120540.977213
U14.SI 117082.250094
C31.SI 116749.623977
C09.SI 103683.511262
Z74.SI 98148.257365
G13.SI 96611.034280
J36.SI 94218.094332
C6L.SI 92036.314938
J37.SI 89875.262253
C07.SI 82052.260724
BN4.SI 81422.706953
C52.SI 81073.073232
H78.SI 71673.478714
D01.SI 70636.736051
BS6.SI 64924.041589
U96.SI 54028.529669
Name: 2019-12-31 00:00:00, dtype: float64

With a starting capital of $100,000, the below chart shows me the value of my portfolio if I were to invest all my money in a single stock portfolio (as well as the portfolio constructed above).

Honestly, the image is just for visualisation purposes — it can be very difficult to tell which lines belong to which stocks since there are duplicate colours. The point being made here is that there seems to be an even spread of portfolios doing well and poorly.

Market value of all single-stock portfolios and the optimal portfolio

For clarity, the below shows the value of the optimal portfolio. It can be seen that its profile in 2018 mimics that of the best performing stock (Venture Corporation) but unfortunately, it also mimics the profile of the same stock as its value drops. Yet in 2019, due to portfolio re-balancing, it can be seen that the profile deviates away from Venture’s and slowly regains its former value (while the single stock portfolio of Venture does not).

Market value of the optimal portfolio

Some digression here…

I decided to do some data exploration to find out if there is some form of seasonality in the portfolio constituents. I had hoped to use this as an indicator that reflects the performance of various sectors in Singapore and construct a sector rotation strategy. However, take note that certain sectors (eg. technology and communications) have only 1 stock in the STI and therefore cannot serve as a proxy for the sector’s performance. Nonetheless, here is a (slightly difficult to view) visualisation of the sector weightage as defined in sectorToStockMap above.

Sector allocation as inferred from weights of the optimal portfolio

With re-balancing vs. without re-balancing

It is recognised that certain stocks outperform at certain periods and underperform at certain periods. Portfolio re-balancing can help investors to switch from underperforming stocks to others that could (based on computations) potentially perform better.

In this simulation, the optimal portfolio with re-balancing performed better than the optimal portfolio without re-balancing. With a starting capital of $100,000, the difference in portfolio value at the end of 4 years is approximately $30,000.

Comparing the optimal portfolio with and without re-balancing

Weaknesses of the model

  • Transaction costs are not factored in — These costs can rise and fall depending on the portfolio re-balancing frequency and to a lesser extent, the type of brokers used
  • Moving window size is arbitrary — There was no iterative test to determine the optimal window size
  • No requirements on the number of securities in the portfolio — The computation picks the combination with the highest Sharpe ratio and in certain cases, that combination could have just 2–3 stocks forming a largely undiversified portfolio

Ideas for further improvements

  • Adaptive window size to increase sensitivity to steeper price movements
  • Adaptive re-balancing intervals or ad-hoc re-balancing to alter portfolio weights when a large drawdown is impending

Key takeaways from this simulation

  • The portfolio with the highest Sharpe ratio does not necessarily yield the highest returns
  • The dynamic behaviour of financial markets suggests that a static strategy may not adapt sufficiently well

If you noticed, this simulation was done for the pre-COVID-19 period. Subsequent explorations will relate to adapting this strategy to handle changes in market climate and (hopefully) mitigating drawdowns.

--

--

--

A publishing platform for professionals in business, finance, and tech

Recommended from Medium

A detailed look at JuiceBox’s largest DAO — AssangeDAO

Huobi Research Weekly (Vol.187) (2021.10.18–2021.10.24)

Quick Steps to Bridge ERC-20 $DAFI to Binance Smart Chain

HOW TO BUY LYNXCAT TOKEN

Oraichain Mainnet Upgrade (v0.40.3): ORAIDEX Ready For IBC Integration

Bitcoin/USD — June update

BUXZOR COIN NETWORK DIVERSIFYING THE BLOCHAIN FINANCIAL SYSTEM

The Economics of VC Exits In The ICOs Era

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nigel

Nigel

Singaporean. A self-taught programmer who started off as a software engineer and is now pursuing a career as a quant. Always learning.

More from Medium

Predicting Bitcoin using Google Trends.

Technical Analysis Explained

Examining the Drawdown Risk of Sector ETFs —  2022

Commodity Report #40