Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate daily ticker weights #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Calculate daily ticker weights #1

wants to merge 2 commits into from

Conversation

ronnyli
Copy link
Owner

@ronnyli ronnyli commented Mar 13, 2021

Technical / Common-sense Assessment

Please review this PR with as much detail as possible in the time given to you. You can be as harsh as you like; I didn't write it 😛

For the 2 most egregious problems that you detect, please provide a rough outline of how you would've done it instead. Pseudo-code is encouraged but not necessary.

To run this branch in a dev environment, please follow the instructions in the repo README.

The first commit adds in some administrative stuff so I would recommend only reviewing the commits after.


Context

A programmer named X Æ A-12 was tasked with the following:

Given a database of daily stock prices, a rebalancing frequency (in this example, weekly), and a target % portfolio allocation, calculate the actual daily % allocation of two stocks in a portfolio. This Investopedia article may be helpful for providing context.

From the article:

Mrs. Smith, who has a conservative approach to investing and is five years away from retirement, has a strategic asset allocation of 40% equities / 40% fixed income / 20% cash. Assume Mrs. Smith has a $500,000 portfolio and rebalances her portfolio annually. The dollar amounts allocated to the various asset classes at the time of setting the target allocations would be equities $200,000, fixed income $200,000, and cash $100,000.

In one year’s time, suppose the equity component of the portfolio has generated total returns of 10% while fixed income has returned 5% and cash 2%. The portfolio composition is now equities $220,000, fixed income $210,000, and cash $102,000.

The portfolio value is now $532,000, which means the overall return on the portfolio over the past year was 6.4%. The portfolio composition is now equities 41.3%, fixed income 39.5%, and cash 19.2%.

Based on the original allocations, the portfolio value of $532,000 should be allocated as follows: equities $212,800, fixed income $212,800, and cash $106,400. The table below shows the adjustments that must be made to each asset class to get back to the original or target allocations.

Screen Shot 2021-03-15 at 2 53 43 PM

The above example shows how to rebalance one year later back to your target allocation. What we want to do in this PR is also show all the intermediate allocations for every day between the rebalancing dates.

After some time X Æ A-12 asks you to review this PR that they've been working on...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant