Order input exception

pankaj8932
Hi

I am placing simple order using API but it says order input exception. Below are simple code which u have provided in example. Can you help me on this? I see lot of issues ... I am also unable to unsubscribe token after subscribing it. Its paid service shouldn't be give issues for such a simple implementation.

OrderParams orderParams = new OrderParams();
orderParams.quantity = 1;
orderParams.orderType = Constants.ORDER_TYPE_LIMIT;
orderParams.tradingsymbol = "ASHOKLEY";
orderParams.product = Constants.PRODUCT_CNC;
orderParams.exchange = Constants.EXCHANGE_NSE;
orderParams.transactionType = Constants.TRANSACTION_TYPE_BUY;
orderParams.validity = Constants.VALIDITY_DAY;
orderParams.price = 122.2;
orderParams.triggerPrice = 0.0;
orderParams.tag = "myTag"; //tag is optional and it cannot be more than 8 characters and only alphanumeric is allowed

Order order = kiteConnect.placeOrder(orderParams, Constants.VARIETY_REGULAR);
System.out.println(order.orderId);
  • SRIJAN
    What's the exact exception you are getting?? You can either run javakiteconnect with debug logs on or print the exception.
  • SRIJAN
    SRIJAN edited March 2022
    Oh,I got it. That's why you shouldn't copy something entirely before understanding it properly. Ashok Leyland upper circuit is 120.9,and you are placing limit of 122.2 . How will it not cause exception??
  • pankaj8932
    That was just illustration purpose. I did tried with multiple values. Now we are debugging so I did change price value to 116.20 but still give order exception error.

    OrderParams orderParams = new OrderParams();
    orderParams.quantity = 1;
    orderParams.orderType = Constants.ORDER_TYPE_LIMIT;
    orderParams.tradingsymbol = "ASHOKLEY";
    orderParams.product = Constants.PRODUCT_NRML;
    orderParams.exchange = Constants.EXCHANGE_NSE;
    orderParams.transactionType = Constants.TRANSACTION_TYPE_BUY;
    orderParams.validity = Constants.VALIDITY_DAY;
    orderParams.price = 116.20;
    orderParams.triggerPrice = 0.0;
    orderParams.tag = "myTag"; //tag is optional and it cannot be more than 8 characters and only alphanumeric is allowed

    Order order = kiteConnect.placeOrder(orderParams, Constants.VARIETY_REGULAR);
    System.out.println(order.orderId);
    return order.orderId;

    Below are the error got. Problem is that these error very generic not specific to the issues.

    com.zerodhatech.kiteconnect.kitehttp.exceptions.InputException
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:54)
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:20)
    at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:86)
  • SRIJAN
    Why don't you learn stock market manually first and then try algo trading?? Using NRML on equity, seriously??
  • SRIJAN
    Also,when you have any error, don't post this stacktrace. As I told above,run javakiteconnect with debug logs on or catch and print the exception. That would directly tell the issue.
  • pankaj8932
    pankaj8932 edited March 2022
    Dude I tried with all permutation combination ... for your reference I did specifically tried with what u have told still gives error

    OrderParams orderParams = new OrderParams();
    orderParams.quantity = 1;
    orderParams.orderType = Constants.ORDER_TYPE_LIMIT;
    orderParams.tradingsymbol = "ASHOKLEY";
    orderParams.product = Constants.PRODUCT_CNC; // tried with Constants.PRODUCT_MIS as well
    orderParams.exchange = Constants.EXCHANGE_NSE;
    orderParams.transactionType = Constants.TRANSACTION_TYPE_BUY;
    orderParams.validity = Constants.VALIDITY_DAY;
    orderParams.price = 116.20;
    orderParams.triggerPrice = 0.0;
    orderParams.tag = "myTag"; //tag is optional and it cannot be more than 8 characters and only alphanumeric is allowed

    Order order = kiteConnect.placeOrder(orderParams, Constants.VARIETY_REGULAR);
    System.out.println(order.orderId);
    return order.orderId;
  • pankaj8932
    I did enable logging using "KiteConnect.ENABLE_LOGGING = true;" and catching exception ... but still gives same stacktrace which I mentioned above.

    try {
    KiteCommons.getInstance().placeOrder();

    } catch (KiteException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
  • sujith
    @pankaj8932,
    You need to understand, we are not support agents here. This is a community forum. We are all developers here like you. We take our time out from our main projects and help fellow community members.
    It is throwing an error
    This statement doesn't make any sense. You can refer to documentation and javakiteconnect samples to know how to run it with debug logs on and learn to read the error messages. What you are likely looking at is an InputException, it has nothing to do with API or anyone else. It is the user input that is wrong and you need to read the exception message and figure it out.
  • pankaj8932
    pankaj8932 edited March 2022
    sorry to flooding with messages. I did enabled logging and got below error message. Not sure why it is asking for TOTP. I have to setup this and For every order I have to enter code?

    {"status":"error","message":"TOTP is mandatory to place orders on third-party apps. Learn how to set up TOTP for your account [here](https://support.zerodha.com/category/your-zerodha-account/login-credentials/login-credentials-of-trading-platforms/articles/time-based-otp-setup-mobile-only).","data":null,"error_type":"InputException"}

    I think it will be easier for you now.
  • sujith
    You need to re-login with TOTP to make this go away. You don't need to enter TOTP for every order. You will need it once everyday for login.
  • SRIJAN
    Totp is mandatory to place orders from third-party apps. You can setup Totp once,and then just do the normal daily login once. You don't need to enter totp for every order placement.
  • pankaj8932
    Thanks ... its working now.
This discussion has been closed.