Defining another function for placing order

SAPANKHUNTIA
SAPANKHUNTIA edited March 2021 in Python client
Hi traders and coders.

I want to define a function for placing order, that will take a few arguments and all other arguments will be predefined in the function
def place_an_order(name,price, no_of_shares,transac_type):
order_id = kite.place_order(
tradingsymbol = name,
price = price,
variety = kite.VARIETY_REGULAR,
exchange = kite.EXCHANGE_NSE,
transaction_type = transac_type,
quantity = no_of_shares,
product = kite.PRODUCT_MIS,
order_type = kite.ORDER_TYPE_LIMIT)

print(order_id)
But it is showing some error. But when I call the simple kite.place_order, it is running fine.

Can anyone please suggest how to do that.

Thank you.
  • rakeshr
    The above code looks fine. What was the error? Can you paste the complete error stack trace here?
  • SAPANKHUNTIA
    Hi @rakeshr.

    I am calling the function like this

    place_an_order(name= name, price=ltp, Transac_type=kite.TRANSACTION_TYPE_BUY, no_of_shares=initial_amount)

    But when its time to place an order. this thing shows up without placing an order.

    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /portfolio/positions HTTP/1.1" 200 None

    Kindly tell me what this means. and how to sort this problem out.
    Thank you.
  • rakeshr
    GET /portfolio/positions HTTP/1.1" 200 None
    From the above log, it looks like you are making a position API request. Maybe you can re-check your code, regarding this.
  • SAPANKHUNTIA
    Hi @rakeshr

    But when I check my ac after this message there is no open position or no order request. Any suggestion will be very helpful.

    Thank you.
Sign In or Register to comment.