Hi,

Is there a guideline to add a new futures market for local backtesting? In my case I'm trying to add Shanghai Futures Exchange (market/exchange name “SHFE”), and the underlying ticker is “ag” (silver). What I have done:

  1. Add SHFE field and its key/value pair in Market.cs.
public const string SHFE = "shfe";
private static readonly IEnumerable<Tuple<string, int>> HardcodedMarkets = new List<Tuple<string, int>>
        {

			...
            Tuple.Create(SHFE, 555),
            ...
        }

2. Add SHFE field in Exchange.cs

public static Exchange SHFE { get; }
        = new("SHFE", "SHFE", "Shanghai Futures Exchange", "shfe", SecurityType.Future);

3. Add code in Global.GetPrimaryExchange method so it returns the correct SHFE exchange

else if (securityType == SecurityType.Future || securityType == SecurityType.FutureOption)
{
    switch (exchange.LazyToUpper())
    {
        ...
        case "SHFE":
            return Exchange.SHFE;
        ...
    }
}

4. Make sure the symbol properties and market hours for “ag” are added, also the expiry calculation setup in my TestAlgorithm.Initialize:

MarketHoursDatabase.SetEntry(Market.SHFE, "es", SecurityType.Future, hours);

var symProps = Securities.SymbolProperties("Argent", Currencies.CNH, 10, 1, 1, "");
SymbolPropertiesDatabase.SetEntry(Market.SHFE, "ag", SecurityType.Future, symProps);

Securities.Future.FuturesExpiryFunctions.FuturesExpiryDictionary[Symbol.Create("ag", SecurityType.Future, Market.SHFE)] = time => Securities.Future.FuturesExpiryUtilityFunctions.NthLastBusinessDay(time,3);

5. Organise the minute data including trade/quote/open_interest in zip files and put them in the folder defined in config.json/data-folder. The final folder structure follows the engine's rules: data/future/shfe/minute/ag.

6. Put mapping files and factor files in data/future/shfe/map_files/ag.csv and data/future/shfe/factor_files /ag.csv respectively, and in the mapping files I have done the symbol mappings like:

18991230,ag,SHFE
20130831,ag vmrhkn2nn1zl,SHFE,1
20130915,ag vmrhkn2nn1zl,SHFE,2
20130919,ag vmrhkn2nn1zl,SHFE,0

Since I'm not trading it so I didn't change the fee model. After the above, I could get the future contract list: 

public override void Initialize() {
    SetStartDate(2013, 10, 6);
    SetEndDate(2013, 10, 8);
    SetCash(1000000);
    ... MHDB/SPDB initialization code
    var ag = AddFuture("ag", Resolution.Minute, Market.SHFE);
    var cs = FutureChainProvider.GetFutureContractList(ag.Symbol, new System.DateTime(2013, 10, 6));
    foreach(var c in cs) {
        Log($"{c}: {c.ID.Date}");  // Correctly lists the symbol as well as the expiry date
    }
}
public override void OnData(Slice slice) {
    Log($"{Time}");
}

But TestAlgorithm.OnData doesn't get called - there is no output at all. What else I should do to add a new futures market?