Sound notification in python when eberytime IF codition satisfies

83
April 06, 2022, at 8:20 PM

I want to play a sound every time an IF condition satisfies, I tried playsound module but it plays once & ask for unique alias device id but as per my IF condition, I should be get different answer every time whereas sound only plays once.

def orderManagement():
    sheet = xw.Book("angel_excel(working).xlsx").sheets[0]
    sheet.range(f"A1:K200").autofit()
    for i in range(2, (len(tickerlist)+2)):
        Status = sheet.range('I' + str(i)).value
        quantity = sheet.range('J' + str(i)).value
        if (Status != None) & (type(Status) != float) & (type(Status) != int) & (quantity != None) & (type(quantity) != str):
            if (quantity > 0):
                Status = Status.upper()
                quantity = int(quantity)
                Script = sheet.range('A' + str(i)).value
                Script = (f"{Script}-EQ").upper()
                price = sheet.range('C' + str(i)).value
                token = sheet.range('B' + str(i)).value
                if (Script not in buy_traded_stocks) and (Status == "BUY"):
                    orderparams = {
                        "variety": "NORMAL",
                        "tradingsymbol": Script,
                        "symboltoken": int(token),
                        "transactiontype": Status,
                        "exchange": exchange,
                        "ordertype": "LIMIT",
                        "producttype": "INTRADAY",
                        "duration": "DAY",
                        "price": price,
                        "squareoff": "0",
                        "stoploss": "0",
                        "quantity": quantity
                    }
                    orderId = obj.placeOrder(orderparams)
                    print(f"{Status} order placed for {Script}, at Price: {price} for Quantity: {quantity}, with order_id: {orderId} at time: {datetime.datetime.now()}")
                    buy_traded_stocks.append(Script)
                    sheet.range(f"K{i}").value = "Order Placed"

I want to play sound as soon as ORDER PLACED sent to excel sheet.

READ ALSO
Plot a horizontal line using matplotlib

Plot a horizontal line using matplotlib

I have used spline interpolation to smooth a time series and would also like to add a horizontal line to the plotBut there seems to be an issue that is out of my grips

65
Finding best representative point in a group of latitudes and longitudes

Finding best representative point in a group of latitudes and longitudes

I have a cluster of 10 Latitudes and LongitudesI want to find the optimal location to do set up a lemonade stand

71
Changing python list size during iteration. Is it okay?

Changing python list size during iteration. Is it okay?

Above is simple code changes list size during iterating itself

79