Error while Placing Bracket Order

decipher
decipher edited February 2018 in .Net API client
Hi,

I am trying to place a bracket Order using API with below details, I am getting Success in Authentication Still getting
Exception "Invalid `api_key` or `access_token`."

kite.PlaceOrder("NSE", "OIL", "BUY",5, 336, "BO", "LIMIT", null, null, null, 7, 5, null, "BO", null);


  • sujith
    Are you sure you are setting access token and api key as shown here?
  • decipher
    Yes, if i replace the bracket order with MIS order, it gets executed
  • sujith
    You are missing something. It is not possible to get this error message if your normal order is going through.
    You can enable debugging and check the complete logs.
    Are you using Kite Connect 1 or Kite Connect 3?
    If you are using Kite Connect 3 then you can check out examples.
  • decipher
    I am using Kite 3 and have referred the code mentioned by you. I can show you the same over a screen sharing session. I will try to see the detailed logs meantime.
  • decipher
    Sujith, There seems to be some issue with BracketOrder implementation in dll.

    I have tried in off hours still Same code produces results for other order type and fails for Bracket Order type. Please simulate in your sample code as well and no debug logs are produced.

    Code Workflow
    1) Authenticate();
    2) string[] orderstatus1 = PlaceMarkOrder("SAIL", 1, "SELL"); //goes through
    3) string[] order = PlaceBracketOrder("SAIL",1, "SELL", 84.21M,200,200,10); Exception Occurs

    Place Market
    private string[] PlaceMarkOrder(string dbscripname1, int dblotsize,string transactionType)
    {
    string[] orderstaus = new string[] { "Failure", "" };
    Dictionary orderResult1 = kite.PlaceOrder("NSE", dbscripname1, transactionType, dblotsize, null, "MIS", "MARKET", null, null, null, null, null, null, "regular", "");
    }
    Place Bracket Order
    private string[] PlaceBracketOrder(string dbscripname1, int dblotsize, string transactionType,decimal tradePrice, decimal squareoffVal, decimal stoplossValue,decimal trailingticks)
    {
    string[] orderstaus = new string[] { "Failure", "" };
    Dictionary orderResult1 = kite.PlaceOrder("NSE", dbscripname1, transactionType, dblotsize, tradePrice, "BO", "LIMIT", Constants.VALIDITY_DAY, null, null, squareoffVal, stoplossValue, null, "BO", null);

    }
  • tonystark
    Try initializing with Debug true like this:

    Kite kite = new Kite(MyAPIKey, Debug: true);

    This will give detailed logs. Please post it here.

    And also when you give the variety it should be lower case "bo", not "BO". You can use the value from the Constants class for that. See the example here.
  • decipher
    yups got it, after adding the full project instead of DLL i could do a better debug, but the error i was getting was misleading, i looked at the sample code and modified the variety from "BO" to Constants.VARIETY_BO and it worked.

    So i guess the error handling could have been slightly better here.

    Thanks for your help as well.
    Cheers!
This discussion has been closed.