Back

Margin Orders with Oanda fail if I have open positions

I have an account with Oanda with a Margin Available of 646 and margin used of 400. I have two open positions in EURUSD and USDJPY. When I try to run my live algorithm, I get the following error:

Selling Power for crypto GBPUSD = -4479.3158132487667371388301621
New Order Event: Time: 1/10/2018 6:21:00 PM OrderID: 10 Symbol: GBPUSD Status:
Invalid Message: Insufficient buying power to complete order
Order Error: id: 10, Insufficient buying power to complete order
(Value:-270.389).

I don't have any open positions in GBPUSD, yet it shows that my selling power is negative. -4479 is actually my (cash balance - open positions). Does that mean there is no way to place an order if I have open positions utilizing margin? I can go to the Oanda website and place the same order without any errors. I have set the brokerage model to Margin, and added leverage:

 

self.SetBrokerageModel(BrokerageName.OandaBrokerage, AccountType.Margin)
self.AddForex("GBPUSD", Resolution.Minute, Market.Oanda, leverage=2.0)
Update Backtest








Its tricky to say without you sharing the full algorithm; when you have an existing position it is using some of your margin requirements. If for example the other positions are leverage=1 then they will consume much of your margin leaving none for real trading.

In reality OANDA doesn't allow you to customize that leverage value the margin requirement of your existing positions would be very low (normally 20-50x leverage) -- leaving you plenty of room to place the trade.

I'd recommend just using the default margin settings to FX to better model your OANDA account.

0

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.


Unfortunately, default values don't work either. I have plenty of margin available, and I can place the same order using the OANDA website without any issues. The Project ID is 929508. Is there a better way to share?

0

You can use the support tab on the left of the IDE for 1-1 support or attach the backtest here for community assistance.

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed