How to remove the order from basket orders using javascript

pivottrading.net
Hey,

I was writing javascript to add orders to kite publisher api.
But then for some conditions, i want to remove it from the Kite basket order.
I could not find any documentation for it.

What should i do to remove some order from the basket order using javascript.

I do
kite = new KiteConnect("drt13a4n12vorpac");
kite.add({
"exchange": "NSE",
"tradingsymbol": scripName,
"quantity": 5,
"transaction_type": transaction,
"order_type": orderType,
"product": "MIS"
});

Now, I want to do something like
kite.remove (order xyz....) based on some other button click.??????
How can we do this ?????

Thanks,
Sourabh.
  • pivottrading.net
    pivottrading.net edited November 2016
    The problem that i am facing is, I add order dynamically using javascript. - all good till here.

    Then, i click on some other button for trade. Again, i add order, but i want to clear that first order from Kite object.
    how to clear or reset kite object when dealing with dynamic order generation.

    Thanks,
    Sourabh.
  • sujith
    Hi Sourabh,
    That is not the right way. You should remove it prior to adding into basket rather than removing it from basket.
  • pivottrading.net
    @sujith
    Yes exactly thats what i want, before creating or placing another order, i want to remove all existing entries from the kite object. What is the function to do so ?

    Here is the scenarios.

    I have 2 scrips (ICICIBANK & AXISBANK)
    There are 2 buttons next to each scrip. (Buy & Sell)

    I first click on icicibank buy button. Javascript add ICICIBANK to list and order window is shown.\
    I reaslise i should not buy ICICBANK. I should go for Axisbank. So, i just close the order window without placing order.

    I then click on sell of Axisbank. Javascript adds sell order for Axisbank also.
    When the order window opens up, i see both buy of cicibank and sell of axisbank, where as i only wanted sell of axisbank.

    So, my question is when i click on sell button, what should i do in javascript that it removes the old icicibank order.

    Hope, I made my query clear.
    Awaiting your reply.
  • vishnus
    Hi Sourabh,

    For your given scenario, you should not be using an order basket. You should be using individual scrip buy/sell buttons. So you just pass the scrip name to the parameter data-tradingsymbol. Please refer to
    https://kite.trade/docs/connect/v1/#custom-html5-buttons

    Purpose of basket is to create a fixed set of orders to send to Kite. From previous comments, I am guessing you are trying to build a shopping cart sort for stocks. In that case, you should just store the scrip selected by the user into a simple array (which can be added / removed easily) and do a one time Kite object initialization and add the final set of scrips user is selected to the basket. Hope this makes it clear.

    Thanks
    Vishnu
  • pivottrading.net
    pivottrading.net edited December 2016
    @vishnus
    Yes you are correct. But thats how my requirement is. It cannot be solved with the help of individual buttons.

    The page gets just too slow in loading when individual buttons are used.

    removing should be feasible. its just matter of calling proper API method or exposing method in the API.

    Thanks,
    Sourabh.
  • sujith
    Hi Sourabh,

    We will do it in near future. We cannot give you any timeline.
  • pivottrading.net
    ohhhhh. No worries. As of now i have handled it using the finished callback method.But still in few cases, it has problem.
    A simple api function like clear or reset should be sufficient.

    Thanks,
    Sourabh.
Sign In or Register to comment.