public void ProcessTransaction(OrderTransaction trans)
        {
            string comment;

            if (trans.OrderId == 8)
            {
                comment = "";
            }
            IPositionInventory openPosition = OpenPositions.FirstOrDefault(p => p.GetSymbol() == trans.Symbol);

            if (openPosition == null)
            {
                openPosition = OpenPosition(trans, PositionInventoryMethod.Lifo);

                OpenPositions.Add(openPosition);
            }
            else
            {
                OrderTransaction transaction = ResolvePosition(openPosition, trans);
                if (openPosition.BuysCount() == 0 && openPosition.SellsCount() == 0)
                {
                    OpenPositions.Remove(openPosition);
                }
            }
        }
Example #2
0
 private void CreatePositionLists()
 {
     foreach (Position pos_i in Positions)
     {
         bool positionIsClosed = pos_i.CurrentQuantity == 0;
         if (positionIsClosed)
         {
             ExitedPositions.Add(pos_i);
         }
         else
         {
             OpenPositions.Add(pos_i);
         }
     }
 }