GithubHelp home page GithubHelp logo

rebalancing-module's Introduction

Rebalancing Module

This module reads in an asset portfolio from a csv and prints out the required trades to rebalance the portfolio to a target allocation.

There are two algorithms included to rebalance: rebalance() and rebalanceRound(). Both functions return a list of trades to be executed that can then be applied to a portfolio in order to execute. The default method to use is rebalance() as it makes sure that assets never exceed the available capital. However, in cases of increased liquidity and circumstances where excess funds are available, rebalanceRound() will provide a slightly more accurate allocation as it applies a basic Math.round() rather than a Math.floor().

Excess Capital Allocation

In order to act on opportunities where excess cash is available after a floor rebalance is applied, rebalance() will look to increase the trades using the excess cash shouold it get the asset closer to it's target allocation.

Use

In order to use the module, adjust the data saved in portfolio.csv to reflect the target portfolio. Then open the module using any Java IDE (ie. Eclipse), build the project and run. After making any changes to the portfolio, re-run the module in order to view a new rebalancing strategy.

Trade-Offs

Due to the discrete nature of shares, rebalancing must be done in integers, however, this eliminates the possibility of a truly optimal rebalancing. This module attempts to mitigate the risk of this through excess cash allocation however it does not guarentee a truly optimal allocation.

In order to minimize the total distance from the target allocation, a non-linear integer optimization could be applied. In a production environment, however, this calculation would take too long to apply to many portfolios, possibly taking up to a minute per portfolio in order to be sure the allocation is close to optimal.

An Excel Solver model can be found in this repo that performs this optimization. Solver must be set to perform an integer optimization and it's best to reset the New Shares fields to 0 in order to eliminate bias from the non-linear solver. It would be possible to recreate the same model using quadratic programming, however, the decreased performance at scale would make it an ineffective method.

rebalancing-module's People

Contributors

connorgiles avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.