29 private IOptionData _optionData = OptionPriceModelResultData.Null;
111 public long Volume => _optionData.Volume;
156 _symbolProperties = symbolProperties;
157 _optionData =
new OptionUniverseData(contractData);
164 internal void SetOptionPriceModel(Func<OptionPriceModelResult> optionPriceModelEvaluator)
166 _optionData =
new OptionPriceModelResultData(optionPriceModelEvaluator, _optionData as OptionPriceModelResultData);
185 =>
Create(baseData.EndTime, security, underlying);
200 contract._optionData.SetUnderlying(underlying);
237 _optionData.Update(data);
241 _optionData.SetUnderlying(data);
245 #region Option Contract Data Handlers
247 private interface IOptionData
261 void Update(BaseData data);
263 void SetUnderlying(BaseData data);
269 private class OptionPriceModelResultData : IOptionData
273 private readonly Lazy<OptionPriceModelResult> _optionPriceModelResult;
277 private BaseData _underlying;
279 public decimal
LastPrice => _tradeBar?.Close ?? decimal.Zero;
285 public decimal
BidPrice => _quoteBar?.Bid?.Close ?? decimal.Zero;
287 public long BidSize => (long)(_quoteBar?.LastBidSize ?? 0L);
289 public decimal
AskPrice => _quoteBar?.Ask?.Close ?? decimal.Zero;
291 public long AskSize => (long)(_quoteBar?.LastAskSize ?? 0L);
293 public decimal
OpenInterest => _openInterest?.Value ?? decimal.Zero;
295 public decimal
TheoreticalPrice => _optionPriceModelResult.Value.TheoreticalPrice;
296 public decimal
ImpliedVolatility => _optionPriceModelResult.Value.ImpliedVolatility;
297 public Greeks Greeks => _optionPriceModelResult.Value.Greeks;
299 public OptionPriceModelResultData(Func<OptionPriceModelResult> optionPriceModelEvaluator,
300 OptionPriceModelResultData previousOptionData =
null)
302 _optionPriceModelResult =
new(optionPriceModelEvaluator, isThreadSafe:
false);
304 if (previousOptionData !=
null)
306 _tradeBar = previousOptionData._tradeBar;
307 _quoteBar = previousOptionData._quoteBar;
308 _openInterest = previousOptionData._openInterest;
309 _underlying = previousOptionData._underlying;
313 public void Update(BaseData data)
318 _tradeBar = tradeBar;
321 _quoteBar = quoteBar;
324 _openInterest = openInterest;
329 public void SetUnderlying(BaseData data)
338 private class OptionUniverseData : IOptionData
342 public decimal
LastPrice => _contractData.Close;
349 public long Volume => (long)_contractData.Volume;
351 public decimal
BidPrice => _contractData.Close;
355 public decimal
AskPrice => _contractData.Close;
359 public decimal
OpenInterest => _contractData.OpenInterest;
369 _contractData = contractData;
372 public void Update(BaseData data)
376 public void SetUnderlying(BaseData data)