Skip to content

Commit 38bfa3c

Browse files
committed
Add tests
1 parent ceba1cd commit 38bfa3c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Tests/Common/Securities/Futures/FuturesExpiryFunctionsTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,21 @@ public void EnergyExpiryDateFunction_WithDifferentDates_ShouldFollowContract(str
305305
}
306306
}
307307

308+
[Test]
309+
public void BankHolidaysAreRespected()
310+
{
311+
//Arrange
312+
var futureSymbol = GetFutureSymbol("6E", new DateTime(2025, 2, 1));
313+
var func = FuturesExpiryFunctions.FuturesExpiryFunction(GetFutureSymbol("6E"));
314+
// Expiry date is the second business day immediately preceding the third Wednesday of the contract month(usually Monday).
315+
// The third wednesday is the 19th so the expiry date should be monday 17th, but that day is a bank holiday
316+
// so the real expiry date is the 14th
317+
var expiryDate = func(futureSymbol.ID.Date);
318+
319+
//Assert
320+
Assert.AreEqual(new DateTime(2025, 2, 14), expiryDate.Date);
321+
}
322+
308323
// 25th is a sunday
309324
[TestCase(QuantConnect.Securities.Futures.Energy.MicroCrudeOilWTI, "20221001", "20220919")]
310325
[TestCase(QuantConnect.Securities.Futures.Energy.CrudeOilWTI, "20221001", "20220920")]

Tests/Common/Securities/MarketHoursDatabaseTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,29 @@ public void CorrectlyReadsCMEGroupFutureEarlyCloses(string futureTicker, string
172172
}
173173
}
174174

175+
[TestCase("BIO", Market.CME, true)]
176+
[TestCase("5YY", Market.CBOT, true)]
177+
[TestCase("6E", Market.CME, true)]
178+
[TestCase("BTC", Market.CME, true)]
179+
[TestCase("A8O", Market.NYMEX, true)]
180+
[TestCase("PAM", Market.NYMEX, true)]
181+
[TestCase("ZC", Market.CBOT, false)]
182+
[TestCase("LBR", Market.CME, false)]
183+
[TestCase("HE", Market.CME, false)]
184+
[TestCase("DY", Market.CME, false)]
185+
[TestCase("YO", Market.NYMEX, true)]
186+
public void CorrectlyReadsCMEGroupFutureBankHolidays(string futureTicker, string market, bool isBankHoliday)
187+
{
188+
var provider = MarketHoursDatabase.FromDataFolder();
189+
var ticker = OptionSymbol.MapToUnderlying(futureTicker, SecurityType.Future);
190+
var future = Symbol.Create(ticker, SecurityType.Future, market);
191+
192+
var futureEntry = provider.GetEntry(market, ticker, future.SecurityType);
193+
var bankHolidays = futureEntry.ExchangeHours.BankHolidays;
194+
var bankHoliday = new DateTime(2025, 11, 27);
195+
Assert.AreEqual(isBankHoliday, bankHolidays.Contains(bankHoliday));
196+
}
197+
175198
[TestCase("2YY", Market.CBOT, true)]
176199
[TestCase("TN", Market.CBOT, true)]
177200
[TestCase("6A", Market.CME, true)]

0 commit comments

Comments
 (0)