Hi, I am using 'token' as the filter to create separate DataFrames instead of using group_by. So I start with the line : if token in tokens , where tokens is a list of tokens. If there is only one token in the list , all the orders are uniquely related to that token. But when there are many tokens, then there is a need to be sure about the status of the existing order/position before placing a fresh order. For example if a buy condition is triggered, I would like to check that either there is no order pending or it is a sell order. The parameter "transaction_type" : "BUY" or "SELL" is used for all the tokens. Then how to distinguish status of one token from the other? Should I use different identifier for each instrument? Kindly enlighten.
Let me rephrase the problem statement, you want to place an order but before placing an order you want to check if there is a position already.
In order to check if a position already exists for an instrument, you need to fetch positions and find the position with same instrument token or (tradingsymbol + exchange) and check for the product type.
I have solved this with the help of hint you provided. I also want to understand what is the purpose of the parameter "tag" in the order_place function..
@RP3436 "tag" is an identifier you can give to uniquely identify a particular order or categorizing a set of orders etc. Check out the documentation here.
In order to check if a position already exists for an instrument, you need to fetch positions and find the position with same instrument token or (tradingsymbol + exchange) and check for the product type.
I also want to understand what is the purpose of the parameter "tag" in the order_place function..