public CancelOrderCommand(Order mask)
		{
			if (mask == null)
				throw new ArgumentNullException("mask");

			Mask = mask;
		}
				public void Remove(Order order)
				{
					if (order == null)
						throw new ArgumentNullException(nameof(order));

					_orders.Remove(order);
				}
		public RegisterOrderCommand(Order order)
		{
			if (order == null)
				throw new ArgumentNullException(nameof(order));

			Order = order;
		}
				public void Add(Order order)
				{
					if (order == null)
						throw new ArgumentNullException(nameof(order));

					_orders.Add(order);
				}
		/// <summary>
		/// Перерегистрировать заявку на бирже.
		/// </summary>
		/// <param name="oldOrder">Заявка, которую нужно снять.</param><param name="newOrder">Новая заявка, которую нужно зарегистрировать.</param>
		protected override void OnReRegisterOrder(Order oldOrder, Order newOrder)
		{
			if (oldOrder.Security.Board.IsSupportAtomicReRegister)
			{
				var newOrderId1 = oldOrder.Id;
				var newOrderId2 = 0L;

				string res;
				var resCode = _slot.MoveOrders(1, ref newOrderId1, (double)newOrder.Price, (int)newOrder.Volume,
				                              newOrder.TransactionId.To<string>(), ref newOrderId2, 0, 0, "", out res);

				var exception = AlorExceptionHelper.GetException(resCode, res);

				if (exception != null)
				{
					RaiseOrderFailed(newOrder, exception);
					RaiseOrderFailed(oldOrder, exception);
				}

				newOrder.Messages.Add(res);
			}
			else
			{
				base.OnReRegisterOrder(oldOrder, newOrder);
			}
		}
Exemple #6
0
		public OrderCommand(Order order, OrderActions action)
		{
			if (order == null)
				throw new ArgumentNullException(nameof(order));

			Order = order;
			Action = action;
		}
			public void ProcessChangedOrder(Order order)
			{
				var container = GetContainer(order);

				if (order.State == OrderStates.Done)
					container.Remove(order);

				container.RefreshTotals();
			}
			public void ProcessNewOrder(Order order)
			{
				var container = GetContainer(order);

				if (order.State == OrderStates.Active)
				{
					container.Add(order);
					container.RefreshTotals();
				}
			}
		public ReRegisterOrderCommand(Order oldOrder, Order newOrder)
		{
			if (oldOrder == null)
				throw new ArgumentNullException(nameof(oldOrder));

			if (newOrder == null)
				throw new ArgumentNullException(nameof(newOrder));

			OldOrder = oldOrder;
			NewOrder = newOrder;
		}
		/// <summary>
		/// Зарегистрировать заявку на бирже.
		/// </summary>
		/// <param name="order">Заявка, содержащая информацию для регистрации.</param>
		protected override void OnRegisterOrder(Order order)
		{
			string exexCondition;

			switch (order.TimeInForce)
			{
				case TimeInForce.PutInQueue:
					exexCondition = " ";
					break;
				case TimeInForce.MatchOrCancel:
					exexCondition = "N";
					break;
				case TimeInForce.CancelBalance:
					exexCondition = "W";
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}

			const string enterType = "P";
			const string splitFlag = "S";
			const string issueCode = "";

			var direction = order.Direction == OrderDirections.Buy ? "B" : "S";
			var extRef = order.TransactionId.To<String>();

			int resCode;
			string res;

			if (order.Type == OrderTypes.Conditional)
			{
				var condition = (AlorOrderCondition)order.Condition;
				resCode = _slot.AddStopOrder(order.Portfolio.Name, direction, order.Price == 0 ? "M" : "L", splitFlag,
				                            exexCondition, enterType, order.Security.Board.Code, order.Security.Code, issueCode,
				                            condition.Type.ToAlorConditionType(), order.ExpiryDate,
				                            (double)condition.StopPrice, (double)order.Price, (int)order.Volume, _slot.BrokerRef, extRef, out res);
			}
			else
			{

				resCode = _slot.AddOrder(order.Portfolio.Name, direction,
				                        order.Type == OrderTypes.Market ? "M" : "L", splitFlag, exexCondition, enterType, order.Security.Board.Code,
				                        order.Security.Code, issueCode, (double)order.Price, (int)order.Volume, _slot.BrokerRef, extRef, out res);
			}

			var exception = AlorExceptionHelper.GetException(resCode, res);
			if (exception != null)
				RaiseOrderFailed(order, exception);

			order.Messages.Add(res);
		}
		private void OrderGrid_OnOrderReRegistering(Order order)
		{
			var window = new OrderWindow
			{
				Title = LocalizedStrings.Str2976Params.Put(order.TransactionId),
				Connector = MainWindow.Instance.Trader,
				Order = order.ReRegisterClone(newVolume: order.Balance),
			};

			if (window.ShowModal(this))
			{
				MainWindow.Instance.Trader.ReRegisterOrder(order, window.Order);
			}
		}
