Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CME Ether futures to symbols database #6884

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
8 changes: 4 additions & 4 deletions Common/Orders/Fees/InteractiveBrokersFeeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private static CashAmount HongKongFutureFees(Security security)
{ "MYM", 0.25m }, { "M2K", 0.25m }, { "MES", 0.25m }, { "MNQ", 0.25m }, { "2YY", 0.25m }, { "5YY", 0.25m }, { "10Y", 0.25m },
{ "30Y", 0.25m }, { "MCL", 0.25m }, { "MGC", 0.25m }, { "SIL", 0.25m },
// Cryptocurrency Futures
{ "BTC", 5m }, { "MIB", 2.25m }, { "MBT", 2.25m }, { "MET", 0.20m }, { "MRB", 0.20m },
{ "BTC", 5m }, { "MBT", 2.25m }, { "ETH", 3m }, { "MET", 0.20m },
// E-mini FX (currencies) Futures
{ "E7", 0.50m }, { "J7", 0.50m },
// Micro E-mini FX (currencies) Futures
Expand All @@ -342,7 +342,7 @@ private static CashAmount HongKongFutureFees(Security security)
{ "MYM", 0.25m }, { "M2K", 0.25m }, { "MES", 0.25m }, { "MNQ", 0.25m }, { "2YY", 0.25m }, { "5YY", 0.25m }, { "10Y", 0.25m },
{ "30Y", 0.25m }, { "MCL", 0.25m }, { "MGC", 0.25m }, { "SIL", 0.25m },
// Cryptocurrency Future Options
{ "BTC", 5m }, { "MIB", 1.25m }, { "MBT", 1.25m }, { "MET", 0.10m }, { "MRB", 0.10m },
{ "BTC", 5m }, { "MBT", 1.25m }, { "ETH", 3m }, { "MET", 0.10m },
};

private static readonly Dictionary<string, decimal> _usaFuturesExchangeFees = new()
Expand All @@ -353,7 +353,7 @@ private static CashAmount HongKongFutureFees(Security security)
{ "MYM", 0.30m }, { "M2K", 0.30m }, { "MES", 0.30m }, { "MNQ", 0.30m }, { "2YY", 0.30m }, { "5YY", 0.30m }, { "10Y", 0.30m },
{ "30Y", 0.30m }, { "MCL", 0.30m }, { "MGC", 0.30m }, { "SIL", 0.30m },
// Cryptocurrency Futures
{ "BTC", 6m }, { "MIB", 2.5m }, { "MBT", 2.5m }, { "MET", 0.20m }, { "MRB", 0.20m },
{ "BTC", 6m }, { "MBT", 2.5m }, { "ETH", 4m }, { "MET", 0.20m },
// E-mini FX (currencies) Futures
{ "E7", 0.85m }, { "J7", 0.85m },
// Micro E-mini FX (currencies) Futures
Expand All @@ -369,7 +369,7 @@ private static CashAmount HongKongFutureFees(Security security)
{ "MYM", 0.20m }, { "M2K", 0.20m }, { "MES", 0.20m }, { "MNQ", 0.20m }, { "2YY", 0.20m }, { "5YY", 0.20m }, { "10Y", 0.20m },
{ "30Y", 0.20m }, { "MCL", 0.20m }, { "MGC", 0.20m }, { "SIL", 0.20m },
// Cryptocurrency Future Options
{ "BTC", 5m }, { "MIB", 2.5m }, { "MBT", 2.5m }, { "MET", 0.20m }, { "MRB", 0.20m },
{ "BTC", 5m }, { "MBT", 2.5m }, { "ETH", 4m }, { "MET", 0.20m },
};

/// <summary>
Expand Down
18 changes: 6 additions & 12 deletions Common/Securities/Future/Futures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public static class Currencies
/// <returns>The symbol</returns>
public const string BTC = "BTC";

/// <summary>
/// Ether Futures
/// </summary>
/// <returns>The symbol</returns>
public const string ETH = "ETH";

/// <summary>
/// Canadian Dollar/Japanese Yen Futures
/// </summary>
Expand Down Expand Up @@ -307,18 +313,6 @@ public static class Currencies
/// </summary>
/// <returns>The symbol</returns>
public const string MicroBTC = "MBT";

/// <summary>
/// BTIC on Micro Ether Futures
/// </summary>
/// <returns>The symbol</returns>
public const string BTICMicroEther = "MRB";

/// <summary>
/// BTIC on Micro Bitcoin Futures
/// </summary>
/// <returns>The symbol</returns>
public const string BTICMicroBTC = "MIB";
}

