i’m trying to understand the orders logic so i’ve developped a fast addons that contains a simple TextBlock and OrderUpdate event is catched i get the order infos and print they in the texbox
but sometime i’ve an “combined event” that seems the same event repeated and i cant understand the reason. This is the output of one sell limit order. The event is called 4 times but the first 2 times the the orderState is the same. It’s occurs also when i delete an order but seem to be random
asking to IA seems that this issue is a critical point of ninjatrader. I think that this can not be true but one solution should be using “a logic” to filter duplicate events checking the new orderstate with the last received for the same orderID but really i’m not thinking that this should be a real solution.
i’ve watched the code of the 2 tradecopier in ninjaecosystem and also uses OrderUpdate but i cant see any kind of filter
There are no “duplicate” events. It’s doing its job. Events are not supposed to hold some kind of state. It’s just a notification. It’s up to you to implement whatever filter you need when you get the notification. For example, if you need to keep track of the orders for your purpose then you need to implement that yourself. Once you get a notification from the function.
ok but read my first post. Why OrderUpdate should be called more time if the orderstate remains the same ? If you read the first 2 lines you can see the same orderId, same sender, same orderstatus= submitted. I’m setting only 1 order 1 time but ther orderupdate event is called 2 times
It doesn’t matter if it occurred a million times. It’s just a notification. The user is responsible for handling the notification. Something just fires off a notification to it and you as the developer will have to do something when you get notified.
Thanks, I understand now, as per your link:
" Basic event correlation: A consumer processes a few discrete business events, correlates them by some identifier, and persists information from earlier events for use when processing later events"
This is a common design pattern so threads don’t get blocked (waiting for something to complete). Threads will just sit around using the resources while not doing anything if its just waiting for a task to finish.
I don’t know enough about TradeCopierFree. In that function, it appears that it has logic to check whatever it needs. The point is that whenever function gets notified you do something with it even if you are seeing the same data. For example, just don’t do anything if the data is the same and only do something if its different.
Thanks! Looking at the TradeCopierFree code again, multiple events of the same kind would not affect the flags (isFilled, isLimitOrStop, isSubmittedNotCancelled).
@BillMilton i’ve looked that code and it ignore all the other status (they dipended by broker/dataprovider) so the duplicate events seems to not modify the logic. Is an idea… my alternative idea was do a dictionary or an hashset of all the order events and check by orderId and orderState the duplicates but the tradeCopierFree solution seems to be better.
I will think about it tomorrow, it’s 12 pm here