private static void QTrade_OnSymbolSearchRecieved(object sender, APISymbolSearchReturnArgs e) { var list = e.symbols.symbols; for (int i = 0; i < list.Length; i++) { Console.WriteLine(string.Format("{0,-10}\t{1,-10}\t{2,-10}\t{3,-10}", list[i].symbol, list[i].symbolId, list[i].listingExchange, list[i].description)); } }
/// <summary> /// Retrives a list of symbols given a search query /// </summary> /// <param name="query">Search query</param> /// <param name="offset">Starting offset on list</param> /// <param name="cancellationTokenSource">Cancellation token source</param> public void GetSymbolsAsync(string query, CancellationTokenSource cancellationTokenSource, int offset = 0) { CancellationToken ct = cancellationTokenSource.Token; Task.Run(() => { ct.ThrowIfCancellationRequested(); var obj = ApiGet <Symbols>(apiClient, string.Format("v1/symbols/search?prefix={0}&offset={1}", query, offset, ct)); //var resp = await apiClient.GetAsync(string.Format("v1/symbols/search?prefix={0}&offset={1}",query,offset)); //obj.Wait(ct); if (obj.isSuccess && !ct.IsCancellationRequested) { var arg = new APISymbolSearchReturnArgs(); arg.symbols = obj.q_obj; arg.NumCallsLeft = obj.NumCallsLeft; arg.RateReset = obj.RateReset; OnSymbolSearchRecieved(this, arg); } }, ct); }