public void calculatePortfolioTotalsTest()
        {
            Calculator calculator = new Calculator();
            Portfolio portfolio = new Portfolio();
            List<Position> positions = new List<Position>();
            Position position1 = new Position();

            position1.SecLastPrice = 102;
            position1.SecPrevClosePrice = 100;
            position1.ExecPrice = 100;
            position1.Quantity = 10;
            position1.DailyPnL = 20;
            position1.TotalPnL = 120;

            Position position2 = new Position();

            position2.SecLastPrice = 102;
            position2.SecPrevClosePrice = 100;
            position2.ExecPrice = 100;
            position2.Quantity = 10;
            position2.DailyPnL = 10;
            position2.TotalPnL = 240;

            positions.Add(position1);
            positions.Add(position2);

            portfolio.positions = positions;

            portfolio = calculator.calculatePortfolioTotals(portfolio);
            Assert.AreEqual(portfolio.portfolioTotalPnL, 360);
            Assert.AreEqual(portfolio.portfolioDailyPnL, 30);
        }
 // Calculates the Daily PnL
 public Position calculateDailyPnL(Position position)
 {
     // Daily PnL = Yesterday's Close price - current price
     decimal yestClosePrice = position.SecPrevClosePrice;
     decimal latestPrice = position.SecLastPrice;
     position.DailyPnL = latestPrice - yestClosePrice;
     return position;
 }
        // Calculates the Total PnL since purchase of the position
        public Position calculateTotalPnL(Position position)
        {
            decimal executionPrice = position.ExecPrice;
            int positionSize = position.Quantity;
            decimal positionLast = position.SecLastPrice;

            position.TotalPnL = (positionLast * positionSize) - (executionPrice * positionSize);
            return position;
        }
        public void calculateDailyPnLTest()
        {
            Calculator calculator = new Calculator();
            Position position  = new Position();
            position.SecLastPrice = 102;
            position.SecPrevClosePrice = 100;

               position=  calculator.calculateDailyPnL(position);
            Assert.AreEqual(position.DailyPnL ,2);
        }
        public void calculateTotalPnLTest()
        {
            Calculator calculator = new Calculator();

            Position position = new Position();
            position.SecLastPrice = 102;
            position.SecPrevClosePrice = 100;

            position.ExecPrice = 100;
            position.Quantity = 10;
            position.SecLastPrice = 120;

            position = calculator.calculateTotalPnL(position);
            Assert.AreEqual(position.TotalPnL, 200);
        }