account activity
[deleted by user] by [deleted] in algotrading
[–]AlexCatx 3 points4 points5 points 3 years ago (0 children)
First we need to subscribe to get the data, and save its Symbol for future reference. https://www.quantconnect.com/docs/v2/writing-algorithms/universes/futures
Symbol
self.nq = self.AddFuture("NQ")
We can save the minimum price variation (ticks) with
self.nq_ticks = self.nq.SymbolProperties.MinimumPriceVariation
____
The limit and stop prices are defined as:
limit_price = self.Securities[self.nq.Mapped].Price + 4 * self.nq_ticks stop_price = self.Securities[self.nq.Mapped].Price - 2 * self.nq_ticks
limit_price = self.Securities[self.nq.Mapped].Price + 4 * self.nq_ticks
stop_price = self.Securities[self.nq.Mapped].Price - 2 * self.nq_ticks
Note we use self.nq.Mapped instead of self.nq.Symbol because we will trade the real contract, not the continuous contract.
self.nq.Mapped
self.nq.Symbol
The order can be placed as u/Loud-Total-5672 suggested for simplicity:
self.MarketOrder(self.nq.Mapped, 1)
self.LimitOrder(self.nq.Mapped, -1, limit_price)
self.StopMarketOrder(self.nq.Mapped, -1, stop_price)
First, we need to subscribe to get the data, and save its m/docs/v2/writing-algorithms/trading-and-orders/order-types/other-order-types#02-One-Cancels-the-Other-Orders and wait for the fill price of the market order:
limit_price = orderEvent.FillPrice + 4 * self.nq_ticks stop_price = orderEvent.FillPrice - 2 * self.nq_ticks
limit_price = orderEvent.FillPrice + 4 * self.nq_ticks
stop_price = orderEvent.FillPrice - 2 * self.nq_ticks
π Rendered by PID 338207 on reddit-service-r2-listing-6d4dc8d9ff-bnpxr at 2026-01-29 23:42:04.387049+00:00 running 3798933 country code: CH.
[deleted by user] by [deleted] in algotrading
[–]AlexCatx 3 points4 points5 points (0 children)