¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Date

Re: EClientSocket needs EReaderSignal (java)

Russell Brown
 

You need to implement the eclientsocket interface to use each function of the socket.

example:

class myclient implements eclientsocket

... declare each interface method following

--------------------------------------------

On Tue, 12/29/15, andreasschober <no_reply@...> wrote:

Subject: [TWS API] Re: EClientSocket needs EReaderSignal (java)
To: TWSAPI@...
Date: Tuesday, December 29, 2015, 2:49 PM

Thanks for your
suggestion, there isnt a specific reason other than i wanted
to understand what this EReaderSignal is for!

Much appreciated your help
Andy


Re: EClientSocket needs EReaderSignal (java)

rholowczak
 

What is the rest of the error message (should be a full stack trace)?
What client are you working with TWS or IB Gateway? What versions of those are being used? Are you connected to IB under your own account or edemo? ?Are you certain you are building against the version 9.71 API?
What JDK are you using? What OS are you using? What contract specification did you use?

There are dozens of reasons why an application like this will not run so the more information you supply the better chance anyone has of helping you.

I just uploaded a second version of the full source code that works with the IB API 9.72 (see the (new) last page of my Tutorial for the full code: Programming Interactive Brokers Java API in a Console Application - Real Time Data). You'll need JDK 1.8, IB API 9.72. ? This is very quick&dirty implementation and should not be used for any real work.

The major difference between 9.71 and 9.72 is how the EReader is implemented. In 9.71 all of the functionality of the EReader was included in the "client". ?In 9.72 the work of the client (all of the methods to connect and kick off requests) is separated form the EReader (that reads incoming messages).




Re: EClientSocket needs EReaderSignal (java)

andreasschober
 

...actually just having tried your code with (Realtime) with v9.71 i get an EOF exception.

What happens after you send client.connect()..
shouldnt there be a routine for handling the incoming data?

Rgds

java.io.EOFException


Re: EClientSocket needs EReaderSignal (java)

 

I would agree with the advice to avoid the 9.72 API at the moment.



I¡¯m involved in contributing to the API development effort on GitHub, and I¡¯m hoping to persuade IB to change this rather odd design, that forces the client to create objects that are only of internal relevance to the API. I haven¡¯t yet had any feedback on my proposal, which I submitted quite some time ago, so I¡¯m not optimistic that they¡¯ll listen to my concerns, but I¡¯m still hoping they¡¯ll appreciate the benefits of it.



To answer your question, the EReaderSignal is of no significance at all to the API client: it is only used internally to the API for synchronising access to a queue of messages. There is absolutely no reason I can see for the client to have to create this object.



Richard



From: TWSAPI@... [mailto:TWSAPI@...] On Behalf Of andreasschober
Sent: 29 December 2015 19:49
To: TWSAPI@...
Subject: [TWS API] Re: EClientSocket needs EReaderSignal (java)





Thanks for your suggestion, there isnt a specific reason other than i wanted to understand what this EReaderSignal is for!



Much appreciated your help

Andy













[Non-text portions of this message have been removed]


Re: EClientSocket needs EReaderSignal (java)

andreasschober
 

Thanks for your suggestion, there isnt a specific reason other than i wanted to understand what this EReaderSignal is for!

Much appreciated your help
Andy





Re: EClientSocket needs EReaderSignal (java)

Stuart Brisgel
 

¿ªÔÆÌåÓý

Will pay for that ... Just don't want to program it :)?

Sent from my iPhone

On Dec 29, 2015, at 12:48 PM, rholowczak <no_reply@...> wrote:

?

Is there a specific reason you want/need to use the 9.72 API (which appears to me to still be a Beta version)?

If you are just starting out trying to learn how the API works, you might want to stick with the more stable 9.71.


Re: EClientSocket needs EReaderSignal (java)

rholowczak
 

Is there a specific reason you want/need to use the 9.72 API (which appears to me to still be a Beta version)?
If you are just starting out trying to learn how the API works, you might want to stick with the more stable 9.71.


Re: EClientSocket needs EReaderSignal (java)

