VaR icon indicating copy to clipboard operation
VaR copied to clipboard

VaR for Long/Short Portfolios

Open julius-datajunkie opened this issue 2 years ago • 1 comments

Weight supplied that adds to 0 will yield error due to

self.pnl = pd.DataFrame(np.average(self.returns, 1, self.weights),
                        index=self.returns.index,
                        columns=["Daily PnL"])

A workaround that I have used is to change the above to:

self.pnl = pd.DataFrame((self.returns * self.weights).sum(axis=1),
                        index=self.returns.index,
                        columns=["Daily PnL"])

The above change will make the PnL into a long short excess return for the portfolio. However, the backtest() function doesn't yield correct graph though.

julius-datajunkie avatar Nov 03 '23 09:11 julius-datajunkie

That is a very good point! Thank you very much. I will try to implement and include short positions!

ibaris avatar Nov 04 '23 11:11 ibaris