Example #1
0
        public void RemoveOrder(string orderId, int cookie)
        {
            /* int buyIndex = BuyOrders.FindIndex(order => (order.OrderId == orderId));
             * int sellIndex = SellOrders.FindIndex(order => (order.OrderId == orderId));
             * if (buyIndex >= 0)
             *  BuyOrders.RemoveAt(buyIndex);
             * else if (sellIndex >= 0)
             *  SellOrders.RemoveAt(sellIndex);
             * else
             * {
             *  buyIndex = BuyOrders.FindIndex(order => (order.Cookie == cookie));
             *  sellIndex = SellOrders.FindIndex(order => (order.Cookie == cookie));
             *  if (buyIndex >= 0)
             *      BuyOrders.RemoveAt(buyIndex);
             *  else if (sellIndex >= 0)
             *      SellOrders.RemoveAt(sellIndex);
             * } */
            Order foundOrder = FindOrder(orderId, cookie);

            if (foundOrder != null)
            {
                if (foundOrder.Action == ActionEnum.BUY)
                {
                    BuyOrders.Remove(foundOrder);
                }
                else if (foundOrder.Action == ActionEnum.SELL)
                {
                    SellOrders.Remove(foundOrder);
                }
                else
                {
                    throw new SmartException(ExceptionImportanceLevel.LOW, "RemoveOrder", "StrategyState", "No other choices in foundOrder.Action");
                }
            }
        }
Example #2
0
 private void CancelBuyOrder(BuyOrder order)
 {
     order.OrderAccount.DepositInto(BalanceAccount, order.OrderAccount.Balance);
     lock (BuyOrders)
     {
         BuyOrders.Remove(order);
     }
     Updated?.Invoke(this, this);
 }
Example #3
0
        public void RemoveOrder(ILimitOrder order)
        {
            switch (order.Way)
            {
            case WayEnum.Buy:
                BuyOrders.Remove(order);
                break;

            case WayEnum.Sell:
                SellOrders.Remove(order);
                break;
            }

            order.UnRegisterDeleteNotificationHandler(HandleDeleteOrFilled);
            order.UnRegisterFilledNotification(HandleDeleteOrFilled);
        }
Example #4
0
        private void ExecuteBuyOrder(BuyOrder order)
        {
            Security security;

            if (!Securities.TryGetValue(order.SecurityName, out security))
            {
                Securities.Add(order.SecurityName, order.Security);
            }
            else
            {
                Securities[order.SecurityName].Merge(order.Security);
            }
            lock (BuyOrders)
            {
                BuyOrders.Remove(order);
            }
            Updated?.Invoke(this, this);
        }