/// <summary> /// query the instrument info /// </summary> /// <param name="symbol"></param> /// <param name="product">limit the result to the specified product only, default value "UnknownType" means query all products</param> /// <param name="exchange">limit the result to the specified exchange only, default value "NonExch" means query all exchanges</param> /// <param name="maturityDate">limit the result to the specified maturity date YYYYMM only, default value "" means all maturity date</param> /// <param name="broker">limit the result to the specified broker only, default value "Xceder" means all brokers</param> /// <returns>ansyc task result for this request</returns> public Task <Tuple <Request, Response> > queryInstrument(string symbol, Instrument.Types.PRODUCT product = Instrument.Types.PRODUCT.UnknownType, Exchange.Types.EXCHANGE exchange = Exchange.Types.EXCHANGE.NonExch, string maturityDate = "", BROKER broker = BROKER.Xceder) { Request request = createRequestMsg(); Tuple <uint, uint> epochPeriod = calPeriod(maturityDate); var query = request.QueryRequest = new Query(); var conditions = query.Instruments = new QueryConditions(); conditions.Broker = broker; conditions.Exchange = exchange; conditions.Symbol = symbol; conditions.Product = product; return(send(request).ContinueWith(r => { var result = r.Result; if (epochPeriod != null) { var array = result.Item2.QueryResult.Instruments.Instrument; var size = array.Count; while (size-- > 0) { var instrument = array[size]; if (instrument.MaturityEpochDays < epochPeriod.Item1 || instrument.MaturityEpochDays > epochPeriod.Item2) { array.RemoveAt(size); } } } return result; })); }
private IList <Instrument> queryInstrument(Client client, string symbol, Instrument.Types.PRODUCT product = Instrument.Types.PRODUCT.Fut, Exchange.Types.EXCHANGE exch = Exchange.Types.EXCHANGE.NonExch, string targetMaturiyDate = "", BROKER broker = BROKER.Xceder) { var requestTask = client.queryInstrument(symbol, product, exch, targetMaturiyDate, broker); setLastSentRequestExpectation(false, Request.RequestOneofCase.QueryRequest); requestTask.Wait(); assertSendRequestResult(requestTask); var instruments = requestTask.Result.Item2.QueryResult.Instruments.Instrument; foreach (var i in instruments) { Assert.AreEqual(symbol, i.Identity.Symbol); if (product != Instrument.Types.PRODUCT.UnknownType) { Assert.AreEqual(product, i.Product); } if (broker != BROKER.Xceder) { Assert.AreEqual(broker, i.Identity.Broker); } if (exch != Exchange.Types.EXCHANGE.NonExch) { Assert.AreEqual(exch, i.Identity.Exchange); } } return(instruments); }