Skip to content

VaR for Long/Short Portfolios #11

Description

@julius-datajunkie

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions