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

Portfolio improvements #1818

Merged
merged 66 commits into from
May 19, 2022
Merged

Portfolio improvements #1818

merged 66 commits into from
May 19, 2022

Conversation

DidierRLopes
Copy link
Collaborator

@DidierRLopes DidierRLopes commented May 14, 2022

  • Improve portfolio controller UX
  • Shadow commands when these are unavailable
  • Allow custom reset when loaded portfolio and benchmark for faster development
  • bug when bench was loaded before portfolio, this fixes it
  • allow to see sum of portfolio holdings (stacked plot)
  • Add R-square command between portfolio returns and benchmark returns for all periods
  • Add overall stats command for portfolio and benchmark (mean, std, percentiles, count) for a specific period
  • Add kurtosis command for all periods
  • Add skewness command for all periods
  • Add period parameter to perf command
  • Add yearly returns to cumulative return plot
  • Add rolling volatility
  • Add rolling sharpe
  • Add rolling sortino
  • Add rolling beta
  • Allow to select period for cumulative returns vs EOY returns
  • Add volatility, sharpe ratio, sortino ratio and maximum drawdown ratio

@JerBouma just fails on missing docs. Waiting for your approval on this so I can add the docs if you are happy with it.


Additions since @JerBouma review:

  • remove sqrt(N) and N from sharpe and sortino calculations
  • allow hold to export raw data from tail
  • automatically add space before and after table
  • add portfolio holdings in percentage
  • fix relative periods to be more accurate
  • refactor metric command to allow to select a metric of interest and see multiple periods for it
  • fix cumulative return (in percentage)
  • implement new yearly return command
  • add daily returns graph
  • add distribution of daily returns command and stats for raw
  • add monthly returns command
  • add summary command with multiple metrics for a specific period
  • calculate yearly (out)performance

Since 2nd @JerBouma review:

  • fix show
  • beta with benchmark of 1
  • improve meet style

@DidierRLopes DidierRLopes added bug Fix bug feat XS Extra small feature labels May 14, 2022
@DidierRLopes DidierRLopes added feat M Medium T-Shirt size feature and removed feat XS Extra small feature labels May 15, 2022
@DidierRLopes DidierRLopes marked this pull request as ready for review May 15, 2022 22:46
@JerBouma
Copy link
Contributor

JerBouma commented May 16, 2022

Hey, looking good so far! You've been busy this weekend while i was sitting in the sun ;)

Some notes:

  • Could you transform the relevant numbers to percentages with 1 or 2 decimals? E.g. stats (since returns), vol, and possibly rsquare.
  • Could hold also give me a table (--raw) with the absolute values and % of the portfolio? I know alloc also does the percentages but I think it is useful to see this result in a table regardless.
  • return:
    • Could return command also provide me with a table that gives me returns for each year and benchmark and depict outperformance? This combined with the periods I mentioned. Here I do want to point out that I see a clear difference in cumulative returns and the method used within perf (and I would go with perf). The difference here is that the perf method makes an attempt to mimic the scenario that you bought the ETF (benchmark) instead of the asset at every order moment you bought and then determines if that would have led to outperformance. This also makes intuitive sense since I want to understand if I wasn't better off just buying the ETF.
    • I am unsure if the cumulative returns make sense if you are buying on a periodic basis. Why is the cumulative return negative for the portfolio? That makes very little sense looking at how much return you were able to achieve with those early day trades. E.g. look at the return perf gives you.
  • I think maxdd and the rolling graphs could all use a table with values.
  • rbeta only gives portfolio value but does it make sense we show the beta of 1 for benchmark as well? Just overall consistency and making the graph more clear (??). Optional.
  • I'd like stats to also include skewness and kurtosis. I think it makes little sense to have those as separate commands, they have little meaning to look at individually.

Regarding rbeta, see QuantStats:
image

@jmaslek
Copy link
Collaborator

jmaslek commented May 17, 2022

In the case bench isn't supplied, should we just use SPY as default:

2022 May 17, 18:47 (🦋) /portfolio/ $ yret --raw
Please first define the benchmark (via 'bench')

@DidierRLopes
Copy link
Collaborator Author

In the case bench isn't supplied, should we just use SPY as default:

2022 May 17, 18:47 (🦋) /portfolio/ $ yret --raw
Please first define the benchmark (via 'bench')

Good idea, let me add that

@JerBouma
Copy link
Contributor

JerBouma commented May 17, 2022

I disagree with adding a default benchmark. When you use bench you get countless of options already and setting a default benchmark makes little sense if your portfolio is composed of stocks that aren't even in the benchmark. What are you measuring then?

Also, I should go to bed. 🙃

@DidierRLopes
Copy link
Collaborator Author

I disagree with adding a default benchmark. When you use bench you get countless of options already and setting a default benchmark makes little sense if your portfolio is composed of stocks that aren't even in the benchmark. What are you measuring then?

Also, I should go to bed. 🙃

Gotcha, will leave as is then! Will start working on the docs - @jmaslek is helping debug returns

@DidierRLopes DidierRLopes merged commit 0e3b62e into main May 19, 2022
@DidierRLopes DidierRLopes deleted the portfolio branch May 30, 2022 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fix bug feat M Medium T-Shirt size feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants