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-ModelsI 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-ModelsBut it does not work either.
Any assistance would be appreciated, thanks in advance.
Shile Wen
Hi YunQi,
We are missing 1 positional argument, so it should be
self.AddForex("AUDUSD", Resolution.Minute, Market.Oanda, True, 200.0)
instead of
self.AddForex("AUDUSD",Resolution.Minute, Market.Oanda, 200.0)
Best,
Shile Wen
YUNQI ZUO
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!