Need help with the Spyder IDE console bug

I have built a python function in anaconda through which the buy/sell order is placed in 5paisa server. Here is the function defined:

def place_order(order_type,scrip_code,quantity,price):     
    
    place_order = client.place_order(OrderType=order_type,Exchange='N',
                       ExchangeType='D', 
                       ScripCode = scrip_code, 
                       Qty=quantity, 
                       Price=price)
    
    print (place_order)     
    print ("Order status is {}". format (place_order["Status"]))

    return place_order

While executed for the first few times, the function works properly and sends the appropriate order to 5paisa. However after a couple of times or so, it is sending a malfunctioned order. If I restart the kernel, it works properly. This is happening continuously, I am new to python as well. Request your help & thank you in advance.

Here is the way I access, Open anaconda windows prompt → Open Spyder → Write and execute in Spyder console. When I restart the kernel in Spyder console, it works perfectly.

Here is the screen recording link : Spyder IDE issue.mp4 - Google Drive

And this happens only in Spyder, not if you run the code repeatedly in a regular Python REPL?