how can i create new thread to place orders in it.

sanket_one
sanket_one edited June 2020 in Python client
i want to create new thread to place orders in it. can someone show me any example of how to do it. i am really struggling with threading concept.
Tagged:
  • rakeshr
    @sanket_one
    Where you want to create a new thread for order placement? Inside Websocket streaming?
    Maybe you can go through this thread.
  • sanket_one
    def buy():
    order_id = kite.place_order(variety=kite.VARIETY_REGULAR,exchange=kite.EXCHANGE_NSE, tradingsymbol=name,transaction_type=kite.TRANSACTION_TYPE_BUY, quantity=1, product=kite.PRODUCT_MIS, order_type=kite.ORDER_TYPE_MARKET,)

    def on_ticks(ws,ticks):
    helper_method()
    def helper_method(ticks):
    #calculations.
    buy(name)


    this is what i am trying to do.
    but after placing order i lose my connection. with this error.

    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /orders/regular HTTP/1.1" 200 None
    ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (None)
  • sanket_one
    @rakeshr can you please guide me.
  • rakeshr
    @sanket_one
    def buy():
    We see you don't accept any input value on buy method, but you are sending name variable herebuy(name).
    For future query, please post complete code, so we can get a better idea to debug it.
  • sanket_one
    @rakeshr ok. thank you.
This discussion has been closed.