public async Task <int> CreateOption(OptionTypeEnum optionType, int garageId, string name, string description) { var sql = ""; switch (optionType) { case OptionTypeEnum.Recommendation: sql = @"INSERT INTO [dbo].[OptionsRecommendation] VALUES(@Name, @Description, @GarageId)"; break; case OptionTypeEnum.Maintenance: sql = @"INSERT INTO [dbo].[OptionsMaintenance] VALUES(@Name, @Description, @GarageId)"; break; case OptionTypeEnum.Appointment: sql = @"INSERT INTO [dbo].[OptionsNextAppointment] VALUES(@Name, @Description, @GarageId)"; break; } using (var connection = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"))) { connection.Open(); var result = await connection.ExecuteAsync(sql, new { Name = name, Description = description, GarageId = garageId }, commandType : CommandType.Text); return(result); } }
public async Task <int> UpdateOption(OptionTypeEnum optionType, int id, string name, string description) { var sql = ""; switch (optionType) { case OptionTypeEnum.Recommendation: sql = @"UPDATE [dbo].[OptionsRecommendation] SET Name = @Name, Description = @Description WHERE Id = @Id"; break; case OptionTypeEnum.Maintenance: sql = @"UPDATE [dbo].[OptionsMaintenance] SET Name = @Name, Description = @Description WHERE Id = @Id"; break; case OptionTypeEnum.Appointment: sql = @"UPDATE [dbo].[OptionsNextAppointment] SET Name = @Name, Description = @Description WHERE Id = @Id"; break; } using (var connection = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"))) { connection.Open(); var result = await connection.ExecuteAsync(sql, new { Id = id, Name = name, Description = description }, commandType : CommandType.Text); return(result); } }
public async Task <IEnumerable <OptionModel> > GetOptions(OptionTypeEnum optionType, int garageId) { var sql = ""; switch (optionType) { case OptionTypeEnum.Recommendation: sql = "SELECT [Id],[Name],[Description] FROM [dbo].[OptionsRecommendation] WHERE GarageId = @garageId"; break; case OptionTypeEnum.Maintenance: sql = "SELECT [Id],[Name],[Description] FROM [dbo].[OptionsMaintenance] WHERE GarageId = @garageId"; break; case OptionTypeEnum.Appointment: sql = "SELECT [Id],[Name],[Description] FROM [dbo].[OptionsNextAppointment] WHERE GarageId = @garageId"; break; } using (var connection = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"))) { connection.Open(); var result = await connection.QueryAsync <OptionModel>(sql, new { GarageId = garageId }, commandType : CommandType.Text); return(result); } }
public async Task <int> DeleteOption(OptionTypeEnum optionType, int id) { var sql = ""; switch (optionType) { case OptionTypeEnum.Recommendation: sql = @"DELETE FROM [dbo].[OptionsRecommendation] WHERE Id = @Id"; break; case OptionTypeEnum.Maintenance: sql = @"DELETE FROM [dbo].[OptionsMaintenance] WHERE Id = @Id"; break; case OptionTypeEnum.Appointment: sql = @"DELETE FROM [dbo].[OptionsNextAppointment] WHERE Id = @Id"; break; } using (var connection = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"))) { connection.Open(); var result = await connection.ExecuteAsync(sql, new { Id = id }, commandType : CommandType.Text); return(result); } }
double IPricer.Price(BSParameter param) { double d1 = 0.0; double d2 = 0.0; double optionValue = 0.0; double S = param.Stock; double X = param.Strike; double r = param.InterestRate; double T = param.Day; double v = param.Vol; OptionTypeEnum optionType = param.OptionType; d1 = (Math.Log(S / X) + (r + v * v / 2.0) * T) / (v * Math.Sqrt(T)); d2 = d1 - v * Math.Sqrt(T); if (optionType == OptionTypeEnum.CallOption) { optionValue = S * CumulativeNormalDistributionFun(d1) - X * Math.Exp(-r * T) * CumulativeNormalDistributionFun(d2); } else if (optionType == OptionTypeEnum.PutOption) { optionValue = X * Math.Exp(-r * T) * CumulativeNormalDistributionFun(-d2) - S * CumulativeNormalDistributionFun(-d1); } PricingTerminated?.Invoke(this, null); return(optionValue); }
public OptionBase(XmlNode xmlNode) : base(xmlNode) { XmlNodeList optionTypeNodeList = xmlNode.SelectNodes("optionType"); if (optionTypeNodeList.Count > 1 ) { throw new Exception(); } foreach (XmlNode item in optionTypeNodeList) { if (item.Attributes["href"] != null || item.Attributes["id"] == null) { if (item.Attributes["id"] != null) { optionTypeIDRef = item.Attributes["id"].Name; OptionTypeEnum ob = OptionTypeEnum(); IDManager.SetID(optionTypeIDRef, ob); } else if (item.Attributes.ToString() == "href") { optionTypeIDRef = item.Attributes["href"].Name; } else { optionType = new OptionTypeEnum(item); } } } }
/// <summary> /// 计算隐含波动率 /// </summary> /// <param name="underlyingPrice"></param> /// <param name="strikePrice"></param> /// <param name="daysToMaturity"></param> /// <param name="interestRate"></param> /// <param name="marketPrice"></param> /// <param name="optionType"></param> /// <returns></returns> public static double CalculateImpliedVolatilityBisection(double underlyingPrice, double strikePrice, int daysToMaturity, double interestRate, double marketPrice, OptionTypeEnum optionType) { double lower = 0; double upper = 10; double impliedVolatility = 0; double impliedPrice = 0; while (Math.Abs(upper - lower) > 0.000000001) { impliedVolatility = (lower + upper) / 2; OptionPricingModelParams optionPricingModelParams = new OptionPricingModelParams(optionType, underlyingPrice, strikePrice, interestRate, impliedVolatility, daysToMaturity); OptionValue optionValue = OptionPricingModel.EuropeanBS(optionPricingModelParams); if(impliedPrice == optionValue.Price) { break; } impliedPrice = optionValue.Price; if (optionValue.Price >= marketPrice) { upper = impliedVolatility; } else { lower = impliedVolatility; } } return impliedVolatility; }
public EuropeanOptionProb(double?spotPrice, double?volatility, double?interestRate, double?maturity, double?strikePrice, OptionTypeEnum optionType) { SpotPrice = spotPrice ?? default(double); Volatility = volatility ?? default(double); InterestRate = interestRate ?? default(double); Maturity = maturity ?? default(double); StrikePrice = strikePrice ?? default(double); OptionType = optionType; }
public ImpliedVolatilityProb(double?spotPrice, double?interestRate, double?maturity, double?strikePrice, double?optionPremium, OptionTypeEnum optionType) { SpotPrice = spotPrice ?? default(double); InterestRate = interestRate ?? default(double); Maturity = maturity ?? default(double); StrikePrice = strikePrice ?? default(double); OptionPremium = optionPremium ?? default(double); OptionType = optionType; }
// Binomial Tree - American Options private static double BinomialTreePayoff(double s, double k, OptionTypeEnum optionType) { if (OptionTypeEnum.Call == optionType) { return(Math.Max(s - k, 0.0)); } else { return(Math.Max(k - s, 0.0)); } }
public static double BSPricing(EuropeanOptionProb prob) { double s = prob.SpotPrice; double k = prob.StrikePrice; double t = prob.Maturity; double r = prob.InterestRate; double sigma = prob.Volatility; OptionTypeEnum optionType = prob.OptionType; return(BSPricing(s, k, t, r, sigma, optionType)); }
public GeometricAsianOptionProb(double?spotPrice, double?volatility, double?interestRate, double?maturity, double?strikePrice, int?observationTime, OptionTypeEnum optionType) { SpotPrice = spotPrice ?? default(double); Volatility = volatility ?? default(double); InterestRate = interestRate ?? default(double); Maturity = maturity ?? default(double); StrikePrice = strikePrice ?? default(double); ObservationTime = observationTime ?? default(int); OptionType = optionType; }
public Option(string optionName, string explaination, OptionTypeEnum optionType, string shortArgument = "", string longArgument = "", string defaultValue = "", bool required = false, Action <Option> validationAction = null) { Name = optionName; Explaination = explaination.Trim(); Type = optionType; ShortArgument = shortArgument.Trim(); LongArgument = longArgument.Trim(); Required = required; DefaultValue = defaultValue.Trim(); ValidationAction = validationAction; }
public AmericanOptionProb(double?spotPrice, double?volatility, double?interestRate, double?maturity, double?strikePrice, int?stepsNum, OptionTypeEnum optionType) { SpotPrice = spotPrice ?? default(double); Volatility = volatility ?? default(double); InterestRate = interestRate ?? default(double); Maturity = maturity ?? default(double); StrikePrice = strikePrice ?? default(double); StepsNum = stepsNum ?? default(int); OptionType = optionType; }
public static double GeometricAsianOptionPricing(GeometricAsianOptionProb prob) { double s = prob.SpotPrice; double k = prob.StrikePrice; double r = prob.InterestRate; double t = prob.Maturity; double sigma = prob.Volatility; int n = prob.ObservationTime; OptionTypeEnum optionType = prob.OptionType; return(getGeoAsianOptionPrice(s, k, r, t, sigma, n, optionType)); }
public static double BinomialTreePricing(AmericanOptionProb prob) { double s = prob.SpotPrice; double k = prob.StrikePrice; double t = prob.Maturity; double r = prob.InterestRate; double sigma = prob.Volatility; OptionTypeEnum optionType = prob.OptionType; int n = prob.StepsNum; double dt = t / n; double u = Math.Exp(sigma * Math.Sqrt(dt)); double d = Math.Exp(-sigma * Math.Sqrt(dt)); double p = (Math.Exp(r * dt) - d) / (u - d); double[,] stockTree = new double[n + 1, n + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= i; j++) { stockTree[i, j] = s * Math.Pow(u, j) * Math.Pow(d, i - j); } } double[,] valueTree = new double[n + 1, n + 1]; for (int j = 0; j <= n; j++) { valueTree[n, j] = BinomialTreePayoff(stockTree[n, j], k, optionType); } for (int i = n - 1; i >= 0; i--) { for (int j = 0; j <= i; j++) { valueTree[i, j] = Math.Exp(-r * dt) * (p * valueTree[i + 1, j + 1] + (1 - p) * valueTree[i + 1, j]); if (optionType == OptionTypeEnum.Call) { valueTree[i, j] = Math.Max(stockTree[i, j] - k, valueTree[i, j]); } else { valueTree[i, j] = Math.Max(k - stockTree[i, j], valueTree[i, j]); } } } return(valueTree[0, 0]); }
public ArithmeticAsianOptionProb(double?spotPrice, double?volatility, double?interestRate, double?maturity, double?strikePrice, int?observationTime, OptionTypeEnum optionType, int?pathNumber, ControlVariateMethod variateMethod) { SpotPrice = spotPrice ?? default(double); Volatility = volatility ?? default(double); InterestRate = interestRate ?? default(double); Maturity = maturity ?? default(double); StrikePrice = strikePrice ?? default(double); ObservationTime = observationTime ?? default(int); OptionType = optionType; PathNumber = pathNumber ?? default(int); VariateMethod = variateMethod; }
public static double[] ArithmeticAsianOptionPricing(ArithmeticAsianOptionProb prob) { double s = prob.SpotPrice; double k = prob.StrikePrice; double r = prob.InterestRate; double t = prob.Maturity; double sigma = prob.Volatility; int n = prob.ObservationTime; OptionTypeEnum optionType = prob.OptionType; int pathNum = prob.PathNumber; ControlVariateMethod method = prob.VariateMethod; return(GetAAOPrice(s, k, t, r, sigma, optionType, method, pathNum, n)); }
public OptionPricingModelParams(OptionTypeEnum optionType, double underlyingPrice, double strikePrice, double interestRate, double volatility, double daysToMaturity) { this.optionType = optionType; this.underlyingPrice = underlyingPrice; this.strikePrice = strikePrice; this.interestRate = interestRate; this.volatility = volatility; if (GlobalValues.TimeMeasurementType == TimeMeasurementTypeEnum.交易日) { this.maturity = daysToMaturity / GlobalValues.TradingDaysPerYear; } else if (GlobalValues.TimeMeasurementType == TimeMeasurementTypeEnum.日历日) { this.maturity = daysToMaturity / GlobalValues.GeneralDaysPerYear; } }
public async Task <IEnumerable <OptionModel> > GetBaseOptions(OptionTypeEnum optionType, string language) { var sql = "SELECT [Id],[Name],[Description] FROM [dbo].[OptionsBase] WHERE OptionType = @optionType AND Language = @language"; using (var connection = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"))) { connection.Open(); var result = await connection.QueryAsync <OptionModel>(sql, new { OptionType = (int)optionType, Language = language.ToUpper() }, commandType : CommandType.Text); return(result); } }
public SysTrayOption(string optionName, string detail = "") { if (optionName.NullOrEmpty()) { throw new SysTrayOptionException("option name invalid"); } if (isServiceName(optionName)) { OptionType = OptionTypeEnum.Service; ServiceName = optionName; DisplayName = ServiceTools.ServiceNamesLookup[optionName]; CommandStr = ""; } else { OptionType = OptionTypeEnum.Command; ServiceName = ""; DisplayName = optionName; CommandStr = detail; } }
public static double ImpliedVolatilityCalculate(ImpliedVolatilityProb prob) { double s = prob.SpotPrice; double k = prob.StrikePrice; double t = prob.Maturity; double r = prob.InterestRate; double premium = prob.OptionPremium; OptionTypeEnum optionType = prob.OptionType; double sigmaHat = Math.Sqrt(2 * Math.Abs((Math.Log(s / k) + r * t) / t)); double tol = Double.MinValue; double sigma = sigmaHat; double sigmaDiff = 1; int n = 1, nmax = 100; while (sigmaDiff >= tol && n < nmax) { double increment = GetIncrement(s, k, t, r, sigma, premium, optionType); sigma = sigma - increment; sigmaDiff = Math.Abs(increment); n++; } return(sigma); }
private static double GetIncrement(double s, double k, double t, double r, double sigma, double premium, OptionTypeEnum optionType) { double vega = GetVega(s, k, t, r, sigma); double newOptionPremium = newOptionPremium = BSPricing(s, k, t, r, sigma, optionType); return((newOptionPremium - premium) / vega); }
public static double BSPricing(double s, double k, double t, double r, double sigma, OptionTypeEnum optionType) { double[] dValueArray = GetDValues(s, k, t, r, sigma, optionType); double d1 = dValueArray[0]; double d2 = dValueArray[1]; Normal normal = new Normal(); if (optionType == OptionTypeEnum.Call) { return(s * normal.CumulativeDistribution(d1) - k * Math.Exp(-r * t) * normal.CumulativeDistribution(d2)); } else { return(k * Math.Exp(-r * t) * normal.CumulativeDistribution(-d2) - s * normal.CumulativeDistribution(-d1)); } }
private static double[] GetAAOPrice(double s, double k, double t, double r, double sigma, OptionTypeEnum optionType, ControlVariateMethod method, int pathNum, int n) { const int seed = 11151; double Dt = t / n; double drift = Math.Exp((r - 0.5 * Math.Pow(sigma, 2)) * Dt); Normal normal = new Normal(); normal.RandomSource = new Random(seed); List <Double> arithPayoff = new List <Double>(); List <Double> geoPayoff = new List <Double>(); for (int i = 1; i <= pathNum; i++) { double growthFactor = drift * Math.Exp(sigma * Math.Sqrt(Dt) * normal.Sample()); List <Double> spath = new List <double>(); spath.Add(s * growthFactor); double logSpathSum = Math.Log(spath.ElementAt(0)); for (int j = 2; j <= n; j++) { growthFactor = drift * Math.Exp(sigma * Math.Sqrt(Dt) * normal.Sample()); double tmp = spath.ElementAt(spath.Count - 1) * growthFactor; spath.Add(tmp); logSpathSum += Math.Log(tmp); } double arithMean = GetMeanVarStd(spath)[0]; double geoMean = Math.Exp((1.0 / n) * logSpathSum); if (optionType == OptionTypeEnum.Call) { arithPayoff.Add(Math.Exp(-r * t) * Math.Max(arithMean - k, 0)); geoPayoff.Add(Math.Exp(-r * t) * Math.Max(geoMean - k, 0)); } else { arithPayoff.Add(Math.Exp(-r * t) * Math.Max(k - arithMean, 0)); geoPayoff.Add(Math.Exp(-r * t) * Math.Max(k - geoMean, 0)); } spath.Clear(); } double[] arithPayoffMvs = GetMeanVarStd(arithPayoff); double arithPayoffMean = arithPayoffMvs[0]; double arithPayoffVar = arithPayoffMvs[1]; double arithPayoffStd = arithPayoffMvs[2]; double[] geoPayoffMvs = GetMeanVarStd(geoPayoff); double geoPayoffMean = geoPayoffMvs[0]; double geoPayoffVar = geoPayoffMvs[1]; double geoPayoffStd = geoPayoffMvs[2]; List <double> pointMultiplyList = new List <double>(); for (int iter = 0; iter < arithPayoff.Count; iter++) { pointMultiplyList.Add(arithPayoff[iter] * geoPayoff[iter]); } double covXY = GetMeanVarStd(pointMultiplyList)[0] - arithPayoffMean * geoPayoffMean; double theta = covXY / geoPayoffVar; double geoPrice = getGeoAsianOptionPrice(s, k, r, t, sigma, n, optionType); List <double> controlVar = new List <double>(); for (int iter = 0; iter < arithPayoff.Count; iter++) { double tempVar = arithPayoff[iter] + theta * (geoPrice - geoPayoff[iter]); controlVar.Add(tempVar); } double[] controlVarMvs = GetMeanVarStd(controlVar); double controlVarMaen = controlVarMvs[0]; double controlVarVar = controlVarMvs[1]; double controlVarStd = controlVarMvs[2]; double lbound = 0; double ubound = 0; double[] results = new double[3]; if (method == ControlVariateMethod.None) { lbound = arithPayoffMean - (1.96 * arithPayoffStd) / Math.Sqrt(pathNum); ubound = arithPayoffMean + (1.96 * arithPayoffStd) / Math.Sqrt(pathNum); results[0] = lbound; results[1] = arithPayoffMean; results[2] = ubound; } else { lbound = controlVarMaen - (1.96 * controlVarStd) / Math.Sqrt(pathNum); ubound = controlVarMaen + (1.96 * controlVarStd) / Math.Sqrt(pathNum); results[0] = lbound; results[1] = controlVarMaen; results[2] = ubound; } return(results); }
// Geometric Asian Options private static double getGeoAsianOptionPrice(double s, double k, double r, double t, double sigma, int n, OptionTypeEnum optionType) { double sigsqT = Math.Pow(sigma, 2) * t * (n + 1) * (2 * n + 1) / (6 * n * n); double muT = 0.5 * sigsqT + (r - 0.5 * sigma * sigma) * t * (n + 1) / (2 * n); double d1 = (Math.Log(s / k) + (muT + 0.5 * sigsqT)) / (Math.Sqrt(sigsqT)); double d2 = d1 - Math.Sqrt(sigsqT); Normal normal = new Normal(); if (optionType == OptionTypeEnum.Call) { return(Math.Exp(-r * t) * (s * Math.Exp(muT) * normal.CumulativeDistribution(d1) - k * normal.CumulativeDistribution(d2))); } else { return(Math.Exp(-r * t) * (k * normal.CumulativeDistribution(-d2) - s * Math.Exp(muT) * normal.CumulativeDistribution(-d1))); } }
// Black-Scholes Formula - European Options private static double[] GetDValues(double s, double k, double t, double r, double sigma, OptionTypeEnum optionType) { double[] dValueArray = new double[2]; double dHead = (Math.Log(s / k) + r * t) / (sigma * Math.Sqrt(t)); double dTail = sigma * Math.Sqrt(t) / 2; double d1 = dHead + dTail; double d2 = dHead - dTail; dValueArray[0] = d1; dValueArray[1] = d2; return(dValueArray); }
/// <summary> /// 计算隐含波动率(牛顿方法) /// </summary> /// <param name="underlyingPrice"></param> /// <param name="strikePrice"></param> /// <param name="daysToMaturity"></param> /// <param name="interestRate"></param> /// <param name="marketPrice"></param> /// <param name="optionType"></param> /// <returns></returns> public static double CalculateImpliedVolatilityNewton(double underlyingPrice, double strikePrice, int daysToMaturity, double interestRate, double marketPrice, OptionTypeEnum optionType) { double maturity = 0; if (GlobalValues.TimeMeasurementType == TimeMeasurementTypeEnum.交易日) { maturity = (double)daysToMaturity / GlobalValues.TradingDaysPerYear; } else if (GlobalValues.TimeMeasurementType == TimeMeasurementTypeEnum.日历日) { maturity = (double)daysToMaturity / GlobalValues.GeneralDaysPerYear; } double sigmahat = Math.Sqrt(2 * Math.Abs((Math.Log(underlyingPrice / strikePrice) + interestRate * maturity) / maturity)); double tol = 0.00000001; double sigma = sigmahat; double sigmadiff = 1; int index = 1; int indexMax = 100; while (sigmadiff >= tol && index < indexMax) { double d1 = (Math.Log(underlyingPrice / strikePrice) + (interestRate + 0.5 * sigma * sigma) * (maturity)) / (sigma * Math.Sqrt(maturity)); double d2 = d1 - sigma * Math.Sqrt(maturity); double optionImpliedPrice = 0; double optionImpliedVega = 0; if (optionType == OptionTypeEnum.call) { optionImpliedPrice = underlyingPrice * Math.Exp(-interestRate * maturity) * normdist(d1) - normdist(d2) * strikePrice * Math.Exp(-interestRate * maturity); optionImpliedVega = (Math.Exp(-d1 * d1 / 2) / Math.Sqrt(2 * Math.PI)) * Math.Exp(-interestRate * maturity) * underlyingPrice * Math.Sqrt(maturity); } else if (optionType == OptionTypeEnum.put) { optionImpliedPrice = -underlyingPrice * Math.Exp(-interestRate * maturity) * normdist(-d1) + normdist(-d2) * strikePrice * Math.Exp(-interestRate * maturity); optionImpliedVega = (Math.Exp(-d1 * d1 / 2) / Math.Sqrt(2 * Math.PI)) * Math.Exp(-interestRate * maturity) * underlyingPrice * Math.Sqrt(maturity); } double increment = (optionImpliedPrice - marketPrice) / optionImpliedVega; sigma = sigma - increment; index++; sigmadiff = Math.Abs(increment); } return sigma; }
/// <summary> /// Initializes a new instance of the <see cref="EquityOption" /> class. /// </summary> /// <param name="startDate">The start date of the instrument. This is normally synonymous with the trade-date. (required).</param> /// <param name="optionMaturityDate">The maturity date of the option. (required).</param> /// <param name="optionSettlementDate">The settlement date of the option. (required).</param> /// <param name="deliveryType">The available values are: Cash, Physical (required).</param> /// <param name="optionType">The available values are: None, Call, Put (required).</param> /// <param name="strike">The strike of the option. (required).</param> /// <param name="domCcy">The domestic currency of the instrument. (required).</param> /// <param name="underlyingIdentifier">The available values are: LusidInstrumentId, Isin, Sedol, Cusip, ClientInternal, Figi, RIC, QuotePermId, REDCode, BBGId, ICECode (required).</param> /// <param name="code">The reset code of the option. (required).</param> public EquityOption(DateTimeOffset?startDate = default(DateTimeOffset?), DateTimeOffset?optionMaturityDate = default(DateTimeOffset?), DateTimeOffset?optionSettlementDate = default(DateTimeOffset?), DeliveryTypeEnum deliveryType = default(DeliveryTypeEnum), OptionTypeEnum optionType = default(OptionTypeEnum), decimal?strike = default(decimal?), string domCcy = default(string), UnderlyingIdentifierEnum underlyingIdentifier = default(UnderlyingIdentifierEnum), string code = default(string), InstrumentTypeEnum instrumentType = default(InstrumentTypeEnum)) : base(instrumentType) { // to ensure "startDate" is required (not null) if (startDate == null) { throw new InvalidDataException("startDate is a required property for EquityOption and cannot be null"); } else { this.StartDate = startDate; } // to ensure "optionMaturityDate" is required (not null) if (optionMaturityDate == null) { throw new InvalidDataException("optionMaturityDate is a required property for EquityOption and cannot be null"); } else { this.OptionMaturityDate = optionMaturityDate; } // to ensure "optionSettlementDate" is required (not null) if (optionSettlementDate == null) { throw new InvalidDataException("optionSettlementDate is a required property for EquityOption and cannot be null"); } else { this.OptionSettlementDate = optionSettlementDate; } // to ensure "deliveryType" is required (not null) if (deliveryType == null) { throw new InvalidDataException("deliveryType is a required property for EquityOption and cannot be null"); } else { this.DeliveryType = deliveryType; } // to ensure "optionType" is required (not null) if (optionType == null) { throw new InvalidDataException("optionType is a required property for EquityOption and cannot be null"); } else { this.OptionType = optionType; } // to ensure "strike" is required (not null) if (strike == null) { throw new InvalidDataException("strike is a required property for EquityOption and cannot be null"); } else { this.Strike = strike; } // to ensure "domCcy" is required (not null) if (domCcy == null) { throw new InvalidDataException("domCcy is a required property for EquityOption and cannot be null"); } else { this.DomCcy = domCcy; } // to ensure "underlyingIdentifier" is required (not null) if (underlyingIdentifier == null) { throw new InvalidDataException("underlyingIdentifier is a required property for EquityOption and cannot be null"); } else { this.UnderlyingIdentifier = underlyingIdentifier; } // to ensure "code" is required (not null) if (code == null) { throw new InvalidDataException("code is a required property for EquityOption and cannot be null"); } else { this.Code = code; } }