Problem with Leverage and Margin
I have a couple of questions regarding leverage and margin. I am looking mainly at futures and options as an asset class and would like to implement the same leverage/margin principles that is applied to futures.
As an example, on EURUSD CME futures, the initial margin for speculator is 2310 USD and the contract size is for 125.000 EUR.
In backtrader, with no leverage, if I set broker.setcash(100.000), I would not be able to buy a single futures due to the contract size, since the buy of 1 contract would be greater than the size of the cash account. In reality, one would have only to post 2310 USD per contract when buying a single futures (and in with a cash size of 100k, I should be able to buy roughly 43 futures for a total notional value of 5.375mio USD)
I have tried to play with leverage in broker.setcommission(leverage) that was added recently, and using sizers.FixedSizer(10), but my orders are being rejected even if I set broker.setcommission(leverage=50.0), i.e. being levered 50x times which is equivalent to allowing me to trade up to 5mio USD.
Surely I am missing something on how actually implement the leverage component. Could anyone clarify (perhaps with a snippet code) on how to properly implement a leverage factor?
Many thanks in advance guys!
Set futures type commission scheme and backtrader will treat future contracts correctly.
That's it! Thanks very much sir!