EternalHappiness
EternalHappiness

Reputation: 1

How do I count the dynamic orderIds generated through API in this code?


This code simply prints "the orderId is 1 to 3", but what I want is, I want to Count the Orderid that is' generated through API..

 order_params = {
"variety": "NORMAL",
"tradingsymbol": TRADING_SYMBOL,
"symboltoken": TOKEN,
"transactiontype": transaction_type,
"exchange": EXCHANGE.split("_") 
[0].upper(),
"ordertype": "MARKET",
"producttype": "INTRADAY",
"duration": "DAY",
"price": price,
"squareoff": "0",
"stoploss": "0",
"quantity": QUANTITY
}

  orderId = obj.placeOrder(order_params)
  print("[Real Trade]")
  print("The order id is: 
 {}".format(orderId))
 order_idcount ="The orderId is"
 occurrences = 

order_idcount.count(order_idcount)
for orderId in range(1, 4):
print("The order id is: 
{}".format(orderId))
  occurrences+= 1  # Increment the count 
  for each API generated order ID

The Ouput for the above code I m getting 
is 
The orderId is 1 
The orderId is 2
The orderId is 3
Number of occurrences of order id:
The order id is:230809000922748       
Number of occurrences of order id:
The order id is: 230809000922753       
Number of occurrences of order id:
The order id is: 230809000922789      

This above code simply prints "the orderId from 1 to 3", simply because, the logic of the code is to write down the numbers from 1 to 3.

I do not know how to code this to get the desired output as given below.So anyone please help me how to code that one.

Sorry I m just a beginner in python.Appologies if my question is dumb. Thank you

but

what I want is, I want to Count the Orderid that is' generated through API.

This number--> orderId [230809000922748] is autogenerated in the terminal through API //================================== BUT THE EXPECTED OUTPUT IS

Number of occurrences of order id: 1
The order id is:230809000922748 [1]      
[count the API generated orderId]

Number of occurrences of order id:2
The order id is: 230809000922753[2]      

Number of occurrences of order id:3
The order id is: 230809000922755 [3]

Anyone please give me the modified code to get the desired output

Upvotes: 0

Views: 67

Answers (0)

Related Questions