Stuart Brisgel
 

¿ªÔÆÌåÓý

Would love to pay someone to make it :)?

Sent from my iPhone

On Dec 29, 2015, at 12:19 PM, rholowczak <no_reply@...> wrote:

?

I'll be updating my tutorials over the winter break and will use the latest TWS API (the tutorials were developed using version 9.71)?


Re: EClientSocket needs EReaderSignal (java)

rholowczak
 

I'll be updating my tutorials over the winter break and will use the latest TWS API (the tutorials were developed using version 9.71)?


Looking for an EXCEL DDE API Interactive Brokers GURU

 

Hello Yall



End of the year which means get all those projects done that you have always wanted.? This is more of the same as we are looking for someone to build a simple excel sheet that pulls live data from IB.? Any recommendations or people interested?


Thanks



EClientSocket needs EReaderSignal (java)

andreasschober
 

Hi Im trying to get a simple code to work but dont understand how to implement EClientSocket,


which needes EWraper and also EReaderSignal as input.


I looked at other codes and EClientsocket is alwas calledwith "this"


.. EClientSocket client = new EClientSocket(this) ....




Have a look at this code from Prof H.




It doesnt seem to work either with the new 9.72 version of TWS.



Thanks

for your input


Andy




Re: TWS 50/sec limit

 

Ok everyone, we have beat that subject into the ground and?there is a solution. I however, am not a skilled developer and need help with the code. Can all interested parties jump back over to my original subject, "Building an options trading algo using TWS. Need some help!?"? In that topic,?I have detailed the trade entry portion. Is someone interested in developing the entire system for a fee?


Re: Stale quantity in open order event

 

Well, although there may be something specific to this situation that can be improved, I expect that with asynchronous communication buffered in both directions (which is usually more performant than a synchronized API) and possibly multiple servers, to some degree you may always receive status messages that were already en route before you changed the order, for example.


Re: TWS 50/sec limit

Nick
 

It is good you point this out. I should have been clear that my post was directed to the OP's claim that he could not download an option chain due to a fault in TWS.

Regarding "Disconnects are caused by an error in your program." - I suppose we could debate the meaning of "error" but I have no desire for that. I was trying to say that if he was getting a disconnect then he should be looking at his program for the cause, not TWS.

Regarding "TWS does not disconnect for pacing violations." - This was directed at his assertion that a large option chain reply was causing a pacing violation and that in turn was causing the disconnection. I was trying to say that pacing violations do not apply to replies sent by TWS. Although there are some pacing violations that don't cause disconnects (historical requests return a pacing violation error message) I should not have made an unqualified declaration.

So, thanks for being thorough and making things clear for those who may read these posts in the future. I will put effort into making posts that stand on their own.

On 12/25/2015 2:20 AM, Dmitry Shevkoplyas shevkoplyas@... [TWSAPI] wrote:
@Nick news1000,

I'm not sure how important it is, but the above exercise with java demo app
also shows that it is actually TWS who initiate the disconnect when client
brakes some rules (number of realtime subscribed tickers or exceed request
rate limits).

So then statement "Disconnects are caused by an error in your program."
seems to be not 100% right since there's no language/functionality scope
error - I mean the program itself is clean and does not crash nor does it
any wrong calls, but rather logical error (pacing) related to timing can
occur due to some reason ant then disconnect will be caused by TWS.

And then 2nd statement "TWS does not disconnect for pacing violations." is
not true. What I saw in described java demo app was:

*case-1: requested too many contracts simultaneously*
TWS does disconnect client when it brakes a limit (number of simultaneously
subscribed tickers).
TWS also brings nice modal popup alert with explanation as of why you've
been kicked out :)

*case-2: sent too many requests/second*
Then to check if similar disconnect (by TWS) happens in case of request
pacing I modified the demo app to send some bulk (about 950:)
reqContractDetails and saw similar behaviour: client kicked out by TWS
after 3 error/notes:


Re: Stale quantity in open order event

 

