30 private IOptionData _optionData = OptionPriceModelResultData.Null;
115 public long Volume => _optionData.Volume;
160 _symbolProperties = symbolProperties;
161 _optionData =
new OptionUniverseData(contractData);
168 internal void SetOptionPriceModel(Func<OptionPriceModelResult> optionPriceModelEvaluator)
170 _optionData =
new OptionPriceModelResultData(optionPriceModelEvaluator, _optionData as OptionPriceModelResultData);
189 =>
Create(baseData.EndTime, security, underlying);
204 contract._optionData.SetUnderlying(underlying);
241 _optionData.Update(data);
245 _optionData.SetUnderlying(data);
249 #region Option Contract Data Handlers
251 private interface IOptionData
265 void Update(BaseData data);
267 void SetUnderlying(BaseData data);
273 private class OptionPriceModelResultData : IOptionData
277 private readonly Lazy<OptionPriceModelResult> _optionPriceModelResult;
281 private BaseData _underlying;
283 public decimal
LastPrice => _tradeBar?.Close ?? decimal.Zero;
289 public decimal
BidPrice => _quoteBar?.Bid?.Close ?? decimal.Zero;
291 public long BidSize => (long)(_quoteBar?.LastBidSize ?? 0L);
293 public decimal
AskPrice => _quoteBar?.Ask?.Close ?? decimal.Zero;
295 public long AskSize => (long)(_quoteBar?.LastAskSize ?? 0L);
297 public decimal
OpenInterest => _openInterest?.Value ?? decimal.Zero;
299 public decimal
TheoreticalPrice => _optionPriceModelResult.Value.TheoreticalPrice;
300 public decimal
ImpliedVolatility => _optionPriceModelResult.Value.ImpliedVolatility;
301 public Greeks Greeks => _optionPriceModelResult.Value.Greeks;
303 public OptionPriceModelResultData(Func<OptionPriceModelResult> optionPriceModelEvaluator,
304 OptionPriceModelResultData previousOptionData =
null)
306 _optionPriceModelResult =
new(optionPriceModelEvaluator, isThreadSafe:
false);
308 if (previousOptionData !=
null)
310 _tradeBar = previousOptionData._tradeBar;
311 _quoteBar = previousOptionData._quoteBar;
312 _openInterest = previousOptionData._openInterest;
313 _underlying = previousOptionData._underlying;
317 public void Update(BaseData data)
322 _tradeBar = tradeBar;
325 _quoteBar = quoteBar;
328 _openInterest = openInterest;
333 public void SetUnderlying(BaseData data)
342 private class OptionUniverseData : IOptionData
346 public decimal
LastPrice => _contractData.Close;
353 public long Volume => (long)_contractData.Volume;
355 public decimal
BidPrice => _contractData.Close;
359 public decimal
AskPrice => _contractData.Close;
363 public decimal
OpenInterest => _contractData.OpenInterest;
373 _contractData = contractData;
376 public void Update(BaseData data)
380 public void SetUnderlying(BaseData data)