eiten icon indicating copy to clipboard operation
eiten copied to clipboard

Provide more advice on how to interpret outputs of portfolio_manager

Open hatboysam opened this issue 4 years ago • 9 comments

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!

hatboysam avatar Sep 10 '20 10:09 hatboysam

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.

dashed avatar Sep 10 '20 10:09 dashed

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

edoreld avatar Sep 10 '20 12:09 edoreld

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.

hatboysam avatar Sep 10 '20 13:09 hatboysam

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

tradytics avatar Sep 10 '20 16:09 tradytics

@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?

tradytics avatar Sep 12 '20 02:09 tradytics

@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?

hatboysam avatar Sep 12 '20 10:09 hatboysam

First thank you. It's very interesting.

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

jmg17 avatar Sep 12 '20 17:09 jmg17

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.

edoreld avatar Sep 13 '20 06:09 edoreld

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

silvavn avatar Sep 16 '20 21:09 silvavn