order not place in trading account with below logic please help

def custom_message(msg) :
    #print("...new msg...")
    script = msg[0]['symbol'] 
    ltp = msg[0]['ltp'] 
    high = msg[0]['high_price'] 
    low = msg[0]['low_price'] 
    ltt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(msg[0]['timestamp'])) 
    print(f"Script: {script}, Ltp:{ltp}, High:{high}, Low:{low}, Ltt:{ltt}")     
    time.sleep()  
            
def signal (script,ltp,high,low,ltt):
    if (ltp <= low) and (script not in open_position) and (ltt[-8:] < "15:10:00"):
       open_position.append(script)
       placeOrder("SELL",script,ltp)
    
    if (ltp >= high) and (script not in open_position) and (ltt[-8:] < "15:10:00"):
       open_position.append(script)
       placeOrder("BUY",script,ltp) 
       
def placeOrder(order, script, ltp):
    if order == "BUY":
        quantity = int(10)
        target_price = int(ltp*0.02)
        stoploss_price = int(ltp*0.01)
        
        order = fyers.place_order(data={"symbol":script,"qty":quantity,"type":2,"side":1,"productType":"BO","limitPrice":0,"stopPrice":0,"disclosedQty":0,"validity":"DAY","offlineOrder":"False","stopLoss":stoploss_price,"takeProfit":target_price})
        print(f"Buy Order Pleaced for {script}, at Price: {ltp} for Quantity: {quantity},with order_id:{order['id']} at time: {getTime()}")
        print(open_position)
          
    else:
        quantity = int(10)
        target_price = int(ltp*0.02)
        stoploss_price = int(ltp*0.01)
        
        order = fyers.place_order(data={"symbol":script,"qty":quantity,"type":2,"side":-1,"productType":"BO","limitPrice":0,"stopPrice":0,"disclosedQty":0,"validity":"DAY","offlineOrder":"False","stopLoss":stoploss_price,"takeProfit":target_price})
        print(f"Sell Order Pleaced for {script}, at Price: {ltp} for Quantity: {quantity},with order_id:{order['id']} at time: {getTime()}")
        print(open_position)
3 replies