Example #1
0
        private async Task ExecuteMarketOrders(OrderList orderList)
        {
            var marketOrders = orderList.MarketOrders.ToArray();

            foreach (var marketOrder in marketOrders)
            {
                while (!marketOrder.IsOrderFullfiled() && marketOrder.Status == OrderStatus.Registered)
                {
                    try
                    {
                        var limitOrders = GetRankedOrders(marketOrder, orderList);

                        //If there is no limit orders to execute the market order - exit from the loop
                        if (limitOrders == null || limitOrders.Length == 0)
                        {
                            break;
                        }

                        foreach (var limitOrder in limitOrders)
                        {
                            await ExecuteOrders(marketOrder, limitOrder);
                        }
                    }
                    finally
                    {
                        orderList.CleanUpFullfiledLimitOrders();
                    }
                }
            }
        }
Example #2
0
 private async Task ExecuteLimitOrders(OrderList orderList)
 {
     foreach (var orderWrapperBuy in orderList.LimitOrdersBuy.OrderBy(itm => itm.Order.Id))
     {
         foreach (var orderWrapperSell in orderList.LimitOrdersSell.OrderBy(itm => itm.Order.Id))
         {
             if (orderWrapperBuy.Order.Price >= orderWrapperSell.Order.Price &&
                 orderWrapperBuy.Order.Asset == orderWrapperSell.Order.Asset &&
                 orderWrapperBuy.Order.TraderId != orderWrapperSell.Order.TraderId)
             {
                 try
                 {
                     await ExecuteOrders(orderWrapperBuy.Order, orderWrapperSell.Order);
                 }
                 finally
                 {
                     orderList.CleanUpFullfiledLimitOrders();
                 }
             }
         }
     }
 }
Example #3
0
 private async Task ExecuteLimitOrders(OrderList orderList)
 {
     foreach (var orderWrapperBuy in orderList.LimitOrdersBuy.OrderBy(itm => itm.Order.Id))
         foreach (var orderWrapperSell in orderList.LimitOrdersSell.OrderBy(itm => itm.Order.Id))
             if (orderWrapperBuy.Order.Price >= orderWrapperSell.Order.Price && 
                 orderWrapperBuy.Order.Asset == orderWrapperSell.Order.Asset &&
                 orderWrapperBuy.Order.TraderId != orderWrapperSell.Order.TraderId)
                 try
                 {
                     await ExecuteOrders(orderWrapperBuy.Order, orderWrapperSell.Order);
                 }
                 finally
                 {
                     orderList.CleanUpFullfiledLimitOrders();
                 }
 }
Example #4
0
        private async Task ExecuteMarketOrders(OrderList orderList)
        {
            var marketOrders = orderList.MarketOrders.ToArray();

            foreach (var marketOrder in marketOrders)
                while (!marketOrder.IsOrderFullfiled())
                    try
                    {
                        var limitOrders = GetRankedOrders(marketOrder, orderList);

                        //If there is no limit orders to execute the market order - exit from the loop
                        if (limitOrders == null || limitOrders.Length == 0)
                            break;

                        foreach (var limitOrder in limitOrders)
                            await ExecuteOrders(marketOrder, limitOrder);

                    }
                    finally
                    {
                        orderList.CleanUpFullfiledLimitOrders();
                    }

        }