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

Provide more advice on how to interpret outputs of portfolio_manager #2

Open
hatboysam opened this issue Sep 10, 2020 · 9 comments
Open

Comments

@hatboysam
Copy link

First of all thank you! This tool was so easy to get up and running, despite the obvious underlying complexity.

After running portfolio_manager.py on a few different stock lists I am left with the following simple questions:

  • How should I interpret "portfolio weights" to actually construct a portfolio? Does the tool assume a single weighted simultaneous purchase of all the symbols in the list and hold them indefinitely? Does it buy over time? It would be good if we could put in an amount for the initial principal and have the tool show the portfolio weights in terms of Day 0 dollar value.
  • The tool has 4 main output charts, what is the difference between "Future Test Results" and "Simulated Future Returns"? The README only explains the former, I am having trouble interpreting the latter. They seem to be wildly different!
@dashed
Copy link

dashed commented Sep 10, 2020

I'm also curious what negative weights mean for when only_long=1.

Some of the weights exceed 100%, which, I assume, the use of leverage/margin loans will make that a possibility.

@edoreld
Copy link

edoreld commented Sep 10, 2020

Some info about the negative weights:

"So the negative weights are just ignored during the forward and back tests. They are there just to show you the raw portfolios without any filtering." 1

@hatboysam
Copy link
Author

hatboysam commented Sep 10, 2020

From the link @edoreld posted:

So the negative weights are just ignored during the forward and back tests. They are there just to show you the raw portfolios without any filtering.
As for the other question, the weights are just proportions of your money that you should put in each stock. If a weight is negative, that means just short with that proportion. You can simply normalize the weights to sum up to one if it's harder to read them without them being normalized.

So reading that correctly let's say I put in 5 stocks and get the following weights:

A: 0.5
B: 1.0
C: -1.0
D: 2.0
E: 0.5

If I am long-only I can throw away C, it shouldn't be in my portfolio at all. So if I normalize the weights:

A: 0.125
B: 0.25
(no C)
D: 0.5
E: 0.125

So for a $1000 portfolio that would be:

A: $125
B: $250
D: $500
E: $125

I think an example like that would be really helpful in the README! Or better yet, add a --portfolio-principal flag to the command to turn everything into real dollars.

@tradytics
Copy link
Owner

Let me back to you folks with a detailed response. Thanks for asking.

@tradytics
Copy link
Owner

@hatboysam - this is a perfect example so thanks a lot for sharing.

So when is_long is set to 1, the weights are not constrained during optimization but during back and forward testing. When you build a long only portfolio, you can simple ignore the negative weights because that is what's happening during the testing.

As for an example, I think @hatboysam has a pretty good one, that's exactly how everything is working right now. I would let someone else add a PR though if there is any interest in adding an example in the readme?

@hatboysam
Copy link
Author

@tradytics happy to do a PR but I actually don't understand how weights would work if short positions are allowed. Let's use the above example again. Would all of the long positions stay the same and I'd just add a $250 short position to the portfolio? Or would the size of all positions change?

Also a follow up from my original question: does the algorithm assume rebalancing at any point or are these pure buy-and-hold portfolios?

@jmg17
Copy link

jmg17 commented Sep 12, 2020

First thank you. It's very interesting.

Same question as hatboysam about rebalancing : daily, monthly, never?

@edoreld
Copy link

edoreld commented Sep 13, 2020

For the author to confirm, but in my understanding:

  • If you allow short positions, then yes, you would short the stock with -1.0 weight with $250 as per your example.

  • I think rebalancing is up for you to do. If you want to rebalance monthly, then you would run the algorithm monthly and adjust your portfolio accordingly.

@silvavn
Copy link
Contributor

silvavn commented Sep 16, 2020

@hatboysam if you just want to use longs, you can discard negative values and the weights would be the same. Likewise if you just want to use shorts. If you want to use both, just sum up the positive then sum up the absolute of the negatives. the sum of positives plus the sum of abs negatives is the total weight. Divide each part by the total weight and you will get the money proportion for longs and shorts. Now you can easily find the money allocation by dividing each positive weight by the sum of positives and so on...

As @edoreld correctly mentioned, this algorithm does NOT consider re-balancing as of right now. You woud have to run it in shorter periods of time to find how to rebalance your portfolio.

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

No branches or pull requests

6 participants