public void AddOrderTrade(Trade t)
        {
            var tradeWithIndexing = new TradeWithIndexing
            {
                Trade = t
            };

            if (_firstOrder == null)
            {
                _firstOrder = tradeWithIndexing;
                return;
            }

            if (t.OrderDateTime.Value.Ticks <= _firstOrder.Trade.OrderDateTime.Value.Ticks)
            {
                AddToListStart(tradeWithIndexing, ref _firstOrder);
                return;
            }

            // Find position
            var positionNext = _firstOrder;

            while (positionNext.Next != null && positionNext.Next.Trade.OrderDateTime.Value.Ticks < t.OrderDateTime.Value.Ticks)
            {
                positionNext = positionNext.Next;
            }

            tradeWithIndexing.Next = positionNext.Next;
            tradeWithIndexing.Prev = positionNext;
            positionNext.Next      = tradeWithIndexing;
        }
        public void AddClosedTrade(Trade t)
        {
            var tradeWithIndexing = new TradeWithIndexing
            {
                Trade = t
            };

            AddToListStart(tradeWithIndexing, ref _firstClosed);
        }
        public void AddOpenTrade(Trade t)
        {
            var tradeWithIndexing = new TradeWithIndexing
            {
                Trade = t
            };

            AddToListStart(tradeWithIndexing, ref _firstOpen);
        }
 private void AddToListStart(TradeWithIndexing t, ref TradeWithIndexing first)
 {
     t.Prev = null;
     t.Next = first;
     if (first != null)
     {
         first.Prev = t;
     }
     first = t;
 }
 private void RemoveFromList(TradeWithIndexing t, ref TradeWithIndexing first)
 {
     if (first == t)
     {
         first = t.Next;
         if (first != null)
         {
             first.Prev = null;
         }
     }
     else
     {
         t.Prev.Next = t.Next;
         if (t.Next != null)
         {
             t.Next.Prev = t.Prev;
         }
     }
 }
 public void MoveOpenToClose(TradeWithIndexing t)
 {
     RemoveFromList(t, ref _firstOpen);
     AddToListStart(t, ref _firstClosed);
 }
 public void MoveOrderToClosed(TradeWithIndexing t)
 {
     RemoveFromList(t, ref _firstOrder);
     AddToListStart(t, ref _firstClosed);
 }
 public void MoveOrderToOpen(TradeWithIndexing t)
 {
     RemoveFromList(t, ref _firstOrder);
     AddToListStart(t, ref _firstOpen);
 }