Multiple order Error

infotrade
Hi Support,

When I do multiple order cancellation and placing one big order for SELL or BUY execution , I am getting error now. There is 1 second wait for each order cancellation.

Code snippet:
List orders = kite.GetOrders();
List orderHistory = kite.GetOrderHistory(order.OrderId);
if (orderHistory[orderHistory.Count - 1].Status != Constants.ORDER_STATUS_COMPLETE)
kite.CancelOrder(order.OrderId);
Place BUY or SELL order on leftover quantity.

Error:
7/29/2019 2:46:47 PM: OnError: Lost ticker connection.
7/29/2019 2:46:47 PM: OnError: Lost ticker connection.
7/29/2019 2:46:53 PM: OnReconnect: Reconnecting
7/29/2019 2:46:53 PM: OnConnect: Connected ticker

Is there any limitation which i am not considering? Please guide.

--InfoTrade



  • sujith
    The stacktrace seems to be coming from the Kite Ticker and not the API call.
  • infotrade
    I don't understand what you are saying but I am getting Ticker "OnError", "OnReconnect" while making call "kite.GetOrderHistory" simultaneously.
  • sujith
    Are you doing the thread sleep? You may have to do async (Task.Delay) calls instead of blocking the whole thread which in turn will block ticker.
  • infotrade
    infotrade edited August 5
    I am not using Tread sleep or task delay method as somehow it was not working with windows for multiple treads. I am using below method to sleep the process for some milliseconds.
    public void wait(int milliseconds)
    {
    System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
    if (milliseconds == 0 || milliseconds < 0) return;
    timer1.Interval = milliseconds;
    timer1.Enabled = true;
    timer1.Start();
    timer1.Tick += (s, e) =>
    {
    timer1.Enabled = false;
    timer1.Stop();
    };
    while (timer1.Enabled)
    {
    Application.DoEvents();
    }
    }
  • sujith
    while (timer1.Enabled)
    {
    Application.DoEvents();
    }
    This seems to be the wrong way to handle it. You may use async and await to achieve this.
Sign In or Register to comment.