Knowing order position before placing fresh order , multiple instruments

RP3436
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.
  • sujith
    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.
  • RP3436
    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..
  • tonystark
    @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.
  • RP3436
    OK, that means i can refer to an order with this tag in place of order_id. If that is correct, you please close the thread.
This discussion has been closed.