cmarcourt / neo-ib-api

Automatically exported from code.google.com/p/neo-ib-api
4 stars 4 forks source link

IB Generated Auto IDs are ignored. #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Place an order using TWS.
2. Request 'RetrieveOpenOrderRequest' or 'RetrieveAllOpenOrderRequest' through 
Session.
3. Place breakpoint on line 76 of 
ch.aonyx.broker.ib.api.order.RetrieveOpenOrderEventCreatingInputStreamConsumer.c
onsumeOrder(...).

What is the expected output? What do you see instead?
Expected Output: 'final int id' provided in the method arguments should be set 
at the OrderID, even if it is an IB generated ID. Alternatively, neo-should 
generate an ID and bind it to the IB provided int orderID.
Actual Output: After neo-ib-api tries to retrieve the orderId through 
OrderIdInternalIdBinding.getInstance().getOrderId(id), as there's no matching 
IB orderID in the OrderIdInternalIdBinding.binding, 'null' is returned as the 
OrderID, which is incorrect.

What version of the product are you using? On what operating system?
neo-ib-api versions:
<dependency>
    <groupId>ch.aonyx.broker.ib</groupId>
    <artifactId>neo-ib-api</artifactId>
    <version>1.1.0-SNAPSHOT</version>
</dependency>

Java version:
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)  

OS version:
Darwin DrewMBP.local 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 
PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64

Please provide any additional information below.

I've attached screenshots from eclipse showing what happens with the incoming 
ID (final int id, in this case -2) and the value of Order.id before and after 
line 76.

Original issue reported on code.google.com by drew.so...@gmail.com on 30 Mar 2013 at 1:21

Attachments:

GoogleCodeExporter commented 9 years ago
I don't know how this kind of fix would fit within your architecture, but in a 
similiar manner to:
    ch.aonyx.broker.ib.api.OrderIdInternalIdBinding.addAndBind(final Request request);
change 
     ch.aonyx.broker.ib.api.OrderIdInternalIdBinding.getOrderId(final int internalId);
to:

Id getOrderId(final int internalId) {
    Id newId = binding.inverse().get(internalId);
    if(newId == null && internalId != 0) {
        newId = sequence.getAndIncrement();
        binding.put(internalId, newId);
    }
    return newId;
}

Original comment by drew.so...@gmail.com on 30 Mar 2013 at 1:29

GoogleCodeExporter commented 9 years ago

Original comment by cmarco...@gmail.com on 1 Apr 2013 at 7:53

GoogleCodeExporter commented 9 years ago
Thank you for looking at this! Let me know if I can assist you in any way! :-)

It's a lot easier to get the bug fixed at the maven source, so I don't have to 
manage the dependencies myself, so I am very appreciative of you looking at 
this!

Original comment by drew.so...@gmail.com on 1 Apr 2013 at 7:56

GoogleCodeExporter commented 9 years ago
Hello,

First of all, your solution to fix the problem is not good as sequence is an 
AtomicInteger object and newId is an Id object.
Second of all you are using negative order id IB generation. So the solution to 
always increment is not good also.

Have you tried using positive order id generation ? (It won't fix the problem 
with the RetrieveOpenOrderRequest)

Original comment by cmarco...@gmail.com on 1 Apr 2013 at 8:12

GoogleCodeExporter commented 9 years ago
Check for positive and negative order id generation to increment or decrement.
Create on the fly OrderId when retrieving open orders from IB when orders were 
not generated by Neo API.

Original comment by cmarco...@gmail.com on 1 Apr 2013 at 8:47