Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Negative leverage

I thought leverage is always positive, but there is a backtest result with a negative value.
And should't turnover and position concentration also be positive? They are negative, too.
How can this happen?

One thought crossed my mind:
There is no screen to filter the universe, perhaps some futures or such got traded and messed it all up?

2 responses

Some more details:
On July 3rd there is a huge drawdown from + 99 % to -658 %. Afterwards it looks like everything has flipped to the opposite direction. Until this date the returns went straight up, then even straighter downwards (in one test to -58736 %).
Tests that either end before or start after that date are performing very well - maybe a bit too well to be realistic - and have no negative leverage, turnover or position concentration.
How can I find out what went wrong on that day and how to prevent it?

I think I found out what happened:
The algo was heavy on the short side in this period and the price of some assets it was shorting skyrocketed.
This lead to such a big drawdown that the portfolio value became negative.
Presuming that leverage and position concentration are calculated using context.portfolio.portfolio_value, this would explain why they also became negative.