I am experiencing seemingly high latency when using the
eClientSocket.placeOrder() function in the JAVA API of Interactive Brokers. It
seems to take 30 milliseconds for this socket connection to take place outside
of my JAVA program. This seems quite high, as I would think it should be around
1 millisecond. Here is my isolated code to test this latency (all variables have
been declared and code executes):
//////start code///////////////////////////////////////////////////////////
contract = createContract("SPY", "STK", "SMART", "USD");
order = createOrder("Buy", 1, "LMT", 1.00);
requestId = (int) (System.currentTimeMillis()/1000);
startTime = System.nanoTime();
eClientSocket.placeOrder(requestId, contract, order);
eClientSocket.placeOrder(requestId+1, contract, order);
estimatedTime = System.nanoTime()-startTime;
//Print nanosecond time to complete place order code//
System.out.println("Time to complete in code: " + estimatedTime);
////end code///////////////////////////////////////////////////////////////
The code after running posts a software latency of 3,172,000 ns of latency or
around 3.2 milliseconds. This would mean 1.6 milliseconds per placeOrder. Yet
the submit times Interactive Brokers gives me are 30 milliseconds apart. Which
means that each function takes 30 milliseconds to develop before actually being
sent to Interactive brokers. I know this delay exists for both orders, and will
break it down as such.
At 0 milliseconds my posted code starts
At 1.6 milliseconds the first placeOrder is being developed by my computer.
At 3.2 milliseconds the second placeOrder is being developed
At 31.6 milliseconds the first placeOrder is sent
At 33.2 milliseconds the second placeOrder is sent
At 39.6 milliseconds IB receives my first order, 8 ms to IB (from ping)
At 41.2 milliseconds IB receives my second order, 8 ms to IB
Could someone please help me remove this 30 milliseconds latency in the
eClientSocket.placeOrder() function?
I believe I've isolated the latency, and I believe it's not due to any risk
checking on IB's end nor internet latency nor my java code. It seems to be
entirely within the eClientSocket java class.
Best,
Joe
eClientSocket.placeOrder() function in the JAVA API of Interactive Brokers. It
seems to take 30 milliseconds for this socket connection to take place outside
of my JAVA program. This seems quite high, as I would think it should be around
1 millisecond. Here is my isolated code to test this latency (all variables have
been declared and code executes):
//////start code///////////////////////////////////////////////////////////
contract = createContract("SPY", "STK", "SMART", "USD");
order = createOrder("Buy", 1, "LMT", 1.00);
requestId = (int) (System.currentTimeMillis()/1000);
startTime = System.nanoTime();
eClientSocket.placeOrder(requestId, contract, order);
eClientSocket.placeOrder(requestId+1, contract, order);
estimatedTime = System.nanoTime()-startTime;
//Print nanosecond time to complete place order code//
System.out.println("Time to complete in code: " + estimatedTime);
////end code///////////////////////////////////////////////////////////////
The code after running posts a software latency of 3,172,000 ns of latency or
around 3.2 milliseconds. This would mean 1.6 milliseconds per placeOrder. Yet
the submit times Interactive Brokers gives me are 30 milliseconds apart. Which
means that each function takes 30 milliseconds to develop before actually being
sent to Interactive brokers. I know this delay exists for both orders, and will
break it down as such.
At 0 milliseconds my posted code starts
At 1.6 milliseconds the first placeOrder is being developed by my computer.
At 3.2 milliseconds the second placeOrder is being developed
At 31.6 milliseconds the first placeOrder is sent
At 33.2 milliseconds the second placeOrder is sent
At 39.6 milliseconds IB receives my first order, 8 ms to IB (from ping)
At 41.2 milliseconds IB receives my second order, 8 ms to IB
Could someone please help me remove this 30 milliseconds latency in the
eClientSocket.placeOrder() function?
I believe I've isolated the latency, and I believe it's not due to any risk
checking on IB's end nor internet latency nor my java code. It seems to be
entirely within the eClientSocket java class.
Best,
Joe
