GetOHLC and GetLTP returning errors

vardhan36397
vardhan36397 edited November 2017 in .Net API client
Hi Team,

As part of my development using .Net API Client, I have gone through the below error after returning the data.

Below is the code I used.
          /// <summary>
/// Retrieve LTP and OHLC of upto 200 instruments
/// </summary>
/// <param name="Exchange">Name of the exchange</param>
/// <param name="TradingSymbol">Tradingsymbol of the instrument</param>
/// <returns>Json response in the form of nested string dictionary.</returns>
try
{
Dictionary<string, OHLC> ohlcs = kite.GetOHLC(new string[] { "MCX:ALUMINI17NOVFUT","MCX:ALUMINIUM17NOVFUT","MCX:COPPER17NOVFUT","MCX:COPPERM17NOVFUT","MCX:COTTONREF17NOVFUT","MCX:CPO17NOVFUT","MCX:GOLDGUINEA17NOVFUT","MCX:GOLDPETAL17NOVFUT","MCX:LEAD17NOVFUT","MCX:LEADMINI17NOVFUT","MCX:MENTHAOIL17NOVFUT","MCX:NICKEL17NOVFUT","MCX:NICKELM17NOVFUT","MCX:RBDPMOLEIN17NOVFUT","MCX:SILVER100017NOVFUT","MCX:SILVERM17NOVFUT","MCX:SILVERMIC17NOVFUT","MCX:ZINC17NOVFUT","MCX:ZINCMINI17NOVFUT" });
Console.WriteLine(JsonSerialize(ohlcs));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}



//// Get LTP of upto 200 scrips
/// <summary>
/// Retrieve LTP of upto 200 instruments
/// </summary>
/// <param name="Exchange">Name of the exchange</param>
/// <param name="TradingSymbol">Tradingsymbol of the instrument</param>
/// <returns>Json response in the form of nested string dictionary.</returns>
try
{
Dictionary<string, LTP> ltps = kite.GetLTP(new string[] { "MCX:ALUMINI17NOVFUT", "MCX:ALUMINIUM17NOVFUT", "MCX:COPPER17NOVFUT", "MCX:COPPERM17NOVFUT", "MCX:COTTONREF17NOVFUT", "MCX:CPO17NOVFUT", "MCX:GOLDGUINEA17NOVFUT", "MCX:GOLDPETAL17NOVFUT", "MCX:LEAD17NOVFUT", "MCX:LEADMINI17NOVFUT", "MCX:MENTHAOIL17NOVFUT", "MCX:NICKEL17NOVFUT", "MCX:NICKELM17NOVFUT", "MCX:RBDPMOLEIN17NOVFUT", "MCX:SILVER100017NOVFUT", "MCX:SILVERM17NOVFUT", "MCX:SILVERMIC17NOVFUT", "MCX:ZINC17NOVFUT", "MCX:ZINCMINI17NOVFUT" });
Console.WriteLine(JsonSerialize(ltps));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
I received an error.
The given key was not present in the dictionary.

Kindly verify the issue.


  • vardhan36397
    Any update on this please?
  • tonystark
    It seems "RBDPMOLEIN17NOVFUT" is not being traded now. And the OHLC and LTP for the same are not available.
  • vardhan36397
    Ok, I will verify and let you know, till then please keep the discussion open.
  • vardhan36397
    Hi @ajinsokan,

    You are correct. The RBDPMOLEIN is the culprit. I just want to know, is there any reason behind using the Trading Symbols along with Exchange instead of Instrument Token.

    I believe it will be good for programmers to use the same kind of standards over the project.

    Thanks & Regards,
    R C Vamsi Vardhan
  • tonystark
    You can also use instrument token instead of exchange - trading symbol combination.
Sign In or Register to comment.