Exemplo n.º 1
0
        private void newTradeNotification(Trade trade)
        {
            //var SellActivationTask = Task.Run(() =>
            //{
            if (trade.Side == OrderSide.Buy)
            {
                lock (sellLock_stop)
                {
                    var shouldContinue = false;
                    do
                    {
                        var stopprice = Stop_SellOrdersDict.Keys.Reverse().FirstOrDefault();
                        if (stopprice < trade.Rate)
                        {
                            break;  //Break as No StopSell Order above Current Trading price;
                        }
                        foreach (var order in Stop_SellOrdersDict[stopprice])
                        {
                            order.Type            = order.Type == OrderType.StopLimit ? OrderType.Limit : OrderType.Market;
                            order.IsStopActivated = true;
                            PendingOrderQueue.Add(order);
                        }

                        Stop_SellOrdersDict.Remove(stopprice);
                        shouldContinue = true;
                    } while (shouldContinue);
                }
            }

            //});
            //var BuyActivationTask = Task.Run(() =>
            //{
            else if (trade.Side == OrderSide.Sell)
            {
                lock (buyLock_stop)
                {
                    var shouldContinue = false;
                    do
                    {
                        var stopprice = Stop_BuyOrdersDict.Keys.FirstOrDefault();
                        if (stopprice == 0 || stopprice > trade.Rate)
                        {
                            break;  //Break as No StopLimitBuy Order below Current Trading price;
                        }
                        foreach (var order in Stop_BuyOrdersDict[stopprice])
                        {
                            order.Type            = order.Type == OrderType.StopLimit ? OrderType.Limit : OrderType.Market;
                            order.IsStopActivated = true;
                            PendingOrderQueue.Add(order);
                        }

                        Stop_BuyOrdersDict.Remove(stopprice);

                        shouldContinue = true;
                    } while (shouldContinue);
                }
            }
            //});
            //ME_Gateway.Instance.TradeQueue.Add(trade);
            //var NotificationTask = Task.Run(() =>
            //{
            //    WC_TradeTicker.PushTicker(trade.Pair, trade);
            //});
            WC_TradeTicker.PushTicker(trade.Pair, trade);
        }
Exemplo n.º 2
0
 public WC_TradeTicker()
 {
     Instance = this;
 }