コード例 #1
0
 public void Update(OptionType type, VolQuote volQuote)
 {
     if (type == OptionType.Call)
     {
         this.UpdateCall(volQuote);
     }
     else
     {
         this.UpdatePut(volQuote);
     }
 }
コード例 #2
0
ファイル: VolSurface.cs プロジェクト: RubensYamamoto/Mestrado
 public void Update(DateTime expiryDate, double strike, OptionType type, VolQuote volQuote)
 {
     VolExpiry existingExpiry = null;
     if (this.VolExpiries.TryGetValue(expiryDate, out existingExpiry))
     {
         existingExpiry.Update(strike, type, volQuote);
     }
     else
     {
         VolExpiry volExpiry = new VolExpiry(expiryDate);
         volExpiry.Update(strike, type, volQuote);
         this.VolExpiries[expiryDate] = volExpiry;
     }
 }
コード例 #3
0
        public void Update(double strike, OptionType type, VolQuote volQuote)
        {
            VolStrike existingStrike = null;

            if (this.VolStrikes.TryGetValue(strike, out existingStrike))
            {
                existingStrike.Update(type, volQuote);
            }
            else
            {
                VolStrike volStrike = new VolStrike(strike);
                volStrike.Update(type, volQuote);
                this.VolStrikes[strike] = volStrike;
            }
        }
コード例 #4
0
        public void Update(DateTime expiryDate, double strike, OptionType type, VolQuote volQuote)
        {
            VolExpiry existingExpiry = null;

            if (this.VolExpiries.TryGetValue(expiryDate, out existingExpiry))
            {
                existingExpiry.Update(strike, type, volQuote);
            }
            else
            {
                VolExpiry volExpiry = new VolExpiry(expiryDate);
                volExpiry.Update(strike, type, volQuote);
                this.VolExpiries[expiryDate] = volExpiry;
            }
        }
コード例 #5
0
 private void UpdatePut(VolQuote volQuote)
 {
     this.VolPutQuote = volQuote;
 }
コード例 #6
0
 private void UpdateCall(VolQuote volQuote)
 {
     this.VolCallQuote = volQuote;
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: RubensYamamoto/Mestrado
        private VolSurface GetVolSurface(SortedDictionary<DateTime, RiskFreeRate> riskFreeRates, OrderBook underlyingOrderBook, List<OptionMarketData> optionsMarketData)
        {
            double businessDaysInTheYear = 252;
            VolSurface volSurface = new VolSurface();
            double spot = underlyingOrderBook.GetPriceMid();

            foreach (OptionMarketData option in optionsMarketData)
            {
                RiskFreeRate riskFreeRate = null;
                riskFreeRates.TryGetValue(option.OptionInfo.ExpiryDate, out riskFreeRate);

                double timeToMaturity = riskFreeRate.BusinessDays / businessDaysInTheYear;

                double bid = (option.OrderBook.Bid != null) ? option.OrderBook.Bid.Value : 0.00;
                double bidSize = (option.OrderBook.BidSize != null) ? option.OrderBook.BidSize.Value : 0.00; ;
                double ask = (option.OrderBook.Ask != null) ? option.OrderBook.Ask.Value : 0.00; ;
                double askSize = (option.OrderBook.AskSize != null) ? option.OrderBook.AskSize.Value : 0.00; ;

                BlackScholes bs = new BlackScholes();
                double bidImpliedVolatility = 0.00;
                double askImpliedVolatility = 0.00;

                if (bid > 0.00 && bidSize > 0.00) bidImpliedVolatility = bs.GetImpliedVolatility(option.OptionInfo.Type, bid, spot, option.OptionInfo.Strike, riskFreeRate.Rate, timeToMaturity);
                if (ask > 0.00 && askSize > 0.00) askImpliedVolatility = bs.GetImpliedVolatility(option.OptionInfo.Type, ask, spot, option.OptionInfo.Strike, riskFreeRate.Rate, timeToMaturity);

                if (!(bidImpliedVolatility > 0.0000)) bidImpliedVolatility = 0.00;
                if (!(askImpliedVolatility > 0.0000)) askImpliedVolatility = 0.00;

                VolQuote volQuote = new VolQuote(bidSize, askSize, bidImpliedVolatility, askImpliedVolatility);
                volSurface.Update(option.OptionInfo.ExpiryDate, option.OptionInfo.Strike, option.OptionInfo.Type, volQuote);
            }

            return volSurface;
        }