def enterMarketOrderPosition(self, symbol, position, posSize, tp, sl):
"""Enter a position (either Position.LONG or Position.Short)
for the given symbol with the position size using a market order.
Associated take-profit (tp) and stop-loss (sl) orders are entered."""
self.associatedOrdersLock.acquire()
self.notionalValue = self.liquidContract.AskPrice * self.forexPair.SymbolProperties.ContractMultiplier
self.Debug(f"Sym: {symbol} Margin: {self.Portfolio.MarginRemaining} Price: {self.liquidContract.LastPrice} NotionalValue: {self.notionalValue} Pos: {position} Size: {posSize}, Tp: {tp}, Sl: {sl}")
if position == Position.LONG:
self.Buy(symbol, posSize)
takeProfitOrderTicket = self.LimitOrder(symbol, -posSize, tp)
stopLossOrderTicket = self.StopMarketOrder(symbol, -posSize, sl)
elif position == Position.SHORT:
self.Sell(symbol, posSize)
takeProfitOrderTicket = self.LimitOrder(symbol, posSize, tp)
stopLossOrderTicket = self.StopMarketOrder(symbol, posSize, sl)
# associate the take-profit and stop-loss orders with one another
self.associatedOrders[takeProfitOrderTicket.OrderId] = stopLossOrderTicket
self.associatedOrders[stopLossOrderTicket.OrderId] = takeProfitOrderTicket
self.associatedOrdersLock.release()
self.trendNumTrades += 1
I'm using the IB account to trade Euro Futures Contract, but I don't understand why I'm getting the following warnings. I've tried changing the percision in round from 2-5, but nothing works. Why the LimitPricing rounded to 0?
Sym: 6E XFD7HH3CBY0X Margin: 999992.6 Price: 1.09485 NotionalValue: 136906.25 Pos: Position.SHORT Size: 1, Tp: 1.16054, Sl: 1.16054
61 | 21:06:26:
Backtest Handled Error: Warning: To meet brokerage precision requirements, order LimitPrice was rounded to 0 from 1.16054
Warning: To meet brokerage precision requirements, order StopPrice was rounded to 0 from 1.16054
Derek Melchin
Hi Bo,
Is this reproducible in a backtest? If so, please attach a backtest. If not, please share the project with prime support.
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.
Bo Vargas
You can see the warning in the console in the attached backtest.
Alexandre Catarino
Hi Bo Vargas ,
Sorry about the wait.
We have found a bug in Lean that has caused the wrong rounding of limit/stop orders prices. The bug has been fixed they are not rounded to zero now.
Bo Vargas
Can you share the github link to the PR? Is the fix live now or going out in next release?
Alexandre Catarino
Hi Bo Vargas ,
Sorry for not being clearer.
The fix was in production at the moment I have posted the last reply to this thread.
Bo Vargas
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!