Kite Connect is getting close when placing more than 1 order

krishkalyani
Please help on this

Here is code. its working fine if i place any one of the order.

But when i execute both of them its giving error as below

"The underlying connection was closed: The connection was closed unexpectedly. "

I am using .Net Application to place orders

My Code:
string TradingSymbol = "TATAMOTORS";
string APIKey = "***********************";
string AccessToken = "**************************************";

Kite kite = null; kite = new Kite(APIKey: APIKey, AccessToken: AccessToken, Debug: false, Timeout: 7000, Pool: 2);

kite.PlaceOrder(
Exchange: Constants.EXCHANGE_NSE,
TradingSymbol: TradingSymbol,
TransactionType: Constants.TRANSACTION_TYPE_SELL,
Quantity: 1, Price: 484.00m,
Product: Constants.PRODUCT_MIS,
OrderType: Constants.ORDER_TYPE_SL,
TriggerPrice: 484.50m );


kite.PlaceOrder(
Exchange: Constants.EXCHANGE_NSE,
TradingSymbol: TradingSymbol,
TransactionType: Constants.TRANSACTION_TYPE_SELL,
Quantity: 1,
Price: 492.40m,
OrderType: Constants.ORDER_TYPE_LIMIT,
Product: Constants.PRODUCT_MIS );
  • SRIJAN
    SRIJAN edited January 7
    What's the error you are getting when placing orders?? Do you have enough margin to place a sl and limit order at once?? That could be the error too. If you don't place orders inside try-except block as in the documentation,if any exception occurs,your code will show error and close.
  • krishkalyani
    Hi Srijan,

    The below is error
    "The underlying connection was closed: The connection was closed unexpectedly."

    I am testing placing orders using API.

    just placing 1 quantity only placing Order and Stop Loss for testing. its not working at a time.

    I have enough margin as it only 1 quantity.

    Thanks
    Krishna

  • sujith
    @krishkalyani,
    You shouldn't block the main thread that is receiving ticks. Do all your operations, data dump and calculations on another thread, don't block the thread that is receiving ticks.
  • krishkalyani
    @sujith , its working in separate threads. thank you very much
Sign In or Register to comment.