Not getting instruments other than NSE exchange

yoursvsr
Hi Team,

I just want to get a dump of instruments from NFO but irrespective of what exchange name parameter I provide (I tried with NFO and MCX to see if it works) but I am getting all the instruments of NSE exchange only? I know the exchange name parameter is passed in alright.

Should I subscribe to these separately?

Thanks and regards.
  • rakeshr
    We just checked with https://api.kite.trade/instruments/NFO and it's working fine. Can you let us know your complete request param?
  • yoursvsr
    yoursvsr edited November 2020
    Hi @rakeshr,

    The following is the snippet that calls for list of instruments:
            public async Task<List<Instrument>> GetInstrumentsAsync(string exchangeName = KiteConstants.EXCHANGE_NFO)
    {
    if (!InitializeBroker())
    {
    return null;
    }
    return await _broker.GetInstrumentsAsync(exchangeName);
    }

    where exchange names are:
     public static class KiteConstants
    { // Exchanges
    public const string EXCHANGE_NSE = "NSE";
    public const string EXCHANGE_BSE = "BSE";
    public const string EXCHANGE_NFO = "NFO";
    public const string EXCHANGE_CDS = "CDS";
    public const string EXCHANGE_BFO = "BFO";
    public const string EXCHANGE_MCX = "MCX";
    }

    which in turn would call this:
    public async Task<List<Instrument>> GetInstrumentsAsync(string exchange = null)
    {
    var param = new Dictionary<string, dynamic>();

    List<Dictionary<string, dynamic>> instrumentsData;

    if (string.IsNullOrEmpty(exchange))
    {
    instrumentsData = await GetAsync("market.instruments.all", param);
    }
    else
    {
    param.Add("exchange", exchange);
    instrumentsData = await GetAsync("market.instruments", param);
    }

    List<Instrument> instruments = new List<Instrument>();

    foreach (Dictionary<string, dynamic> item in instrumentsData)
    {
    instruments.Add(new Instrument(item));
    }

    return instruments;
    }
    The remaining code is standard code that comes with official .Net Client.

    Regards.
  • yoursvsr
    Hi @rakeshr ,

    Never mind. They say, it bites where it hurts the most :smile: .

    When I said, "I know the exchange name parameter is passed in alright.", I was dead wrong. I found during debugging that I forgot to change the default param value in the interface definition.

    Now, everything works just fine.

    Thanks much.
This discussion has been closed.