Ejemplo n.º 1
0
        public string GetNetPosition()
        {
            string[] colNames = new[] { "TRADER", "SYMBOL", "QUANTITY" };
            var      result   = TraderPositions.GroupBy(r => new { r.Trader, r.Symbol })
                                .Select(grp => new
            {
                grp.Key,
                Qty = grp.Sum(claim => claim.Qty)
            }).Select(r => r.Key.Trader + "," + r.Key.Symbol + "," + r.Qty).ToList();

            return(string.Join(",", colNames) + Environment.NewLine + string.Join(Environment.NewLine, result));
        }
Ejemplo n.º 2
0
 public DataFile(string fileName) : this()
 {
     using (var streamReader = new StreamReader(fileName))
     {
         streamReader.ReadLine();//skip first line
         while (streamReader.Peek() >= 0)
         {
             var traderPosition = new TraderPosition(streamReader.ReadLine());
             TraderPositions.Add(traderPosition);
             if (traderPosition.Qty >= 0)
             {
                 LongPositions.Add(traderPosition);
             }
             else
             {
                 ShortPositions.Add(traderPosition);
             }
         }
     }
 }