Hi all,

Can someone enlighten me on how to set up a custom leverage ratio for backtesting  ? for forex trading specifically

This is the currently one that I use:

self.SetBrokerageModel(BrokerageName.OandaBrokerage)

however my leverage ratio at Oanda is actually 200 however when I implemented my algo, the default leverage ratio seems to be less than 100. For example, it triggers a margin call when placing 10,000 AUD.USD order with 100 AUD remaining cash with following error:

Backtest Handled Error: Order Error: id: 8653, Insufficient buying power to complete order (Value:7432.7), Reason: Id: 8653, Initial Margin: 148.654, Free Margin: 100
Order Error: id: 8654, Insufficient buying power to complete order (Value:7424), Reason: Id: 8654, Initial Margin: 148.654, Free Margin: 100

I have referred to the following docs but failed to locate the answer:

https://www.quantconnect.com/docs/algorithm-reference/reality-modelling#Reality-Modelling-Portfolio-Models

I have added the following:

self.AddForex("AUDUSD",Resolution.Minute, Market.Oanda, 200.0)

based on the docs below:

https://www.quantconnect.com/docs/algorithm-reference/initializing-algorithms#Initializing-Algorithms-Cash-and-Brokerage-Models

But it does not work either.

Any assistance would be appreciated, thanks in advance.

Author