[ts-gen] Fair merge

Nils Gebhardt mail at ngebhardt.de
Mon Sep 21 16:48:37 EDT 2009



Bill, 

On Tue, 2009-09-15 at 20:03 -0400, Bill Pippin wrote:

> Nils, 
[...]
> 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 for sending some ruby code example - this is indeed helpful. 

Thanks, 

Nils

> -------- 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