I ran into this in Feb 2019 on a live account and was told by IB that it ¡®operates as designed¡¯, meaning OrderRef in a FlexQuery will always be blank.? This is obviously odd since it is available as a selection in the report setup.
?
A workaround is to log all order and execution messages to a database at runtime, both of which contain any OrderRef value included when placing the order.? Also logged is the unique PermId for every order, which is the key you can use for linking orders, order legs, and executions for any reporting based on OrderRef.
?
Incidentally, if you are using TWS and set ¡®Show trades for:¡¯ to ¡®Last 7 Days¡¯ before you connect the API, the initial execution messages received after API connection will include the OrderRef.? So basically, TWS has visibility to OrderRef, but they are dropped at IB before they can make it into a FlexQuery.