[ts-gen] Fair merge
Ken Feng
kfmfe04 at gmail.com
Wed Sep 16 01:35:23 EDT 2009
Hi Bill,
Thanks for posting this - it's functionally equivalent to a simple
table mapping, but very readable since it's all in Ruby.
I will convert my code to follow your pattern...
- Ken
On 9/16/09, Bill Pippin <pippin at owlriver.net> wrote:
> Nils,
>
> About selecting specific events from the shim's log stream, as opposed
> to using two shim sessions:
>
>> ... There is one small reason [for multiple shim sessions] ...
>> a small order reference log file without the tick noise makes
>> it easier to control the order flow / status situation by inspection.
>
> Selected, user-focused displays are of course important. As the first
> step in choosing which events to display, it would be straight forward
> but clumsy to use tail -f and grep with the --line-buffered option.
> Since this would not scale very well for feature extension, a scripting
> language such as ruby is probably the better option for the grep'ing
> stage.
>
> The key elements are patterns such as the following:
>
> CommandExec = %r{^([^|]*\|){3}1\|}
> PlaceOrder = %r{^([^|]*\|){3}2\| 3\|15\|}
> CancelOrder = %r{^([^|]*\|){3}2\| 4\| 1\|}
> OrderStatus = %r{^([^|]*\|){3}3\| 3\| 6\|}
> ErrMessage = %r{^([^|]*\|){3}3\| 4\| 2\|}
> OpenOrders = %r{^([^|]*\|){3}3\| 5\|10\|}
> Portfolio = %r{^([^|]*\|){3}3\| 7\| 7\|}
> ContractSym = %r{^([^|]*\|){3}3\|10\| 6\|}
> Executions = %r{^([^|]*\|){3}3\|11\| 7\|}
> CmdEnqueue = %r{^([^|]*\|){3}4\|11\| 0\|}
> JournalPost = %r{^([^|]*\|){3}4\|12\| 0\|}
>
> Once given the pattern matching, the code is trivial; a script
> follows my sig, and I've also added the file choose.rb to the
> exs directory, so that it will be included in the next release.
>
> Thanks,
>
> Bill
>
> -------- cut here ------------------------------------------------------
> #!/usr/bin/ruby
>
> # author: Bill Pippin, <pippin at trading-shim.com>, msgs may gate to the list
> # copyright (c) 2008 Trading-shim.com, LLC Columbus, OH
> # GPL version 3 or later, see COPYING for details
>
> # choose.rb:
> # Choose a risk-focused subset of events given a shim log stream as input.
> # Usage: e.g., tail -f log/ShimText | exs/choose.rb
>
> # More precisely, match on src-tag-ver triples, split on vertical bars,
> # slice the array to drop the first three fields, reconstitute via join,
> # and slice the resulting string to fit the terminal display.
>
> CommandExec = %r{^([^|]*\|){3}1\|}
> PlaceOrder = %r{^([^|]*\|){3}2\| 3\|15\|}
> CancelOrder = %r{^([^|]*\|){3}2\| 4\| 1\|}
> OrderStatus = %r{^([^|]*\|){3}3\| 3\| 6\|}
> ErrMessage = %r{^([^|]*\|){3}3\| 4\| 2\|}
> OpenOrders = %r{^([^|]*\|){3}3\| 5\|10\|}
> Portfolio = %r{^([^|]*\|){3}3\| 7\| 7\|}
> ContractSym = %r{^([^|]*\|){3}3\|10\| 6\|}
> Executions = %r{^([^|]*\|){3}3\|11\| 7\|}
> CmdEnqueue = %r{^([^|]*\|){3}4\|11\| 0\|}
> JournalPost = %r{^([^|]*\|){3}4\|12\| 0\|}
>
> def print_data line
> fields = line.chop.split('|')
> length = fields.size
> print fields[3,length].join('|')[0..78], "|\n"
> end
>
> STDIN.each do |x|
> case x
> # when CommandExec ; print_data x
> when PlaceOrder ; print_data x
> when CancelOrder ; print_data x
> when OrderStatus ; print_data x
> when ErrMessage ; print_data x
> when OpenOrders ; print_data x
> when Portfolio ; print_data x
> when ContractSym ; print_data x
> when Executions ; print_data x
> when CmdEnqueue ; print_data x
> when JournalPost ; print_data x
> end
> end
>
> _______________________________________________
> ts-general mailing list
> ts-general at trading-shim.org
> http://www.trading-shim.org/mailman/listinfo/ts-general
>
More information about the ts-general
mailing list