예제 #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;
        }
예제 #2
0
        public PLChartUI(Canvas chart, OptionCombination optComb, double chartWidth)
        {
            this._chart = chart;
            this._optionComb = optComb;
            this._chart.Width = chartWidth;

            //DrawChart(DateTime.Today.AddMonths(1), 441, 0.02m, 0.40);
        }
예제 #3
0
        //public OptionCombination Options
        //{
        //    get
        //    {
        //        if (this._optionCombinations==null)
        //        {
        //            if (this.OptionCombinationXML.Length > 0)
        //            {
        //                var ser = new XmlSerializer(typeof(OptionCombination));

        //                this._optionCombinations = (OptionCombination)ser.Deserialize(new StringReader(this.OptionCombinationXML));
        //            }
        //        }

        //        return this._optionCombinations;
        //    }

        //    set
        //    {
        //        this._optionCombinations = value;

        //        if (this._optionCombinations != null)
        //        {
        //            var xs = new XmlSerializer(this._optionCombinations.GetType());
        //            var xml = new StringWriter();
        //            xs.Serialize(xml, this._optionCombinations);

        //            this.OptionCombinationXML = xml.ToString();
        //        }
        //    }
        //}

        public UserOptionComb(OptionComb optComb)
        {
            this.OptionCombID         = optComb.OptionCombID;
            this.UserID               = optComb.UserID;
            this.Name                 = optComb.Name;
            this.OptionCombinationXML = optComb.OptionCombinationXML;
            this.Description          = optComb.Description;
            this.Options              = null;

            if (!string.IsNullOrEmpty(this.OptionCombinationXML))
            {
                var ser = new XmlSerializer(typeof(OptionCombination));

                this.Options = (OptionCombination)ser.Deserialize(new StringReader(this.OptionCombinationXML));
            }
        }
예제 #4
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);
        }