Back to Community
Is it possible to add leverage for back testing?

I would like to test performance of the strategy if leverage is allowed. Is it possible to do that?

Also it would be nice to have possibility to see performance of the strategy if short-selling is allowed. The same question: is it possible?

5 responses

Yes both of these are possible, there are no inherent limits on leverage in the code. You will have to track your own leverage but could make it 1000x leveraged if you so desired.

Its not that hard to do yourself. The harder part is just coming up with a margin rate that is realistic. That data is hard to come by IMHO.

Do I need to change context.account.leverage in the initialize part? Or how it should be done?

you can use a number greater than 1 in your order_target_percent
ie 1.3 to use 30% lev.

I have related question, in my algo I always have in my order_target_percent 1 or less but still the context.account.leverage shows leverage between 1 and 4 depened on the trading days, how can it be ?
1. how can I detect where is the issue ?
2. How can I tell quantopain to disallow any kind of leverage