penberg / helix

Helix, a market data feed handler for C and C++.
Other
110 stars 35 forks source link

exceptions / throw #17

Open ghost opened 9 years ago

ghost commented 9 years ago

when you start a trading system in the middle of a day (it's often needed) history of orders is not available. therefore there is 100% chance of getting a lot of "invalid_argument(string("invalid order id: ") + to_string(order_id))" exceptions (hundreds).

as you probably know exceptions takes a lot of time to process in C++ unfortunately. i believe we should get rid of all the "throw" clauses.

jvirtanen commented 9 years ago

@divaykin Isn't there usually always some kind of facility (backfill or spin) for catching up on historical market data from earlier in the currently active trading session?

ghost commented 9 years ago

yes there is but with error codes instead of exceptions it'd be much less. make sense @jvirtanen ?

jvirtanen commented 9 years ago

@divaykin If there are trading venues where you have to request historical market data on e.g. order identifier basis, I agree with your sentiment.

I'm only familiar with trading venues, such as BATS or NASDAQ, where you either request a spin upon startup or go into backfill on the first market data message based on a higher-than-expected sequence number. In such circumstances, these exceptions would be thrown only in error situations.

ghost commented 9 years ago

i think that even just any catch statement in the caller code is not completely free of performance penalty. and then there could be a gap in your multicast feed. essentially i don't see much benefits of exceptions at all in the feed handler

dsimba commented 5 years ago

Exceptions are just bad for performance. If at all possible, better to handle the issue if it is predictable.