开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: twsapi: Java API


usernew
 

I need to get info on n tickers, so this is what I do at the moment:

tws.connect();
for(i=0; i<n; i++){
tws.requestdata(...)
}
tws.wait_trans(); // to make sure all the prices have arrived
tws.disconnect();

// prices have arrived
// so do stuff here

Looking at the docs for request data, because I need info on n
tickers, seems I would have to call requestdata n times

My concern was making tws.wait_trans() not consume cycles.

--- In twsapi@y..., "David" <kotomo@p...> wrote:
usernew,
maybe i do not know what you want or misunderstand TWS control but
you need to send requestData() only once - you can do it before the
session.
David
----- Original Message -----
From: usernew
To: twsapi@y...
Sent: Wednesday, June 19, 2002 3:56 AM
Subject: Re: twsapi: Java API


So you are saying tickPrice, tickSize etc. are guaranteed to
happen
by the time requestData() returns ? I thought tickPrice etc. were
completely asynchronous.

--- In twsapi@y..., Todd Turner <todd_a_turner@y...> wrote:
> I believe that the callbacks only occur during a call
> to requestData().
>
> In my initial testing I used Sleep with no problem. I
> now have Windows sending a WM_TIMER message to my apps
> message queue every 250 msecs now.
> --- usernew <no_reply@y...> wrote:
> > Yeah, I tried that and got exceptions. The problem
> > might be that when
> > you sleep the whole thread is put to sleep, so the
> > event tickprice
> > etc. callbacks can't happen. So, a regular sleep
> > might not work well
> > in this case.
> >
> > --- In twsapi@y..., Todd Turner <todd_a_turner@y...>
> > wrote:
> > > I am not familiar with Java, but you need some
> > sort of
> > > system call Sleep(int timeout_msecs), so that the
> > > process blocks until the timeout occurs. This
> > > functionality is provided by the OS.
> > >
> > >
> > > --- usernew <no_reply@y...> wrote:
> > > > My program currently is structured as follows:
> > > >
> > > > class TWS implements EWrapper {
> > > > public void requestdata(...)
> > > > public void tickPrice(...)
> > > > public void tickSize(...)
> > > > ...
> > > > public void wait_trans() {
> > > > for(i=0; i < xxxxx; i++);
> > > > }
> > > > }
> > > >
> > > > public class Main {
> > > > tws.connect();
> > > > for(i=0; i<n; i++)
> > > > tws.requestdata(...)
> > > > tws.wait_trans();
> > > > tws.disconnect();
> > > > }
> > > >
> > > > Is there a better way to structure this program
> > ?
> > > >
> > > > My concern is wait_trans(). It is continuously
> > > > eating up cycles. My
> > > > program does not need to do anything while it is
> > > > waiting for the
> > > > arrays to be populated, but I would still like
> > to
> > > > wait without
> > > > consuming cycles.
> > > >
> > > > Thanks in advance
> > > >
> > > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! - Official partner of 2002 FIFA World Cup
> > >
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
>


Yahoo! Groups Sponsor
ADVERTISEMENT




To unsubscribe from this group, send an email to:
twsapi-unsubscribe@y...



Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.

Join [email protected] to automatically receive all group messages.