Exemple #12
0
		private void DeleteOrder(Order order)
		{
			if (order != null)
			{
				try
				{
					Connector.CancelOrder(order);
				}
				catch (Exception g)
				{
					Debug.Print("{0}", g);
				}
			}
		}
		private void OrderGrid_OnOrderReRegistering(Order order)
		{
			var window = new OrderWindow
			{
				Title = LocalizedStrings.Str2976Params.Put(order.TransactionId),
				SecurityProvider = MainWindow.Instance.Trader,
				MarketDataProvider = MainWindow.Instance.Trader,
				Portfolios = new PortfolioDataSource(MainWindow.Instance.Trader),
				Order = order.ReRegisterClone(newVolume: order.Balance),
			};

			if (window.ShowModal(this))
			{
				MainWindow.Instance.Trader.ReRegisterOrder(order, window.Order);
			}
		}
        protected override void OnStarted()
        {
            var order = new Order
            {
                Type = OrderTypes.Limit,
                Portfolio = Portfolio,
                Volume = 100,
                Price = price,
                Security = Security,
                Direction = sides
            };

            Connector.RegisterOrder(order);

            base.OnStarted();
        }     
Exemple #15
0
		private void SpeedTestStrategyOrderRegistered(Order order)
		{
			lock (_locker)
			{
				if (order.LatencyRegistration != null)
					_holeTime += order.LatencyRegistration.Value;

				NumberOfOrders++;

				if (OrderTimeChanged != null)
					OrderTimeChanged();

				DeleteOrder(order);

				if (NumberOfOrders < _nummberofTests)
				{
					RegisterOrder(SendNewOrder());
				}
				else
				{
					Stop();
				}
			}
		}
		/// <summary>
		/// The method is called when a new order added.
		/// </summary>
		/// <param name="order">Order.</param>
		protected override void OnOrderAdded(Order order)
		{
			if (order.Type != OrderTypes.Conditional)
				return;

			Type conditionType;

			lock (_conditionTypes.SyncRoot)
			{
				var condition = order.Condition;

				if (condition == null)
					return;

				conditionType = condition.GetType();

				if (_conditionTypes.Contains(conditionType))
					return;

				_conditionTypes.Add(conditionType);
			}

			GuiDispatcher.GlobalDispatcher.AddAction(() => AddColumns(conditionType));
		}
		protected override void AssignOrderStrategyId(Order order)
		{
			order.UserOrderId = this.GetStrategyId().To<string>();
		}
		/// <summary>
		/// Отменить заявку на бирже.
		/// </summary>
		/// <param name="order">Заявка, которую нужно отменять.</param>
		protected override void OnCancelOrder(Order order)
		{
			var id = order.Id;
			string res;
			var resCode = order.Type == OrderTypes.Conditional
				              ? _slot.DeleteStopOrder(id, out res)
				              : _slot.DeleteOrder(id, out res);

			var exception = AlorExceptionHelper.GetException(resCode, res);

			if (exception != null)
				RaiseOrderFailed(order, exception);

			order.Messages.Add(res);
		}
Exemple #19
0
			/// <summary>
			/// Отменить заявку на бирже.
			/// </summary>
			/// <param name="order">Заявка, которую нужно отменять.</param>
			/// <param name="transactionId">Идентификатор транзакции отмены.</param>
			protected override void OnCancelOrder(Order order, long transactionId)
			{
				_realConnector.SendInMessage(order.CreateCancelMessage(_realConnector.GetSecurityId(order.Security), transactionId));
			}
