My apologies. I use a (pimped) version of the ApiController class that ships with the TWS API. It implements a "controller pattern" and hides a lot of unnecessary TWS API details from the client. But for some reason for the reqExecutions call, it renamed the execDetails() callback to tradeReport() and execDetailsEnd() to tradeReportEnd(). But their functions are identical.
You should reach out to IBKR if your execDetails callbacks indeed only arrive, when the Trade History window is open in TWS.
I still think that you need something more than Execution objects to properly implement your rules based trading. Keep in mind that a single order can be filled with multiple trades (causing multiple execDetails() callbacks and multiple Execution objects with different execIds) and that the total traded volume could be different from what your order asked for. Your rules logic needs to properly handle that. But you are correct that the position callbacks only provide you with aggregate quantities.
Maybe you need a thin layer that related the rule instructions to the various order and execution events and that avoids the erroneous rule execution tiggered by certain execDetails call backs. You could probably use the orderRef field to tag orders so that you know which rule event it belongs to. orderRef is a string in the Order class that you can define as you like when you place the order, it is returned with all order related callbacks as well as in Execution objects you receive from execDetails callbacks. If the rule, for example, says "sell 120" but that takes place in three trades of 100 + 10 + 10, your logic knows that those three execDetails() callbacks and Execution objects relate to that one rule event. And it also would know in case the actually traded volume is different from what the rule asked for.
闯ü谤驳别苍
?
On Tue, Nov 19, 2024 at 07:00 AM, <simon.meier1987@...> wrote:
toggle quoted message
Show quoted text
I do not have the callback functions tradeReports(...) + tradeReportEnd(...) . When i make the request with reqExecutions(...), i receive the information through execDetails(...) and execDetailsEnd(...). How do i receive real-time reports ? Maybe i can use these functions in a java application? I program in c++ and i didn't find these in the documentation page. ?
?
The software behaves like i explained no matter what time. In my case it does not matter if the exchange is open or not.?
?
Exactly. A reliable working "position monitor" is what i need (for stocks and for futures). In my case for a symbol i have several trading rules and each of them manages a certain part of the aggregated position. Sometimes it happens that the statistic that a trading rule "contains" is not valid anymore and then it wants to close its part of the position. So i need the executions, because only then i can assign the closed order to the corresponding rule. As far as i know the position(...)-callback only delivers the aggregated position ( if so, -> not applicable). ?
?
With ---> "By using the position(..) + positionEnd(...) ? In my case it sends the close again and basically opens the symbol in the other direction" <--- I meant that if i do not receive the message that says "there was a execution of selling/buying 60 apple stocks" my system sends the request again, so that (sometimes) there will be another execution that either increments the postion to an unwanted amount (here 120 apple stock) or closes it again that this leads to selling short position. This is a critical error. ?
?
As a side note: i configured the tws in such a way to receive the 7 days of executions and i like to make use of that fact that there is always "enough time" (repeated sending) to complete the position monitor as the callback should send this information repeatedly. ?
But i will have a look at the position(...) and positionEnd(...) callback functions. Maybe they can solve at least a part of my problem
?
regards
Simon