Skip to content
Open
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
17 changes: 17 additions & 0 deletions Common/Securities/Future/Futures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,18 @@ public static class Financials
/// </summary>
/// <returns>The symbol</returns>
public const string MicroY5TreasuryBond = "5YY";

/// <summary>
/// Micro Ultra 10-Year U.S. Treasury Note Futures
/// </summary>
/// <returns>The symbol</returns>
public const string MicroUltraTenYearUSTreasuryNote = "MTN";

/// <summary>
/// Micro Ultra U.S. Treasury Bond Futures
/// </summary>
/// <returns>The symbol</returns>
public const string MicroUltraUSTreasuryBond = "MWN";
}

/// <summary>
Expand Down Expand Up @@ -1794,6 +1806,11 @@ public static class Metals
/// Silver 5000 Oz Futures
/// </summary>
public const string Silver5000Oz = "ZI";

/// <summary>
/// 1-Ounce Gold Futures
/// </summary>
public const string OneOunceGold = "1OZ";
}

/// <summary>
Expand Down
60 changes: 60 additions & 0 deletions Common/Securities/Future/FuturesExpiryFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ public static Func<DateTime, DateTime> FuturesExpiryFunction(Symbol symbol)
return FuturesExpiryUtilityFunctions.NthLastBusinessDay(time,3, holidays);
})
},
// 1-Ounce Gold (1OZ): https://www.cmegroup.com/markets/metals/precious/1-ounce-gold.contractSpecs.html
{Symbol.Create(Futures.Metals.OneOunceGold, SecurityType.Future, Market.COMEX), (time =>
{
var market = Market.COMEX;
var symbol = Futures.Metals.OneOunceGold;
var holidays = FuturesExpiryUtilityFunctions.GetExpirationHolidays(market, symbol);
// Bi-monthly contracts (Feb/2, Apr/4, Jun/6, Aug/8, Oct/10, Dec/12 cycle)
while (!FutureExpirationCycles.GJMQVZ.Contains(time.Month))
{
time = time.AddMonths(1);
}

// This contract is cash settled, so it stops trading before the contract month even starts.
// Trading terminates on the third last business day of the month prior to the contract month.
var previousMonth = time.AddMonths(-1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this returns a date in the month before the contract month, 1OZ also needs registering in FuturesExpiryUtilityFunctions.ExpiriesPriorMonth — that's the companion half of the HH pattern you followed (HH is there at line 414).

Without it, SymbolRepresentation.GenerateFutureTicker renders the Feb-2026 contract as 1OZ28F26 instead of 1OZ28G26 (I confirmed this by test), and LeanData paths plus FutureUniverse.ToCsv record the wrong contract month. Add to that dictionary:

{ Futures.Metals.OneOunceGold, 1 },

Worth a [TestCase] in SymbolRepresentationTests.GenerateFutureTickerExpiringInPreviousMonth alongside the existing CL/HH rows.

return FuturesExpiryUtilityFunctions.NthLastBusinessDay(previousMonth, 3, holidays);
})
},
// Silver (SI): http://www.cmegroup.com/trading/metals/precious/silver_contract_specifications.html
{Symbol.Create(Futures.Metals.Silver, SecurityType.Future, Market.COMEX), (time =>
{
Expand Down Expand Up @@ -1674,6 +1692,48 @@ public static Func<DateTime, DateTime> FuturesExpiryFunction(Symbol symbol)
return FuturesExpiryUtilityFunctions.NthLastBusinessDay(time, 8, holidays);
})
},
// Micro Ultra 10-Year U.S. Treasury Note (MTN): https://www.cmegroup.com/markets/interest-rates/us-treasury/micro-ultra-10-year-us-treasury-note.contractSpecs.html
{Symbol.Create(Futures.Financials.MicroUltraTenYearUSTreasuryNote, SecurityType.Future, Market.CBOT), (time =>
{
var market = Market.CBOT;
var symbol = Futures.Financials.MicroUltraTenYearUSTreasuryNote;
var holidays = FuturesExpiryUtilityFunctions.GetExpirationHolidays(market, symbol);

// Quarterly contracts (Mar, Jun, Sep, Dec), the same cycle as the Ultra 10-Year (TN)
while (!FutureExpirationCycles.HMUZ.Contains(time.Month))
{
time = time.AddMonths(1);
}

// This contract is cash settled against TN instead of delivering notes, so it stops
// trading earlier than TN does.
// Trading terminates at 2:00 p.m. CT 2 business days before the first delivery day
// of the contract month. The first delivery day is the first business day of that month.
var firstDeliveryDay = FuturesExpiryUtilityFunctions.NthBusinessDay(time, 1, holidays);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the 1OZ note: this lands in the previous month, so MTN needs an ExpiriesPriorMonth entry too, otherwise the Mar-2025 contract renders as MTN27G25 instead of MTN27H25.

{ Futures.Financials.MicroUltraTenYearUSTreasuryNote, 1 },

return FuturesExpiryUtilityFunctions.AddBusinessDays(firstDeliveryDay, -2, holidays).AddHours(19);
})
},
// Micro Ultra U.S. Treasury Bond (MWN): https://www.cmegroup.com/markets/interest-rates/us-treasury/micro-ultra-us-treasury-bond.contractSpecs.html
{Symbol.Create(Futures.Financials.MicroUltraUSTreasuryBond, SecurityType.Future, Market.CBOT), (time =>
{
var market = Market.CBOT;
var symbol = Futures.Financials.MicroUltraUSTreasuryBond;
var holidays = FuturesExpiryUtilityFunctions.GetExpirationHolidays(market, symbol);

// Quarterly contracts (Mar, Jun, Sep, Dec), the same cycle as the Ultra Bond (UB)
while (!FutureExpirationCycles.HMUZ.Contains(time.Month))
{
time = time.AddMonths(1);
}

// This contract is cash settled against UB instead of delivering bonds, so it stops
// trading earlier than UB does.
// Trading terminates at 2:00 p.m. CT 2 business days before the first delivery day
// of the contract month. The first delivery day is the first business day of that month.
var firstDeliveryDay = FuturesExpiryUtilityFunctions.NthBusinessDay(time, 1, holidays);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MWN needs the same ExpiriesPriorMonth entry — currently the Mar-2025 contract renders as MWN27G25 instead of MWN27H25.

{ Futures.Financials.MicroUltraUSTreasuryBond, 1 },

return FuturesExpiryUtilityFunctions.AddBusinessDays(firstDeliveryDay, -2, holidays).AddHours(19);
})
},
// Energy group
// Propane Non LDH Mont Belvieu (1S): https://www.cmegroup.com/trading/energy/petrochemicals/propane-non-ldh-mt-belvieu-opis-balmo-swap_contract_specifications.html
{Symbol.Create(Futures.Energy.PropaneNonLDHMontBelvieu, SecurityType.Future, Market.NYMEX), (time =>
Expand Down
3 changes: 3 additions & 0 deletions Common/Securities/Future/FuturesExpiryUtilityFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ public static bool IsFutureContractExpired(Symbol symbol, DateTime currentUtcTim
{ Futures.Energy.NaturalGasHenryHubPenultimateFinancial, 1 },
{ Futures.Energy.WTIHoustonArgusVsWTITradeMonth, 1 },
{ Futures.Energy.WTIHoustonCrudeOil, 1 },
{ Futures.Financials.MicroUltraTenYearUSTreasuryNote, 1 },
{ Futures.Financials.MicroUltraUSTreasuryBond, 1 },
{ Futures.Metals.OneOunceGold, 1 },
{ Futures.Softs.Sugar11, 1 },
{ Futures.Softs.Sugar11CME, 1 }
};
Expand Down
4 changes: 4 additions & 0 deletions Data/future/cbot/margins/MTN.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# we don't have historical information for this symbol
# CME CBOT outright maintenance margin, 09/2026-12/2026; initial = 110% of maintenance
date,initial,maintenance
19900101,281,255
4 changes: 4 additions & 0 deletions Data/future/cbot/margins/MWN.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# we don't have historical information for this symbol
# CME CBOT outright maintenance margin, 09/2026-12/2026; initial = 110% of maintenance
date,initial,maintenance
19900101,567,515
4 changes: 4 additions & 0 deletions Data/future/comex/margins/1OZ.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# we don't have historical information for this symbol
# CME COMEX outright maintenance margin, 10/2026 front month; initial = 110% of maintenance
date,initial,maintenance
19900101,242,220
Loading
Loading