-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix portfolio metrics #2116
Fix portfolio metrics #2116
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meaning of these results are confusing when you have no losing trades (e.g. a typical long-only portfolio). I'd suggest to notify the user that there is no losing trade (or gross loss) and that this calculations therefore will not be accurate. E.g. you can quite easily check if any return < 0
.
2022 Jul 25, 05:59 (🦋) /portfolio/ $ metric profitfactor
Portfolio's profit factor
┏━━━━━┳━━━━━━━━━━━━━━━┓
┃ ┃ Profit Factor ┃
┡━━━━━╇━━━━━━━━━━━━━━━┩
│ mtd │ nan │
├─────┼───────────────┤
│ qtd │ nan │
├─────┼───────────────┤
│ ytd │ 0.064 │
├─────┼───────────────┤
│ 3m │ inf │
├─────┼───────────────┤
│ 6m │ 0.064 │
├─────┼───────────────┤
│ 1y │ 0.041 │
├─────┼───────────────┤
│ 3y │ 0.167 │
├─────┼───────────────┤
│ 5y │ 0.444 │
├─────┼───────────────┤
│ 10y │ 2.284 │
├─────┼───────────────┤
│ all │ 3.085 │
└─────┴───────────────┘
2022 Jul 25, 05:59 (🦋) /portfolio/ $ metric payoff
Portfolio's payoff ratio
┏━━━━━┳━━━━━━━━━━━━━━┓
┃ ┃ Payoff Ratio ┃
┡━━━━━╇━━━━━━━━━━━━━━┩
│ mtd │ 0.000 │
├─────┼──────────────┤
│ qtd │ 0.000 │
├─────┼──────────────┤
│ ytd │ 0.191 │
├─────┼──────────────┤
│ 3m │ nan │
├─────┼──────────────┤
│ 6m │ 0.191 │
├─────┼──────────────┤
│ 1y │ 0.162 │
├─────┼──────────────┤
│ 3y │ 0.143 │
├─────┼──────────────┤
│ 5y │ 0.311 │
├─────┼──────────────┤
│ 10y │ 0.731 │
├─────┼──────────────┤
│ all │ 0.796 │
└─────┴──────────────┘
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The information ratio doesn't seem to work.
2022 Jul 25, 06:03 (🦋) /portfolio/ $ load Public_Equity_Orderbook.xlsx
Preprocessing orderbook: ..........
Loading price data: .
Calculating returns: .
Portfolio: Public_Equity_Orderbook.xlsx
Risk Free Rate: 0
2022 Jul 25, 06:04 (🦋) /portfolio/ $ bench SPDR S&P 500 ETF Trust (SPY)
Benchmark: SPDR S&P 500 ETF Trust (SPY) (SPY)
2022 Jul 25, 06:04 (🦋) /portfolio/ $ metric information
Error: not enough values to unpack (expected 2, got 1)
Error: not enough values to unpack (expected 2, got 0)
2022 Jul 25, 06:04 (🦋) /portfolio/ $
If you fix linting, I am happy to approve :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go!
Description
Fixing the portfolio metrics calculations and fixing the metrics after the refactor.
How has this been tested?
Running the commands in jupyter notebook and the terminal
Checklist:
Others
pre-commit install
.pytest tests/...
.