[Chicago-talk] Talking to yourself or Java API revisited

Jay Strauss me at heyjay.com
Wed Dec 3 23:24:19 CST 2003

This is a bit convoluted (but its not my design, I just rebuilt the vendors
Java in Perl)

I build this class with a bunch of method like: tickPrice tickSize
orderStatus... call this class API
Then I build this class called TWS who connects (via sockets) to a stock
trading system, this TWS class has a bunch of methods like: connect
disconnect reqMktData placeOrder cancelOrder...

now in my script I do:
my $api = API->new;
my $tws = TWS->new($api);    # notice I passed in the API

# at this point TWS forks and the child process sits in a while(1) and reads
the socket, and calls the methods
# in the API as messages come down the wire from the stock system

# the other process (parent), does:

my $contract = Contract->new;

# at which point tick data start pouring in from the stock server, and the
API methods are called and everything is fine

I originally thought, I'll just stick the tick data as it comes into my
database and my other process will just read the database.  But on
retrospect, I'm stupid.  I don't want all that database activity.

So, my question is:
What options do I have of getting the API code to push data to parent

My initial thoughts are to turn my script into a POE server.  Then stick
some code into API to talk to the POE server
or is there a simplier way to get at the child's data?


More information about the Chicago-talk mailing list