Exemple #1
0
 public void AddOrder(MarketOrder order)
 {
     if (order.IsBid)
     {
         BuyOrders.Add(order);
     }
     else
     {
         SellOrders.Add(order);
     }
 }
Exemple #2
0
 private void AddOrder(Order newOrder)
 {
     if (newOrder.Action == ActionEnum.BUY)
     {
         BuyOrders.Add(newOrder);
     }
     else if (newOrder.Action == ActionEnum.SELL)
     {
         SellOrders.Add(newOrder);
     }
     else
     {
         throw new SmartException(ExceptionImportanceLevel.HIGH, "AddOrder", "StrategyState", "No other options. New Order = " + newOrder.ToString());
     }
     MakeConsistent();
 }
Exemple #3
0
        public BuyOrder CreateBuyOrder(string name, ulong quantity, ulong pricePerItem)
        {
            var orderAccount = new Account(0);

            if (!BalanceAccount.DepositInto(orderAccount, quantity * pricePerItem))
            {
                return(null);
            }
            var order = new BuyOrder(name, pricePerItem, quantity, orderAccount);

            order.AddCancelAction(CancelBuyOrder);
            order.AddExecuteAction(ExecuteBuyOrder);
            lock (BuyOrders)
            {
                BuyOrders.Add(order);
            }
            Updated?.Invoke(this, this);
            return(order);
        }
Exemple #4
0
        public void AddOrder(ILimitOrder order)
        {
            if (order.Price != Price)
            {
                return;
            }

            switch (order.Way)
            {
            case WayEnum.Buy:
                BuyOrders.Add(order);
                break;

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

            order.RegisterDeleteNotificationHandler(HandleDeleteOrFilled);
            order.RegisterFilledNotification(HandleDeleteOrFilled);
        }
 public TestDbState AddOrder(BuyOrder buyOrder)
 {
     BuyOrders.Add(buyOrder);
     return(this);
 }