The last bad openOrder/status (450 ms since quan change request) is immediately followed by a good one with a filled status.? While manual changes are very rare, I do not want to start guessing which openOrder/status events should be ignored.? I have opened a ticket with IB.




From: "tron001@... [TWSAPI]"
To: TWSAPI@...
Sent: Saturday, December 26, 2015 11:22 PM
Subject: [TWS API] Re: Stale quantity in open order event

?
Frank, if you need to deal with unexpected arbitrary manual changes, your situation may be more complicated. However your example mentioned times of 45ms and 60ms, which are not really likely to be manual changes, unless you are really fast at typing. ;-)

In terms of your example, I was expecting "you" to know the "new" quantity, which would of course allow you?
sort out any openOrder and orderStatus messages which might refer to a different quantity.

By the way, was the message in step 6 an orderStatus message with fillled+remaining = old quantity, or was remaining already zero, yet the status not given as 'filled"? That would be strange.




Re: Stale quantity in open order event

 

Frank, if you need to deal with unexpected arbitrary manual changes, your situation may be more complicated. However your example mentioned times of 45ms and 60ms, which are not really likely to be manual changes, unless you are really fast at typing. ;-)

In terms of your example, I was expecting "you" to know the "new" quantity, which would of course allow you?
sort out any openOrder and orderStatus messages which might refer to a different quantity.

By the way, was the message in step 6 an orderStatus message with fillled+remaining = old quantity, or was remaining already zero, yet the status not given as 'filled"? That would be strange.


Re: Stale quantity in open order event

 

How do you identify outdated order status/open order events?? Since orders can be changed manually, just ignoring events that do not match my records is not sufficient.




From: "tron001@... [TWSAPI]"
To: TWSAPI@...
Sent: Saturday, December 26, 2015 7:50 PM
Subject: [TWS API] Re: Stale quantity in open order event

?
Or add logic to detect and ignore outdated orderStatus/openOrder messages. *As far as I know*, those messages which appear to be the latest (based on content like status or 'filled' quantity) can be relied upon. That is, status or 'filled' does't actually go backwards, and such messages can be ignored without causing further problems. (Apparently servers do things in parallel and responses aren't always in sequence.)



Re: Stale quantity in open order event

 

Or add logic to detect and ignore outdated orderStatus/openOrder messages. *As far as I know*, those messages which appear to be the latest (based on content like status or 'filled' quantity) can be relied upon. That is, status or 'filled' does't actually go backwards, and such messages can be ignored without causing further problems. (Apparently servers do things in parallel and responses aren't always in sequence.)


Re: Market Open or Closed

uberquant
 

I've found that if I ask for contract details for today when the market is open (during the session), it will generally give back that today for m_liquidhours (which is different from m_tradinghours) it is closed, but if I do it after the session closes it will show the next open day as being open. I've found this rather frustrating. Also watch out the time zones, for instance IB will report Belize which doesn't do daylight savings, instead of Chicago which does for VIX for instance

Quantlib has a helpful calendar functionality that lets you check whether any particular day is a business day in many markets. I use this as a second check if TWS returns today as closed and take tomorrow's opening times for today if needed. You can also use this to compute business days til expiration if it's relevant to your calculations.


Re: Market Open or Closed

 

Actually you can use ContractDetails and look for?m_tradingHours.

2015-12-25 8:42 GMT+01:00 Ed Gonen ed.gonen@... [TWSAPI] <TWSAPI@...>:

?

As far as I know there is no such method in the API. I suggest to keep as simple as possible and use a plain text file with the list of the market holidays times. You will update the file on a yearly basis manually. This¡¯s been working for us for many years.

?

E

?

?

?


From: jason_pulaski@... [TWSAPI]
Sent: Friday, December 25, 2015 2:44
To: TWSAPI@...
Subject: [TWS API] Market Open or Closed

?

?

today market closed at 1pm, I had a trade fire at 2pm.? How best can I tell that the market is open using the API, c# is what I'm using.

?

Thanks,

?

?

?

?

?




--
Best regards,
Chernikov Aleksandr,
e-mail:?me@...
skype:?
RU:?+7-904-179-49-78