SDK issues

fugaz

Member
Joined
Jun 16, 2025
Posts
5
Likes
0
Hello forum
I'm having a couple of issues with a custom strategy.
1. onOrderFilled doesn't seem to be triggered. Not sure how to debug this. Any ideas?
2. I'm trying to get open positions with OrderContext.getPosition() onSignal but unsuccessfully. If I go with OrderContext.getAccountPosition() of course I get the correct position. My understanding is that strategy positions should be automatically reported, or do I have to set something after submitting an order (or maybe onOrderFilled, see 1.)

I'm with Interactive Brokers FWIW, don't know if there is an issue with their API.
 
I don't know your exact implementation, but one thing that might lead to what you are seeing is that onOrderFilled() and getPosition() only work for orders which have been placed by the very strategy that implements these methods. So if for example you are trying to track orders that have been placed manually by the user or by another strategy, you wouldn't be notified by any hook and not be able to access them from within your strategy. Maybe there is a way, but unfortunately I haven't found one yet.
 
Thanks @Liquinaut
I didn't mention it in my message but yes, this is the case. Orders are from the same strategy.
I was even wondering if it's an (a)synchronous call issue (it is written in the doc that submitOrders() is synchronous, maybe onOrderFilled() it's not).
Are there any other debug options beyond the output log and the study log (which are basically the same)?
 
onOrderFilled() surely is asynchronous, as it is an event hook called from outside whenever a broker order fill confirmation occurs. But if you have implemented it in your strategy it should fire whenever that happens. Have you tried writing a simple debug output to the log file from within onOrderFilled() to see if it actually is getting called?
 
ok this is my code:

@Override
public void onOrderFilled(OrderContext ctx, Order order) {
this.info("onOrderFilled: " + order);
if (order == entryOrder) {
this.info("entryOrder filled: createExit");
createExitOrders(ctx);
} else {
this.info("order filled: "+order);
ctx.cancelOrders();
}
super.onOrderFilled(ctx, order);
}

and this is the log (paper account)

12:28:06.520 INFO RSI(14): enter long
12:28:06.535 INFO ServiceHome::placesOrders() placing order: ID: 174 DU3220866 FESX 20251219 M.EUREX.IB (FESX 20251219 M) New BUY MKT Qty:1.0 GTC
12:28:06.542 INFO IBService::placeOrder(): id: 1 local symbol:FESX 20251219 M exchange:EUREX pExchange:null currency:EUR outsideRTH:true expires:null
12:28:06.723 WARNING error() reqId: 1 code: 2109 msg: Order Event Warning:Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now being processed. FESX 20251219 M.EUREX.IB
12:28:06.781 INFO IBListener::createIBOrder() id: 1 type: MKT status: PreSubmitted action: BUY limit: 5764.0 auxPrice: 0.0 trailStop: 5765.0 parentId: 0 created: false
12:28:06.783 INFO orderStatus() orderId: 1 status: PreSubmitted filled: 0 remaining: 1 avgFillPrice: 0.0 permId: 314567999 parentId: 0 lastFillPrice: 0.0clientId: 10 whyHeld: null orderFilled: 0.0 orderRemaining: 1.0
12:28:06.794 INFO position() account: DU3220866 symbol: ESTX50 local symbol: FESX 20251219 M exchange: null pexchange: null type: FUT position: 1 avgCost: 57640.0
12:28:06.807 INFO IBListener::execDetails() reqId: -1 permId: 314567999 execId: 0000e9b5.693f9cf7.01.01 clientId: 10 orderId: 1 symbol: FESX 20251219 M exchange: EUREX pexchange: null type: FUT avgPrice: 5764.0 price: 5764.0 side: BOT qty: 1 shares: 1 time: 20251215 12:28:06 Europe/Paris
12:28:06.808 INFO IBListener::execDetails() notifying order: 1
12:28:06.808 INFO orderStatus() orderId: 1 status: Filled filled: 1 remaining: 0 avgFillPrice: 5764.0 permId: 314567999 parentId: 0 lastFillPrice: 5764.0clientId: 10 whyHeld: null orderFilled: 0.0 orderRemaining: 1.0
12:28:06.808 INFO OrderDirectory::orderFilled() (2) order: ID: 1 DU3220866 FESX 20251219 M.EUREX.IB (FESX 20251219 M) Filled BUY MKT Limit:5764.0 Qty:1.0 GTC Last Fill Time: 12/15/2025 12:28 PM has already been filled! DU3220866:1
12:28:06.811 WARNING Ignoring duplicate order status: 1:Filled:1:0:5764.0:314567999:0:5764.0:10:null
12:28:06.812 INFO position() account: DU3220866 symbol: ESTX50 local symbol: FESX 20251219 M exchange: null pexchange: null type: FUT position: 1 avgCost: 57642.0

Actually there is something weird with the already been filled thing. May that be the cause?
 
Yeah you're right that does look weird. It may well be in issue with the IB API, but I really don't know.
Better write to support and send in your logs as well. Also maybe someone else has an idea?
 
@fugaz as of what I have used, generally the onOrderFilled works. You could check running the strategy in simulation or replay mode.

If it works with simulation/replay, then can conclude that the issue might be related to IB API.
 
Only Canadian equities were impacted by the IIROC (a Canadian regulatory body) decision in September 2024 to prohibit the trading of Canadian equities via 3rd party software including Motivewave and Tradingview platforms. Everything else should be unaffected.

Just place the order manually in IB if it is not working.
 
@fugaz as of what I have used, generally the onOrderFilled works. You could check running the strategy in simulation or replay mode.

If it works with simulation/replay, then can conclude that the issue might be related to IB API.
thanks @John A are you using IB? FWIW, I remember having it working, but inconsistent behaviour. what's puzzling me it the line in the logs where we see that the order is filled, thus the API should see it...
I tried to report this to the support but they're not willing to help, which is quite disappointing
 
Top