Working Sample code to Place Orders - Python


  • Here is the working sample code to Place Orders:

    from smartapi import SmartConnect 
    
    obj = SmartConnect(api_key="your_api_key")
    data = obj.generateSession('client_id', 'your_password')
    refreshToken= data['data']['refreshToken']
    
    orderparams = {
        "variety": "NORMAL",
        "tradingsymbol": "symbol",
        "symboltoken": "token",
        "transactiontype": "BUY",
        "exchange": "NFO",
        "ordertype": "MARKET",
        "producttype": "INTRADAY",
        "duration": "DAY",
        "quantity": "quantiy"
     }
    orderId = obj.placeOrder(orderparams)
    print(orderId)
    

    Above code just punch order and returns orderId of particular order.