Exemple #20
0
			/// <summary>
			/// Перерегистрировать пару заявок на бирже.
			/// </summary>
			/// <param name="oldOrder1">Первая заявка, которую нужно снять.</param>
			/// <param name="newOrder1">Первая новая заявка, которую нужно зарегистрировать.</param>
			/// <param name="oldOrder2">Вторая заявка, которую нужно снять.</param>
			/// <param name="newOrder2">Вторая новая заявка, которую нужно зарегистрировать.</param>
			protected override void OnReRegisterOrderPair(Order oldOrder1, Order newOrder1, Order oldOrder2, Order newOrder2)
			{
				if (IsSupportAtomicReRegister && oldOrder1.Security.Board.IsSupportAtomicReRegister)
					_realConnector.SendInMessage(oldOrder1.CreateReplaceMessage(newOrder1, _realConnector.GetSecurityId(newOrder1.Security), oldOrder2, newOrder2, _realConnector.GetSecurityId(newOrder2.Security)));
				else
					base.OnReRegisterOrderPair(oldOrder1, newOrder1, oldOrder2, newOrder2);
			}
Exemple #21
0
			/// <summary>
			/// Зарегистрировать заявку на бирже.
			/// </summary>
			/// <param name="order">Заявка, содержащая информацию для регистрации.</param>
			protected override void OnRegisterOrder(Order order)
			{
				var regMsg = order.CreateRegisterMessage(_realConnector.GetSecurityId(order.Security));

				var depoName = order.Portfolio.GetValue<string>(PositionChangeTypes.DepoName);
				if (depoName != null)
					regMsg.AddValue(PositionChangeTypes.DepoName, depoName);

				_realConnector.SendInMessage(regMsg);
			}
		private void ClosePosition(Position position, decimal volume)
		{
			var side = position.CurrentValue > 0 ? Sides.Sell : Sides.Buy;
			var security = position.Security;

			var order = new Order
			{
				Security = security,
				Portfolio = position.Portfolio,
				Direction = side,
				Volume = volume,
				Type = position.Portfolio.Board.IsSupportMarketOrders ? OrderTypes.Market : OrderTypes.Limit,
			};

			if (order.Type == OrderTypes.Limit)
				order.Price = security.GetMarketPrice(SafeGetConnector(), side) ?? 0;

			RegisterOrder(order);
		}
