Git Product home page Git Product logo

portfolio-rebalance's Introduction

Portfolio-Rebalance

Small script for rebalancing an investment portfolio by allocating funds to realize specified targets


Example Usage


Rebalance the portfolio summarized by example_funds.csv by adding $1000:

>> python3 rebalance.py example_portfolio.csv 1000
Current allocation vs Targets...
             Current_Allocation  Target_Allocation  Difference
Fund                                                          
InvestmentA               45.45               50.0       -4.55
InvestmentB               18.18               20.0       -1.82
InvestmentC               36.36               30.0        6.36

Dollars to add to reach target allocation...
             Dollars_to_Add  Allocation  Target_Allocation  Difference
Fund                                                                  
InvestmentA           525.0        52.5               50.0         2.5
InvestmentB           210.0        21.0               20.0         1.0
InvestmentC           265.0        26.5               30.0        -3.5

If the dollar amount to be added is not enough for an additive (positive) contribution to each fund, no contribution is possible:

>> python3 rebalance.py example_portfolio.csv 100
Must add more money for strictly additive rebalance

Negative contributions can be computed by passing the --allow_negative flag:

>> python3 rebalance.py --allow_negative example_portfolio.csv 100
Current allocation vs Targets...
             Current_Allocation  Target_Allocation  Difference
Fund                                                          
InvestmentA               45.45               50.0       -4.55
InvestmentB               18.18               20.0       -1.82
InvestmentC               36.36               30.0        6.36

Dollars to add to reach target allocation...
             Dollars_to_Add  Allocation  Target_Allocation  Difference
Fund                                                                  
InvestmentA            75.0        75.0               50.0        25.0
InvestmentB            30.0        30.0               20.0        10.0
InvestmentC            -5.0        -5.0               30.0       -35.0

portfolio-rebalance's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.