in IB java api, you overwrite the tickPrice() function as entry to your blackbox. Each time a new tick price comes in, tickPrice() is called.
public void tickPrice(int tickerId, int field, double price,int canAutoExecute )
{
call_my_blackbox(price);
}
IB is down for the night so i cant test, but i am assuming tickPrice() is asynchronous. This is fine most times as call_my_blackbox will finish processing the tick price before the next tick price comes.
But in fast moving markets, if the next tick price comes in before the previous one is processed by call_my_blackbox(price), you are going to run into the classic data corruption problem with threading.
I am curious how everyone deals with this problem, do you synchronize call_my_blackbox(price). That cant be the solution because it will just backup the tick price and make your system lag behind real time.
The other solution is if the blackbox is still processing, to skip the next tick price completely, and keep skipping until call_my_blackbox finishes processing, but that will mean the next tick price data could be a big jump from previous one, throwing off the system.
Any coders here who can offer some insight on dealing with this particular issue.
public void tickPrice(int tickerId, int field, double price,int canAutoExecute )
{
call_my_blackbox(price);
}
IB is down for the night so i cant test, but i am assuming tickPrice() is asynchronous. This is fine most times as call_my_blackbox will finish processing the tick price before the next tick price comes.
But in fast moving markets, if the next tick price comes in before the previous one is processed by call_my_blackbox(price), you are going to run into the classic data corruption problem with threading.
I am curious how everyone deals with this problem, do you synchronize call_my_blackbox(price). That cant be the solution because it will just backup the tick price and make your system lag behind real time.
The other solution is if the blackbox is still processing, to skip the next tick price completely, and keep skipping until call_my_blackbox finishes processing, but that will mean the next tick price data could be a big jump from previous one, throwing off the system.
Any coders here who can offer some insight on dealing with this particular issue.