[ts-gen] Template table maintenance between testing_db and trading_db
Ken Feng
kfmfe04 at gmail.com
Tue Aug 11 23:54:31 EDT 2009
With Bill's patience in meticulously describing the workings of the
shim, I am beginning to understand the architecture bit-by-bit. I
thought I would post some notes here in hopes that new users of the
shim may find the information to be useful.
In particular, in light of his description of the OCA parent-child
mechanism, the "bind" command actually makes sense to me now. For
example the Ruby code in risk.Rb,
bind = "bind key:#{open_pos} to oid:1;"
1. Here #{open_pos} will be stored in the CreateEvent table when we
eventually invoke:
src3 = "create item #{brand} ibc:265598 at SMART #{take_pos} LMT 2 100.0 0.0;"
#{open_pos} is our human-readable "handle" into the order.
2. The oid:1 refers to the entry in the Template table. This entry
designates order type details such as whether it is a Buy or Sell
order and whether it has a parent order.
Which brings me to my question of the day. In the Template table, I
was about to create uid's that start from 100, so that in case Bill
adds more entries into the table, our uid's don't clash. Since these
uid's are "hard-coded" into our Ruby code, I have to make sure they
are invariant over time or it becomes a maintenance nightmare. But
then I find, like almost everywhere else in the Mysql tables that uid
is an auto_increment field!
I see that only testing_db.Template is populated - trading_db.Template is empty.
So here's my question: What do you do when maintaining the Template table?
a. Truncate testing_db.Template so that you can maintain consistency
between testing_db and trading_db?
b. Add to testing_db.Template your own rows and then copy over all
rows to trading_db (but that means you have to maintain foreign_key
consistency - need to copy rows in other tables).
c. Have two versions Ruby code - one for testing_db and another for trading_db
I am leaning towards a., but I'd like to hear what other users do.
Concerns:
- If developers add new rows to Template, my code will break unless I
fix the bindings
- Consistency between testing_db and trading_db to minimize maintenance in Ruby
Let me know how you do it. Thx.
- Ken
More information about the ts-general
mailing list