public void FutureSubscriptions() { using (var ib = new InteractiveBrokersBrokerage(new QCAlgorithm(), new OrderProvider(), new SecurityProvider(), new AggregationManager(), TestGlobals.MapFileProvider)) { ib.Connect(); var gotEsData = false; var gotHsiData = false; var cancelationToken = new CancellationTokenSource(); var es = Symbols.CreateFuturesCanonicalSymbol("ES"); var firstEs = ib.LookupSymbols(es, includeExpired: false).First(); ProcessFeed( ib.Subscribe(GetSubscriptionDataConfig <TradeBar>(firstEs, Resolution.Second), (s, e) => { gotEsData = true; }), cancelationToken, (tick) => Log(tick)); // non USD quote currency, HDK var hsi = Symbols.CreateFuturesCanonicalSymbol("HSI"); var firstHsi = ib.LookupSymbols(hsi, includeExpired: false).First(); ProcessFeed( ib.Subscribe(GetSubscriptionDataConfig <TradeBar>(firstHsi, Resolution.Second), (s, e) => { gotHsiData = true; }), cancelationToken, (tick) => Log(tick)); Thread.Sleep(2000); cancelationToken.Cancel(); cancelationToken.Dispose(); Assert.IsTrue(gotEsData); Assert.IsTrue(gotHsiData); } }
public void CreateExpectedFutureContractsWithDifferentCurrencies() { using (var ib = new InteractiveBrokersBrokerage(new QCAlgorithm(), new OrderProvider(), new SecurityProvider(), new AggregationManager(), TestGlobals.MapFileProvider)) { ib.Connect(); Assert.IsTrue(ib.IsConnected); var tickersByMarket = new Dictionary <string, string[]> { { Market.HKFE, new[] { "HSI" } }, { Market.CME, new[] { "ACD", "AJY", "ANE" } }, { Market.CBOT, new[] { "ZC" } } }; foreach (var kvp in tickersByMarket) { var market = kvp.Key; var tickers = kvp.Value; foreach (var ticker in tickers) { var currentSymbol = Symbol.Create(ticker, SecurityType.Future, market); var symbolsFound = ib.LookupSymbols(currentSymbol, false); Assert.IsNotEmpty(symbolsFound); foreach (var symbol in symbolsFound) { Log.Trace($"Symbol found in IB: {symbol}"); } } } } }
/// <summary> /// Returns an IEnumerable of Future/Option contract symbols for the given root ticker /// </summary> /// <param name="symbol">The Symbol to get futures/options chain for</param> /// <param name="includeExpired">Include expired contracts</param> public IEnumerable <Symbol> GetChainSymbols(Symbol symbol, bool includeExpired) { return(_brokerage.LookupSymbols(symbol, includeExpired)); }
/// <summary> /// Returns an IEnumerable of Future/Option contract symbols for the given root ticker /// </summary> /// <param name="ticker">The root ticker</param> /// <param name="securityType">Expected security type of the returned symbols (if any)</param> /// <param name="includeExpired">Include expired contracts</param> public IEnumerable <Symbol> GetChainSymbols(string ticker, SecurityType securityType, bool includeExpired) { return(_brokerage.LookupSymbols(ticker, securityType, includeExpired)); }