diff --git a/DataProcessing/config.json b/DataProcessing/config.json
index 17a07ca..39ad385 100644
--- a/DataProcessing/config.json
+++ b/DataProcessing/config.json
@@ -1,5 +1,5 @@
{
"data-folder": "../../../../Lean/Data/",
"history-provider": [ "SubscriptionDataReaderHistoryProvider", "IndexHistoryProvider" ],
- "symbols": []
+ "universe-generation-symbols": []
}
\ No newline at end of file
diff --git a/Lean.DataSource.DerivativeUniverseGenerator/ChainSymbolProvider.cs b/Lean.DataSource.DerivativeUniverseGenerator/ChainSymbolProvider.cs
index 93036d9..dd3fd96 100644
--- a/Lean.DataSource.DerivativeUniverseGenerator/ChainSymbolProvider.cs
+++ b/Lean.DataSource.DerivativeUniverseGenerator/ChainSymbolProvider.cs
@@ -60,7 +60,7 @@ public ChainSymbolProvider(IDataCacheProvider dataCacheProvider, DateTime proces
///
/// Gets all the available symbols keyed by the canonical symbol from the available price data in the data folder.
///
- public Dictionary> GetSymbols()
+ public virtual Dictionary> GetSymbols()
{
var result = new Dictionary>();
diff --git a/Lean.DataSource.FuturesUniverseGenerator/FutureChainSymbolProvider.cs b/Lean.DataSource.FuturesUniverseGenerator/FutureChainSymbolProvider.cs
index e620e03..a7a9191 100644
--- a/Lean.DataSource.FuturesUniverseGenerator/FutureChainSymbolProvider.cs
+++ b/Lean.DataSource.FuturesUniverseGenerator/FutureChainSymbolProvider.cs
@@ -13,8 +13,12 @@
* limitations under the License.
*/
+using QuantConnect.Configuration;
using QuantConnect.DataSource.DerivativeUniverseGenerator;
using QuantConnect.Interfaces;
+using QuantConnect.Securities;
+using QuantConnect.Securities.Future;
+using QuantConnect.Util;
using System;
using System.Collections.Generic;
using System.IO;
@@ -27,6 +31,9 @@ namespace QuantConnect.DataSource.FuturesUniverseGenerator
///
public class FutureChainSymbolProvider : ChainSymbolProvider
{
+ private readonly IFutureChainProvider _futuresChainProvider;
+ private readonly string _market;
+
///
/// Initializes a new instance of the class
///
@@ -34,6 +41,57 @@ public FutureChainSymbolProvider(IDataCacheProvider dataCacheProvider, DateTime
string market, string dataFolderRoot)
: base(dataCacheProvider, processingDate, securityType, market, dataFolderRoot)
{
+ _market = market;
+
+ if (Config.TryGetValue("futures-chain-provider", out var futuresChainProviderStr) &&
+ !string.IsNullOrEmpty(futuresChainProviderStr))
+ {
+ _futuresChainProvider = Composer.Instance.GetExportedValueByTypeName(futuresChainProviderStr);
+ }
+ }
+
+ ///
+ /// Gets all the available symbols keyed by the canonical symbol from the available price data in the data folder.
+ ///
+ public override Dictionary> GetSymbols()
+ {
+ if (_futuresChainProvider == null)
+ {
+ return base.GetSymbols();
+ }
+
+ var chains = FuturesExpiryFunctions.FuturesExpiryDictionary.Keys
+ .Where(symbol => symbol.ID.Market == _market)
+ .Select(symbol =>
+ {
+ var futureChain = _futuresChainProvider.GetFutureContractList(symbol, _processingDate)?.ToList();
+ return KeyValuePair.Create(symbol, futureChain);
+ })
+ .ToList();
+
+ if (chains.Any(kvp => kvp.Value == null))
+ {
+ // The custom chain provider failed for some symbols, fallback to the default chain provider for those
+ var baseSymbols = base.GetSymbols();
+ if (chains.All(kvp => kvp.Value == null))
+ {
+ return baseSymbols;
+ }
+
+ return chains
+ .Select(kvp =>
+ {
+ if (kvp.Value == null && baseSymbols.TryGetValue(kvp.Key, out var chain))
+ {
+ return KeyValuePair.Create(kvp.Key, chain);
+ }
+ return kvp;
+ })
+ .Where(kvp => kvp.Value != null)
+ .ToDictionary();
+ }
+
+ return new Dictionary>(chains);
}
protected override IEnumerable GetZipFileNames(DateTime date, Resolution resolution)
diff --git a/Lean.DataSource.FuturesUniverseGenerator/config.json b/Lean.DataSource.FuturesUniverseGenerator/config.json
index 11f3ccf..d0b385a 100644
--- a/Lean.DataSource.FuturesUniverseGenerator/config.json
+++ b/Lean.DataSource.FuturesUniverseGenerator/config.json
@@ -1,5 +1,5 @@
{
"data-folder": "../../../Data/",
"history-provider": [ "SubscriptionDataReaderHistoryProvider" ],
- "symbols": []
+ "universe-generation-symbols": []
}
\ No newline at end of file
diff --git a/Lean.DataSource.OptionsUniverseGenerator/config.json b/Lean.DataSource.OptionsUniverseGenerator/config.json
index cd23ba6..ceab1ef 100644
--- a/Lean.DataSource.OptionsUniverseGenerator/config.json
+++ b/Lean.DataSource.OptionsUniverseGenerator/config.json
@@ -1,5 +1,5 @@
{
"data-folder": "../../../Data/",
"history-provider": [ "SubscriptionDataReaderHistoryProvider", "IndexHistoryProvider" ],
- "symbols": []
+ "universe-generation-symbols": []
}
\ No newline at end of file