예제 #1
0
        public void UpdateIndexForMatchedOrder(TransactionOrderMatch record)
        {
            if (record.PartialOrFull == TradePartialFull.Full)
            {
                DeleteSingleTransaction(record.OrderTransactionId);
            }
            else if (record.PartialOrFull == TradePartialFull.Partial)
            {
                var orderIndex = new OrderIndexItem()
                {
                    TransactionId = record.OrderTransactionId,
                    Owner         = record.OrderAddress,
                    TradingPair   = record.TradingPair,
                    Side          = record.Side,
                    Amount        = record.Amount,
                    Price         = record.Price
                };

                UpdateIndex(orderIndex);
            }
        }
예제 #2
0
        public void AddToIndex(TransactionOrderLimit record)
        {
            if (record == null)
            {
                return;
            }

            var orderIndex = new OrderIndexItem()
            {
                TransactionId = record.TransactionId,
                Owner         = record.Owner,
                TradingPair   = record.TradingPair,
                Side          = record.Side,
                Amount        = record.Amount,
                Price         = record.Price
            };

            database.SaveOrderIndex(orderIndex);
            IndexOrderCache.AddOrUpdate(orderIndex);

            database.AddToKeyMap("orders_" + record.TradingPair, record.TransactionId);
            database.AddToKeyMap("orders_expiry_" + record.ExpiryBlockIndex, record.TransactionId);
        }
예제 #3
0
        public static void AddOrUpdate(OrderIndexItem item)
        {
            if (cache == null)
            {
                cache = new List <OrderIndexItem>();
                cache.Add(item);
            }
            else
            {
                var find = cache.Where(x =>
                                       x.TransactionId == item.TransactionId)
                           .FirstOrDefault();

                if (find == null)
                {
                    cache.Add(item);
                }
                else
                {
                    cache.Remove(find);
                    cache.Add(item);
                }
            }
        }
예제 #4
0
 private void UpdateIndex(OrderIndexItem orderIndex)
 {
     database.SaveOrderIndex(orderIndex);
     IndexOrderCache.AddOrUpdate(orderIndex);
 }