Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ private bool GenerateUniverses(Dictionary<Symbol, List<Symbol>> symbols)

if (underlyingSymbol is not null)
{
var underlyingEntryGenerated = TryGenerateAndWriteUnderlyingLine(underlyingSymbol, underlyingMarketHoursEntry, writer,
var underlyingEntryGenerated = TryGenerateAndWriteUnderlyingLine(underlyingSymbol, underlyingMarketHoursEntry, writer,
out underlyingEntry, out underlyingHistory);
// Underlying not mapped or missing data, so just skip them
if (!underlyingEntryGenerated)
{
Interlocked.Increment(ref underlyingsWithMissingData);
Log.Error($"DerivativeUniverseGenerator.GenerateUniverses(): " +
$"Underlying data missing for {underlyingSymbol} on {_processingDate:yyyy/MM/dd}, universe file will not be generated.");
UpdateEta(ref symbolCounter, totalContracts, start, contractsSymbols.Count);
return;
}
// Underlying not mapped or missing data, so just skip them. Unless FOPs which don't have greeks, don't need the underlying data
if (!underlyingEntryGenerated && NeedsUnderlyingData())
{
Interlocked.Increment(ref underlyingsWithMissingData);
Log.Error($"DerivativeUniverseGenerator.GenerateUniverses(): " +
$"Underlying data missing for {underlyingSymbol} on {_processingDate:yyyy/MM/dd}, universe file will not be generated.");
UpdateEta(ref symbolCounter, totalContracts, start, contractsSymbols.Count);
return;
}
}

var derivativeEntries = GenerateDerivativeEntries(canonicalSymbol, contractsSymbols, derivativeMarketHoursEntry,
Expand Down Expand Up @@ -389,5 +389,12 @@ protected virtual IDerivativeUniverseFileEntry GenerateDerivativeEntry(Symbol sy
/// Factory method to create an instance of <see cref="IDerivativeUniverseFileEntry"/> for the given <paramref name="symbol"/>
/// </summary>
protected abstract IDerivativeUniverseFileEntry CreateUniverseEntry(Symbol symbol);

/// <summary>
/// Whether the derivative lines generation requires underlying data.
/// If true and the underlying entry has no market data, the derivative entries will be skipped.
/// </summary>
/// <returns></returns>
protected abstract bool NeedsUnderlyingData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ protected override Dictionary<Symbol, List<Symbol>> GetSymbols()
var symbolChainProvider = new FutureChainSymbolProvider(_dataCacheProvider, _processingDate, _securityType, _market, _dataFolderRoot);
return symbolChainProvider.GetSymbols();
}

protected override bool NeedsUnderlyingData()
{
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public OptionUniverseEntry(Symbol symbol)
{
// Options universes contain a line for the underlying: we don't need greeks for it.
// Future options don't have greeks either.
if (HasGreeks(symbol))
if (HasGreeks(symbol.SecurityType))
{
var mirrorOptionSymbol = OptionsUniverseGeneratorUtils.GetMirrorOptionSymbol(symbol);
_greeksIndicators = new GreeksIndicators(symbol, mirrorOptionSymbol);
Expand Down Expand Up @@ -104,9 +104,9 @@ public void SetGreeksIndicators(GreeksIndicators greeksIndicators)
/// <summary>
/// Returns true if the symbol has greeks.
/// </summary>
public static bool HasGreeks(Symbol symbol)
public static bool HasGreeks(SecurityType securityType)
{
return symbol.SecurityType.IsOption() && symbol.SecurityType != SecurityType.FutureOption;
return securityType.IsOption() && securityType != SecurityType.FutureOption;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ protected override IDerivativeUniverseFileEntry CreateUniverseEntry(Symbol symbo
return new OptionUniverseEntry(symbol);
}

protected override bool NeedsUnderlyingData()
{
// We don't need underlying data for future options, since they don't have greeks, so no need for underlying data for calculation
return OptionUniverseEntry.HasGreeks(_securityType);
}

/// <summary>
/// Adds a request for the mirror option symbol to the base list of requests.
/// </summary>
Expand All @@ -79,7 +85,7 @@ protected override IEnumerable<IDerivativeUniverseFileEntry> GenerateDerivativeE
{
var generatedEntries = base.GenerateDerivativeEntries(canonicalSymbol, symbols, marketHoursEntry, underlyingHistory, underlyingEntry);

if (!OptionUniverseEntry.HasGreeks(canonicalSymbol))
if (!OptionUniverseEntry.HasGreeks(canonicalSymbol.SecurityType))
{
return generatedEntries;
}
Expand Down
Loading