[ts-gen] shim: Decimals for Forex

Bill Pippin pippin at owlriver.net
Wed Aug 5 14:46:27 EDT 2009


Ken,

About dynamically controlling the log format price precision:

> I suspect that IB has some kind of "pricing_num_of_decimals" field for
> each traded instrument.  They must have it, or the compensating code
> would very heavy in TWS.

Perhaps.  The gui display may also be able to draw on AWT/Swing etc.
features.  Dynamically set decimal tabs for display canvases should be
a pretty basic feature for a gui library.

> For the shim, incorporating this field into MySQL and then formatting
> prices, etc... based on this entry may be a good, general solution to
> this formatting problem.

Fortunately there is an even simpler approach for the shim; capture
the floating point precision from the original text input as an
attribute of Decimal terms, when they are constructed; cache the
max precision seem so far for each symbol of interest, and cache
the related format descriptors in a table, in order to avoid
reconstruction.  There would be a symbol format lookup for each
message, using the subscription id, but that's not that much effort.
Session-level floating point data could be formatted according to
default formats, as for now.

Columns would jog over one more if precision increased, but would
remain stable when it decreases, as occurs when the upstream servers
trim trailing zeroes.  So, although columns would not always line up
perfectly from the very first message, for the common case they
would stabilize right away.

As always, downstream code to pick apart messages should match on
field boundaries according to the vertical bar attribute delimiter,
e.g., the line.chop.split('|') statement in sql/bin/ProjectRow.rb,
and never, ever count character columns.

Thanks,

Bill


More information about the ts-general mailing list