Exemplo n.º 1
0
        public PLSerious CalculatePLs(OptionCombination optComb, DateTime calculationDate,
                                      decimal lowPrice, decimal highPrice, decimal interest, double volatility)
        {
            PLSerious plSerious = new PLSerious();

            plSerious.CalculationDate = calculationDate;
            plSerious.Volatility      = volatility;

            decimal interval = (highPrice - lowPrice) / 30;

            decimal equityPrice = lowPrice;

            while (equityPrice < highPrice + interval)
            {
                PLPoint plPoint = new PLPoint();
                plPoint.EquityPrice = equityPrice;

                foreach (OpenOption openOpt in optComb)
                {
                    decimal optPrice = CalcualtePrice(openOpt.Option, equityPrice, interest, calculationDate, volatility);

                    plPoint.Profit += (optPrice - openOpt.PurchasePrice) * openOpt.ContractNo * 100;
                }

                plSerious.PLPointSerious.Add(plPoint);

                equityPrice += interval;
            }

            return(plSerious);
        }
Exemplo n.º 2
0
        public void TestCalculatePLs()
        {
            OptionCombination optComb = new OptionCombination();

            OpenOption openOpt = new OpenOption();

            openOpt.ContractNo    = 10;
            openOpt.PurchaseDate  = new DateTime(2013, 05, 17);
            openOpt.PurchasePrice = 23.75m;
            openOpt.Option        = new Option()
            {
                Symbol = "NFLX", IsCall = true, Strike = 250, ExpiryDate = new DateTime(2013, 09, 21)
            };
            optComb.Options.Add(openOpt);

            //openOpt = new OpenOption();
            //openOpt.ContractNo = -10;
            //openOpt.PurchaseDate = new DateTime(2013, 05, 17);
            //openOpt.PurchasePrice = 9.90m;
            //openOpt.Option = new Option() { Symbol = "NFLX", IsCall = true, Strike = 300, ExpiryDate = new DateTime(2013, 09, 21) };
            //optComb.Options.Add(openOpt);

            Calculator calculator = new Calculator();
            var        plSerious  = calculator.CalculatePLs(optComb, new DateTime(2013, 07, 01), 100m, 380m, 0.003m, 0.5);
        }