Question is in the title.
Context on application, we are writing some custom logging to stitch together the dataframes from signals, orders, executions, etc to produce an end to end perspective on what we're calling a "trade."
Currently, I am having a lot of difficulty attempting to figure out if an order is opening or closing a position. I can make some assumptions programmatically, but when multiple orders (due to day trading limit orders) happen to open and close a position, the complexity skyrockets.
Any advice on how to correlate an orderID with "opening" or "closing" a position would be greatly appreciated!