/// <summary>
Expand Down
81 changes: 22 additions & 59 deletions Common/Securities/Future/FuturesExpiryFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,26 @@ public static Func<DateTime, DateTime> FuturesExpiryFunction(Symbol symbol)
return lastFriday.Add(new TimeSpan(15, 0, 0));
})
},
// Ether (ETH): https://www.cmegroup.com/markets/cryptocurrencies/ether/ether.contractSpecs.html
{Symbol.Create(Futures.Currencies.ETH, SecurityType.Future, Market.CME), (time =>
{
// Monthly contracts listed for 6 consecutive months, quarterly contracts (Mar, Jun, Sep, Dec) listed for 4 additional quarters and a second Dec contract if only one is listed.
// Trading terminates at 4:00 p.m. London time on the last Friday of the contract month that is either a London or U.S. business day. If the last Friday of the contract month day is not a business day in both London and the U.S., trading terminates on the prior London or U.S. business day.
var lastFriday = FuturesExpiryUtilityFunctions.LastFriday(time);

var holidays = MarketHoursDatabase.FromDataFolder()
.GetEntry(Market.CME, Futures.Currencies.ETH, SecurityType.Future)
.ExchangeHours
.Holidays;

while (holidays.Contains(lastFriday))
{
lastFriday = FuturesExpiryUtilityFunctions.AddBusinessDays(lastFriday, -1);
}

return lastFriday.Add(new TimeSpan(15, 0, 0));
})
},
// Canadian Dollar/Japanese Yen (CJY): https://www.cmegroup.com/trading/fx/g10/canadian-dollar-japanese-yen_contract_specifications.html
{Symbol.Create(Futures.Currencies.CADJPY, SecurityType.Future, Market.CME), (time =>
{
Expand Down Expand Up @@ -2843,7 +2863,7 @@ Dec listed in June
// Good Friday
FuturesExpiryUtilityFunctions.GetGoodFriday(time.Year)
};

var lastBusinessDay = FuturesExpiryUtilityFunctions.NthLastBusinessDay(time, 3, holidays);

return lastBusinessDay.Add(new TimeSpan(13, 25, 0));
Expand Down Expand Up @@ -3423,7 +3443,7 @@ Dec listed in June
// Micro Ether Futures (MET): https://www.cmegroup.com/markets/cryptocurrencies/ether/micro-ether.contractSpecs.html
{Symbol.Create(Futures.Currencies.MicroEther, SecurityType.Future, Market.CME), (time =>
{
// Monthly contracts listed for 6 consecutive months and 2 additional Dec contract months.
// Monthly contracts listed for 6 consecutive months and 2 additional Dec contract months.

// Trading terminates at 4:00 p.m. London time on the last Friday of the contract month that
// is either a London or U.S. business day. If the last Friday of the contract month day is
Expand Down Expand Up @@ -3478,63 +3498,6 @@ Dec listed in June

return lastFriday.Add(new TimeSpan(15, 0, 0));
})
},
// BTIC on Micro Ether Futures (MRB): https://www.cmegroup.com/markets/cryptocurrencies/ether/micro-ether.contractSpecs.html
{Symbol.Create(Futures.Currencies.BTICMicroEther, SecurityType.Future, Market.CME), (time =>
{
// Monthly contracts listed for 6 consecutive months and 2 additional Dec contract months.

// Trading terminates at 4:00 p.m. London time on the last Friday of the contract month.
// If this is not both a London and U.S. business day, trading terminates on the prior
// London and the U.S. business day.

// BTIC: Trading terminates at 4:00 p.m. London time on the last Thursday of the contract
// month.If this is not both a London and U.S. business day, trading terminates on the prior
// London and the U.S. business day.

var lastThursday = FuturesExpiryUtilityFunctions.LastThursday(time);

var holidays = MarketHoursDatabase.FromDataFolder()
.GetEntry(Market.CME, Futures.Currencies.BTICMicroEther, SecurityType.Future)
.ExchangeHours
.Holidays;

while (holidays.Contains(lastThursday))
{
lastThursday = FuturesExpiryUtilityFunctions.AddBusinessDays(lastThursday, -1);
}

return lastThursday.Add(new TimeSpan(15, 0, 0));
})
},
// BTIC on Micro Bitcoin Futures (MIB): https://www.cmegroup.com/markets/cryptocurrencies/bitcoin/micro-bitcoin.contractSpecs.html
{Symbol.Create(Futures.Currencies.BTICMicroBTC, SecurityType.Future, Market.CME), (time =>
{
// Monthly contracts listed for 6 consecutive months and 2 additional Dec contract months.
// If the 6 consecutive months includes Dec, list only 1 additional Dec contract month.

// Trading terminates at 4:00 p.m. London time on the last Friday of the contract month.
// If this is not both a London and U.S. business day, trading terminates on the prior
// London and the U.S. business day.

// BTIC: Trading terminates at 4:00 p.m. London time on the last Thursday of the contract
// month.If this is not both a London and U.S. business day, trading terminates on the prior
// London and the U.S. business day.

var lastThursday = FuturesExpiryUtilityFunctions.LastThursday(time);

var holidays = MarketHoursDatabase.FromDataFolder()
.GetEntry(Market.CME, Futures.Currencies.BTICMicroBTC, SecurityType.Future)
.ExchangeHours
.Holidays;

while (holidays.Contains(lastThursday))
{
lastThursday = FuturesExpiryUtilityFunctions.AddBusinessDays(lastThursday, -1);
}

return lastThursday.Add(new TimeSpan(15, 0, 0));
})
}
};
}
Expand Down
Loading