Skip to content

Commit 9a6670e

Browse files
authored
Fix: MXN(6M) map fut ticker (#209)
* fix: MXN(6M) map fut ticker test:feat: assert subs to 6M * remove: 6m from mapping file
1 parent 4b09792 commit 9a6670e

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

QuantConnect.InteractiveBrokersBrokerage.Tests/InteractiveBrokersBrokerageDataQueueHandlerTest.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,70 @@ public void GetsTickData()
9797
}
9898
}
9999

100+
[Test]
101+
public void SubscribeOnFutureMappedSymbols()
102+
{
103+
using var cts = new CancellationTokenSource();
104+
using var resetEvent = new ManualResetEvent(false);
105+
using var ib = new InteractiveBrokersBrokerage(new QCAlgorithm(), new OrderProvider(), new SecurityProvider());
106+
107+
var mxnFuture = Symbol.CreateFuture(Futures.Currencies.MXN, Market.CME, new(2026, 03, 16));
108+
var mxnFutureOptionContract = Symbol.CreateOption(mxnFuture, mxnFuture.ID.Market, SecurityType.FutureOption.DefaultOptionStyle(), OptionRight.Call, 0.055m, new(2026, 01, 09));
109+
110+
var symbols = new List<Symbol>()
111+
{
112+
mxnFuture,
113+
mxnFutureOptionContract
114+
};
115+
116+
var securityNotFoundCounter = 0;
117+
var securityDefinitionsFound = 0;
118+
ib.Message += (_, brokerageMessageEvent) =>
119+
{
120+
switch (brokerageMessageEvent.Code)
121+
{
122+
case "200":
123+
// Code: 200 - No security definition has been found for the request.
124+
securityNotFoundCounter += 1;
125+
break;
126+
case "354":
127+
// Requested market data is not subscribed. Delayed market data is available.
128+
securityDefinitionsFound += 1;
129+
if (securityDefinitionsFound >= symbols.Count)
130+
{
131+
resetEvent.Set();
132+
}
133+
break;
134+
135+
}
136+
};
137+
138+
ib.Connect();
139+
140+
var configs = new List<SubscriptionDataConfig>(symbols.Count);
141+
foreach (var symbol in symbols)
142+
{
143+
var config = GetSubscriptionDataConfig<Tick>(symbol, Resolution.Tick);
144+
ProcessFeed(ib.Subscribe(config, (_, _) => { }), cts, (_) => { });
145+
configs.Add(config);
146+
}
147+
148+
_ = resetEvent.WaitOne(TimeSpan.FromSeconds(20), cts.Token);
149+
150+
foreach (var config in configs)
151+
{
152+
ib.Unsubscribe(config);
153+
}
154+
155+
resetEvent.Reset();
156+
resetEvent.WaitOne(TimeSpan.FromSeconds(1), cts.Token);
157+
158+
cts.Cancel();
159+
160+
Assert.GreaterOrEqual(securityDefinitionsFound, symbols.Count);
161+
Assert.AreEqual(0, securityNotFoundCounter);
162+
}
163+
100164
[Test]
101165
public void GetsTickDataAfterDisconnectionConnectionCycle()
102166
{

QuantConnect.InteractiveBrokersBrokerage/InteractiveBrokers/IB-symbol-map.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"AIGCI": "AW",
1313
"AC": "EH",
1414
"BRE": "6L",
15-
"MXP": "6M",
1615
"RUR": "6R",
1716
"ZAR": "6Z",
1817
"BRR": "BTC",

0 commit comments

Comments
 (0)