python coding for formula based excel cell

YU7252
Hi,
I am looking for python coding solution for when there is change in formula based excel cell (in Quantity), than buy / sell triggers.
Please note, Changes happens in same cell. For example, here in "C2" i.e. in Quantity
Exchange Symbol Quantity Price Transaction Type
NSE IDEA 1 1 buy

I have try to write below codes for the same, but unable to get solution for the same.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
firstrun = None
while True:
try:
# df = pd.read_excel ("filepath") # Update with your file path

buy = kite.TRANSACTION_TYPE_BUY
sell = kite.TRANSACTION_TYPE_SELL

# Keep track of previous values
previous_values = {}

# Iterate through each row in the DataFrame and send orders
for index, row in df.iterrows():
# Extract order details from the Excel row
symbol = row['Symbol']
exchange = row['Exchange']
price = (row['Price'])
quantity_formula = str(row['Quantity'])
transaction_type_formula = (row['Transaction Type'])

# Evaluate the formula-based cells
quantity = eval(quantity_formula, globals(), locals())
transaction_type = eval(transaction_type_formula, globals(), locals())

# Check if there is a change in quantity or transaction type

if firstrun == None or (symbol in previous_values and \
(quantity != previous_values[symbol]['quantity'] or transaction_type != previous_values[symbol]['Transaction Type'])):

# send_trade_order(exchange, symbol, quantity, price, transaction_type)

<<<<<<<<<<<<<<<<<<<<<<<

Please help for solution.
  • tahseen
    Use compare function of dataframe. There are lot of options in that

Sign In or Register to comment.