Hi all, hope you are well.
I can't seem to get a brokerage model set. when working locally with docker.
I have created my own tick bars which I add as follows:
self.SetStartDate(2018, 1, 2)
self.SetCash(10_000)
self.SetTimeZone(DateTimeZone.Utc)
self.SetBrokerageModel(BrokerageName.OandaBrokerage)
fx_symbol = Symbol.Create("GBPUSD", SecurityType.Forex, Market.Oanda)
self.symbol = self.AddData(TickBars, fx_symbol, None, DateTimeZone.Utc).Symbol
But when I make a StopMarketOrder like, e.g., this:
self.StopMarketOrder(self.symbol, 60499.0, 1.39140)
I get this warning: 'To meet brokerage precision requirements order stop price was rounded to 1.39'. This makes me think the PriceVariationModel is still set to the default. Additionally, I get an order error: id 1, insufficient buying power, which makes me think the MarginModel isn't set correctly.
When working with the provided EURUSD data it does work, which makes me think I need to do something else/more to link my custom data to the BrokerageModel
Is this the correct way to set a BrokerageModel?
Thanks in advance,
Tom
Derek Melchin
Hi Tomás,
The code above successfully sets the Oanada brokerage. The "brokerage precision" error is thrown because the minimum price variation of custom data is 0.01 by default. To increase the precision, we need to specify the SymbolProperties, as shown below.
properties = SymbolProperties("EUR", "USD", 1, 0.0001, 1, "EURUSD") exchangeHours = SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork) self.symbol = self.AddData(USDRUB, "EURUSD", properties, exchangeHours)
After making the change above and reducing the position size, the margin error is no longer being thrown. See the attached backtest for reference. Note that the call to `SetBrokerageModel` has been removed as the OandaBrokerageModel does not support Base security type (custom data).
Best,
Derek Melchin
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.
Tomás Beers
Thank you!
Tomás Beers
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!