![]() ![]() I think this will do what you want: df = df.groupby('portfolio'). I am using this data from yfinance: import yfnance as yfĭf = yf.download('aapl', start='')]Ĭalculate the cumulative returns, rolling max peaks and the drawdown from the trailing peak as: df = (1+ df).cumprod() # cumulative returnĭf = df.cummax() # cumulative peaksĭf = (df - df) / df # drawdown from trailing peakĮDIT: just noticed you have 2 portfolio returns that you are dealing with, so this hasn't really answered your question. ![]() Thanks a million for the help in advance. As for the actual product, the Maglock Hyperswitch, its absolutely garbage. The drawdown figures for the above inputs are below in the desired format: portfolio period performance Drawdown The desired output isan array that is the difference between the portfolio's previous maximum value and the portfolio's current value. The input data is in the format below portfolio period performance def drawdown_2(arr):ĭf = df.groupby(df.portfolio).expanding().apply(drawdown_2) I'd really appreciate if anyone could let me know where I am going wrong. The Patriot pin and hyper switch can take full advantage of the auto mag release. expanding() function but can't seem to get the desired output. The AR Maglock Gen 1 is a fixed magazine lock for CA Compliant rifles. I'm trying to calculate the drawdown of a portfolio over time of a portfolio using the code below. If you would like a higher performance kit that allows faster magazine changes, please upgrade your Gen 1 kit with a Hyperswitch and BRS, or consider purchasing our Gen 2, Gen 3 or Gen 4 kits with KingPin (for Gen 2 and Gen 4) or our Hyperswitch (for use with the Gen 1 and Gen 3 locking kits).
0 Comments
Leave a Reply. |