Exemple #23
0
		private void AddOrder(Order order)
		{
			if (OrdersKeepCount == 0)
				return;

			_orders.Add(order);
			RecycleOrders();
		}
		public override void AttachOrder(Order order, IEnumerable<MyTrade> myTrades)
		{
			Strategy.AttachOrder(order, myTrades);
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="OrderWindow"/>.
		/// </summary>
		public OrderWindow()
		{
			InitializeComponent();

			TimeInForceCtrl.SetDataSource<OrderWindowTif>();

			Order = new Order { Type = OrderTypes.Limit };
			DataContext = Data = new SecurityData();
		}
        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        private void butStartStrategy_Click(object sender, RoutedEventArgs e)
        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        {
            if (threadStrategy == null)
            //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            {            //if (threadStrategy == null)
                threadStrategy = new Thread
                                 (
                    new ThreadStart
                        (() =>
                {
                    try
                    {
                        while (true)
                        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                        {                                                                //бесконечный цикл обработки стратегии
                            if (analizationPool.Count != 0)
                            {
                                ProcessStrategy();
                            }
                            Thread.Sleep(processStrategyRate);
                        }                                                                //бесконечный цикл обработки стратегии
                                                                                         //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    }
                    catch (Exception ex)
                    {
                        //SendMessage("ERROR", "Error on Thread startegy:>>" + ex.ToString());
                    }
                    finally
                    {
                        //status = StrategyStatus.Stopped;
                    }
                }
                        )
                                 );
                threadStrategy.Name         = "StrategyThread_" + DateTime.Now.Ticks.ToString();
                threadStrategy.IsBackground = true;
                threadStrategy.Priority     = ThreadPriority.Normal;
            }            //if (threadStrategy == null)
            //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            if (threadTrader == null)
            //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            {            //if (threadTrader == null)
                threadTrader = new Thread
                               (
                    new ThreadStart
                        (() =>
                {
                    try
                    {
                        while (true)
                        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                        {                                                                //бесконечный цикл обработки стратегии
                            if (ordersCancel.Count != 0)
                            //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                            {                                                                    //отмена ордеров
                                MyOrder myOrder;
                                while (ordersCancel.TryDequeue(out myOrder))
                                {
                                    if (myOrder.ssOrder == null)
                                    {
                                        throw new Exception("Unexpected state of order");
                                        continue;
                                    }
                                    //lock (order)
                                    //{
                                    //if (order.Status == Trade.Order.OrderStatus.Cancelling)
                                    //{
                                    myOrder.Status = MyOrderStatus.SentToCancel;
                                    trader.CancelOrder(myOrder.ssOrder);
                                    //}
                                    //}
                                    //Thread.Sleep(1000);
                                }
                            }                                                                    //отмена ордеров
                            //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                            if (ordersSend.Count != 0)
                            //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                            {                                                                    //отправка ордеров
                                MyOrder myOrder;
                                while (ordersSend.TryDequeue(out myOrder))
                                {
                                    //_o.rwLock.EnterWriteLock();
                                    MyOrder _order = myOrder;
                                    StockSharp.BusinessEntities.Order ssOrd = new StockSharp.BusinessEntities.Order()
                                    {
                                        Trader    = trader,
                                        Portfolio = portfolio,
                                        Security  = security,
                                        Comment   = "GISMO",
                                        Direction = StockSharp.BusinessEntities.OrderDirections.Buy,                                                                                       // : StockSharp.BusinessEntities.OrderDirections.Sell,
                                        Price     = (decimal)_order.price,
                                        Type      = StockSharp.BusinessEntities.OrderTypes.Limit,
                                        Volume    = _order.amount
                                    };
                                    _order.ssOrder = ssOrd;
                                    //_order.rulerContainer = StockSharp.Algo.MarketRuleHelper.DefaultRuleContainer;

                                    var ruleRegFail = ssOrd.WhenRegisterFailed();
                                    var ruleReg     = ssOrd.WhenRegistered();
                                    //_order.RegisterToken(ruleRegFail.Token);
                                    //_order.RegisterToken(ruleReg.Token);
                                    ruleReg.Do((StockSharp.BusinessEntities.Order _ssOrd) =>
                                    {
                                        try
                                        {
                                            //GISMO.Trade.Order __order = QTrader._orders[_ssOrd.TransactionId];
                                            //__order.rwLock.EnterWriteLock();
                                            _order.Status = MyOrderStatus.AcceptedByServer;
                                            _order.AddStage("WhenRegistered:OrderRegistered");
                                            //__order.rwLock.ExitWriteLock();

                                            _order.OnOrderRegistered();
                                        }
                                        catch (Exception ex)
                                        {
                                            int i = 0;
                                        }
                                    })
                                    .Once()
                                    .Apply(StockSharp.Algo.MarketRuleHelper.DefaultRuleContainer)
                                    .Exclusive(ruleRegFail);

                                    ruleRegFail.Do((StockSharp.BusinessEntities.OrderFail f) =>
                                    {
                                        try
                                        {
                                            //GISMO.Trade.Order __order = QTrader._orders[f.Order.TransactionId];
                                            //__order.rwLock.EnterWriteLock();
                                            _order.Status = MyOrderStatus.Failed;
                                            _order.AddStage("WhenRegisteredFail:OrderRegisteredFail");
                                            //__order.rwLock.ExitWriteLock();

                                            _order.OnOrderRegisterFailed(new OrderFailEventArg()
                                            {
                                                order = _order,
                                                fail  = new OrderFail()
                                                {
                                                    ssFail = f
                                                }
                                            });
                                        }
                                        catch (Exception ex)
                                        {
                                            int i = 0;
                                        }
                                    })
                                    .Once()
                                    .Apply(StockSharp.Algo.MarketRuleHelper.DefaultRuleContainer)
                                    .Exclusive(ruleReg);

                                    var ruleCancelled     = ssOrd.WhenCanceled();
                                    var ruleCancelledFail = ssOrd.WhenCancelFailed();
                                    //_order.RegisterToken(ruleCancelled.Token);
                                    //_order.RegisterToken(ruleCancelledFail.Token);
                                    ruleCancelled.Do((StockSharp.BusinessEntities.Order _ssOrd) =>
                                    {
                                        try
                                        {
                                            //GISMO.Trade.Order __order = QTrader._orders[_ssOrd.TransactionId];
                                            //__order.rwLock.EnterWriteLock();
                                            _order.Status = MyOrderStatus.Cancelled;
                                            //__order.rwLock.ExitWriteLock();

                                            //StockSharp.Algo.MarketRuleHelper.DefaultRuleContainer.Rules.RemoveRulesByToken(ruleCancelled.Token, ruleCancelled);
                                            _order.OnOrderCancelled();
                                        }
                                        catch (Exception ex)
                                        {
                                            int i = 0;
                                        }
                                    })
                                    .Once()
                                    .Apply(StockSharp.Algo.MarketRuleHelper.DefaultRuleContainer)
                                    .Exclusive(ruleCancelledFail);

                                    ruleCancelledFail.Do((StockSharp.BusinessEntities.OrderFail f) =>
                                    {
                                        try
                                        {
                                            //GISMO.Trade.Order __order = QTrader._orders[f.Order.TransactionId];
                                            //__order.rwLock.EnterWriteLock();
                                            _order.Status = MyOrderStatus.Failed;
                                            _order.AddStage("WhenCancelFail:OrderCancelFail");
                                            //__order.rwLock.ExitWriteLock();

                                            _order.OnOrderCancelFailed(new OrderFailEventArg()
                                            {
                                                order = _order,
                                                fail  = new OrderFail()
                                                {
                                                    ssFail = f
                                                }
                                            });
                                        }
                                        catch (Exception ex)
                                        {
                                            int i = 0;
                                        }
                                    })
                                    .Once()
                                    .Apply(StockSharp.Algo.MarketRuleHelper.DefaultRuleContainer)
                                    .Exclusive(ruleCancelled);

                                    var ruleMatched = _order.ssOrder.WhenMatched();
                                    //_order.RegisterToken(ruleMatched.Token);
                                    ruleMatched.Do(() =>
                                    {
                                        try
                                        {
                                            //_order.rwLock.EnterWriteLock();
                                            _order.Status = MyOrderStatus.Filled;
                                            //_order.rwLock.ExitWriteLock();

                                            StockSharp.Algo.MarketRuleHelper.DefaultRuleContainer.Rules.RemoveRulesByToken(ruleMatched.Token, ruleMatched);
                                            _order.OnOrderMatched();
                                        }
                                        catch (Exception ex)
                                        {
                                            int i = 0;
                                        }
                                    })
                                    .Once()
                                    .Apply();

                                    var rulePartMatched = _order.ssOrder.WhenPartiallyMatched();
                                    //_order.RegisterToken(rulePartMatched.Token);
                                    rulePartMatched.Do(() =>
                                    {
                                        try
                                        {
                                            //_order.rwLock.EnterWriteLock();
                                            _order.Status = MyOrderStatus.PartlyFilled;
                                            //_order.rwLock.ExitWriteLock();

                                            _order.OnOrderPartlyMatched();
                                        }
                                        catch (Exception ex)
                                        {
                                            int i = 0;
                                        }
                                    }).Apply();

                                    var ruleNewTrades = _order.ssOrder.WhenNewTrades();
                                    //_order.RegisterToken(ruleNewTrades.Token);
                                    ruleNewTrades.Do((IEnumerable <MyTrade> trades) =>
                                    {
                                        try
                                        {
                                            //List<OrderExecution> execs = new List<OrderExecution>();
                                            //foreach (MyTrade mt in trades) execs.Add(new OrderExecution() { ssMyTrade = mt });
                                            //_order.OnOrderTrades(new OrderExecutionEventArg()
                                            //{
                                            //	order = _order,
                                            //	executions = execs
                                            //});
                                        }
                                        catch (Exception ex)
                                        {
                                            int i = 0;
                                        }
                                    })
                                    .Apply();
                                    _order.Status = MyOrderStatus.SentToServer;
                                    trader.RegisterOrder(ssOrd);
                                    //Thread.Sleep(1000);
                                    //QTrader._orders.Add(ssOrd.TransactionId, _order);

                                    //_o.rwLock.ExitWriteLock();
                                    //if (_order.Strategy != null) _order.Strategy.SendMessage("QSEND", "Order price " + _order.price.ToString() + " Sent (TransID = " + ssOrd.TransactionId + ")");
                                }
                            }                                                                    //отправка ордеров
                            //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                            Thread.Sleep(processStrategyRate);
                        }                                                                //бесконечный цикл обработки стратегии
                                                                                         //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    }
                    catch (Exception ex)
                    {
                        //SendMessage("ERROR", "Error on Thread startegy:>>" + ex.ToString());
                    }
                    finally
                    {
                        //status = StrategyStatus.Stopped;
                    }
                }
                        )
                               );
                threadTrader.Name         = "TraderThread_" + DateTime.Now.Ticks.ToString();
                threadTrader.IsBackground = true;
                threadTrader.Priority     = ThreadPriority.Normal;
            }            //if (threadTrader == null)
                         //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

            try
            {
                //bool tRunning = threadStrategy...ThreadState.HasFlag(ThreadState.Running);
                if (!threadStrategy.IsAlive)
                {
                    threadStrategy.Start();
                }
                if (!threadTrader.IsAlive)
                {
                    threadTrader.Start();
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #27
0
		public bool TryAddOrder(Order order)
		{
			if (order == null)
				throw new ArgumentNullException(nameof(order));

			bool isNew;
			GetOrderInfo(GetData(order.Security), order.Type, order.TransactionId, null, null, id => order, out isNew);
			return isNew;
		}
Exemple #28
0
		public void AddOrderByCancelTransaction(long transactionId, Order order)
		{
			if (order == null)
				return;

			var key = CreateOrderKey(order.Type, transactionId, true);
			GetData(order.Security).Orders.Add(key, new OrderInfo(order, false));
			_allOrdersByTransactionId.Add(Tuple.Create(transactionId, true), order);
		}
		private void ProcessOrder(Order order)
		{
			Dictionary<IChartElement, object> values;

			lock (_syncRoot)
			{
				var elements = _orderElements.TryGetValue(order.Security);

				if (elements == null)
					return;

				values = elements.ToDictionary(e => e, e => (object)order);
			}

			if (values.Count > 0)
				new ChartDrawCommand(order.Time, values).Process(this);
		}
Exemple #30
0
			public OrderInfo(Order order, bool raiseNewOrder = true)
			{
				Order = order;
				RaiseNewOrder = raiseNewOrder;
			}
Exemple #31
0
		protected virtual void OnNewOrderTrades(IEnumerable<MyTrade> trades)
		{
			foreach (var t in trades)
			{
				if (t.Order.Type == OrderTypes.Conditional)
				{
					continue;
				}

				var stopLossLevel = _strategyConfiguration.StopLossLevel;
				var takeProfitLevel = _strategyConfiguration.TakeProfitLevel;
				var takeProfitOffset = _strategyConfiguration.TakeProfitOffset;

				var direction = (t.Order.Direction == Sides.Buy) ? Sides.Sell : Sides.Buy;

				var order = new Order
				{
					Type = OrderTypes.Conditional,
					Volume = t.Order.Volume,
					//Price = stopLossLevel,
					Direction = direction,
					Security = t.Order.Security,
					Condition = new QuikOrderCondition
					{
						Type = QuikOrderConditionTypes.TakeProfitStopLimit,
						StopPrice = (direction == Sides.Sell) ? t.Order.Price + takeProfitLevel : t.Order.Price - takeProfitLevel,
						StopLimitPrice = (direction == Sides.Sell) ? t.Order.Price - stopLossLevel : t.Order.Price + stopLossLevel,
						Offset = takeProfitOffset,
						IsMarketStopLimit = true,
						IsMarketTakeProfit = true
					}
				};

				RegisterOrder(order);
			}
		}