Invaluable indeed.  I&#39;ve studied the docs,  installed the product, <br>and have been following the discussion, and am extremely impressed.<br><br>Thank you Bill and other project members for sharing your thoughts and <br>

resulting work.  <br><br>BTW, I would also love to see any more info, or better yet even an alpha <br>version of a sample client to help tie things together.  I suspect that some <br>or many here may know enough to appreciate the elegance and sophistication <br>

of the shim concept and product, but like myself struggle to produce a client from <br>the ground up.  <br><br>In any event, the main point is thanks.<br><br>Regards,<br>Michael<br><br><br><br><div class="gmail_quote">On Fri, Aug 28, 2009 at 23:09, Ken Feng <span dir="ltr">&lt;<a href="mailto:kfmfe04@gmail.com">kfmfe04@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Bill,<br>
<br>
I appreciate your taking the time to comprehensively describe a<br>
sensible approach to designing the downstream client.  It&#39;s a great<br>
wrap-up, answering many of the questions I have had this week on the<br>
mailing list.<br>
<br>
The examples in exs are fantastic for getting our feet wet, but as you<br>
mentioned,<br>
<div class="im"><br>
&gt; It would be nice to provide example code via a ruby sample client,<br>
&gt; and that&#39;s just one of many things we haven&#39;t completed yet.<br>
<br>
</div>I look forward to seeing an example one of these days, but I believe<br>
you have provided enough of a roadmap for me to continue coding an<br>
approach in Ruby.  Generally, I am indifferent to a particular<br>
language or platform, insomuch as picking a tool doesn&#39;t &quot;make life<br>
hard for me&quot; in terms of implementation or maintenance.<br>
Unfortunately, my engine for generating signals/orders in C++ is<br>
sufficiently large/complex that I do need to interface to it somehow.<br>
As you have very well described in your posts, I share you abhorrence<br>
of any thought of duplicating such code.  I was walking down the<br>
approach of a &quot;poor man&#39;s IPC&quot; via MySQL and crontab&#39;ed writes and<br>
reads into the database, but I may be able to avoid that with your<br>
Ruby hints.<br>
<br>
My indifference towards languages has also led me to a hodge-podge of<br>
programs and tools for getting the job done.  I am fine with this, but<br>
it is certainly not pretty for other developers who are trying to<br>
understand my code - but that&#39;s a different story.<br>
<br>
Having said that, I actually like Ruby and prefer it over all others<br>
for any type of scripting (though I hear Python is also quite good) -<br>
Ruby&#39;s conciseness, intuitiveness, richness of API, and delivery of<br>
its promise of &quot;least surprises&quot; are all quite impressive.  I will<br>
definitely search popen3() and select() in Ruby - thank you for<br>
pointing me in the right direction.<br>
<br>
I will hard-code my triplet response code this time in Ruby, but I do<br>
look forward to the day when I can refactor it to be driven by a shim<br>
table instead.<br>
<br>
BTW, if you haven&#39;t done so already, I hope you do copy-and-paste<br>
these three posts into the new documentation.<br>
<br>
I am certain that users who are at the last stage of downstream client<br>
design/development would find these notes invaluable, as I have.<br>
<br>
Regards,<br>
<font color="#888888">Ken<br>
</font><div><div></div><div class="h5"><br>
On 8/29/09, Bill Pippin &lt;<a href="mailto:pippin@owlriver.net">pippin@owlriver.net</a>&gt; wrote:<br>
&gt; Ken,<br>
&gt;<br>
&gt; With respect to your questions about downstream architectural<br>
&gt; approaches to the IB tws api, this post focuses on the following<br>
&gt; question:<br>
&gt;<br>
&gt;     How might a ruby sample client, an example program to interface<br>
&gt;     with the shim, be designed, what parts of the code would be<br>
&gt;     provided, what parts would be supplied by client users, and in<br>
&gt;     the absence of such a sample client in the shim tarball for now,<br>
&gt;     what might users write in its place?<br>
<br>
&gt;<br>
&gt; To recap, such a program would apply user-specific criteria to perform<br>
&gt; the following types of tasks:<br>
&gt;<br>
&gt;     * ask for market data;<br>
&gt;     * interpret such data;<br>
&gt;     * generate orders; and<br>
&gt;     * manage positions.<br>
&gt;<br>
&gt; Once given an IB tws account, and the shim, then the shim command<br>
&gt; language would be used to generate api requests, and the shim cout<br>
&gt; option could be used to ensure that the resulting message traffic,<br>
&gt; and indeed the entire integrated event stream, were accessible to<br>
&gt; the client.  That much is obvious, and leaves us a long reach from<br>
&gt; the task goals above.  What else?<br>
&gt;<br>
&gt; A.  Main.<br>
&gt;<br>
&gt; Once given initialization, about which more later, there would be<br>
&gt; a main loop to process events; input for that loop would be read<br>
&gt; via the select() system call, provided in ruby; and the two input<br>
&gt; streams from the shim provided via the popen3() system call, the<br>
&gt; stdin and stderr, would be multiplexed via select() .  The input<br>
&gt; would be selectively converted to event objects via table-driven<br>
&gt; code, which brings us back to initialization.<br>
&gt;<br>
&gt; B.  Init<br>
&gt;<br>
&gt; Prior to entering the main loop, event descriptions from a sql<br>
&gt; database would be read in, and used to generate: event classes, the<br>
&gt; related data members, and constructor code which would take as<br>
&gt; input a split array from a text input line.  The result would be an<br>
&gt; admittedly large quantity of automatically generated boilerplate<br>
&gt; none of which would need or warrant human maintenance.<br>
&gt;<br>
&gt; C.  Processing<br>
&gt;<br>
&gt; The client user would still be responsible for writing: the<br>
&gt; definitions of non-empty process operations for each message event;<br>
&gt; as well as strategy code that would use input from such processing,<br>
&gt; presumably to generate signals and/or orders.<br>
&gt;<br>
&gt; D.  User input<br>
&gt;<br>
&gt; The client user would still be responsible for writing: gui screens,<br>
&gt; or code to accept yet another layer of downstream command input, if<br>
&gt; so desired.  As previously noted, the select() system call could be<br>
&gt; used to multiplex the three input streams of other client/human<br>
&gt; control, events from the shim cout, and exceptional messages from<br>
&gt; the shim stderr.<br>
&gt;<br>
&gt; E.  What for now?<br>
&gt;<br>
&gt; As for (c) and (d), above, that&#39;s the user&#39;s responsibility in any<br>
&gt; case, and so about which no more.<br>
&gt;<br>
&gt; As for (a), users should already be using popen3() or its equivalent<br>
&gt; in their favorite scripting language, and select() ditto, in any case;<br>
&gt; or else they may choose threads, in which case that&#39;s their business,<br>
&gt; and outside the scope of these list messages.<br>
&gt;<br>
&gt; It would be nice to provide example code via a ruby sample client,<br>
&gt; and that&#39;s just one of many things we haven&#39;t completed yet.<br>
&gt;<br>
&gt; As for (b), this is the serious gap, and all I can say is that study<br>
&gt; of rule.c and apis.c may help, but is a non-trivial effort.  I fully<br>
&gt; intend to define sql create table and insert statements to provide<br>
&gt; table definition of the api events, but such work is intimately coupled<br>
&gt; with versioned api-level event processing, our next major work effort.<br>
&gt; It&#39;s just not done yet.  Sorry.  Feel free to read rule.c, and apis.c,<br>
&gt; and for that matter EClientSocket.java and EReader.java.<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Bill<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; ts-general mailing list<br>
&gt; <a href="mailto:ts-general@trading-shim.org">ts-general@trading-shim.org</a><br>
&gt; <a href="http://www.trading-shim.org/mailman/listinfo/ts-general" target="_blank">http://www.trading-shim.org/mailman/listinfo/ts-general</a><br>
&gt;<br>
_______________________________________________<br>
ts-general mailing list<br>
<a href="mailto:ts-general@trading-shim.org">ts-general@trading-shim.org</a><br>
<a href="http://www.trading-shim.org/mailman/listinfo/ts-general" target="_blank">http://www.trading-shim.org/mailman/listinfo/ts-general</a><br>
</div></div></blockquote></div><br>