Database setup trading-shim Frequently Asked Questions
  Current time: 04:32   
trading-shim Frequently Asked Questions
Certain recurring questions tend to come up in mailing list and support contexts; the links below address or point to further resources about the most common areas of inquiry.
 Show Categories 

Walkthrough of basic 'shim' database setup

Let's set up a mysql database to test in. We need a mysql userid, which should be other than the mysql 'root' account, with basic 'USAGE' rights in the day to day operation of the shim. Here, we also grant 'SUPER' privleges to the end user account here, as we are in a testing mode, and need to force in this global right, to turn on options for ACID transaction processing to be strictly observed. The 'SUPER' rights may be removed from the account once the database is set up, but it is convenient yo leave in place on a testing developmental box. Note also, that for simplicity on a testing box, we do not key a password on the mysql 'USAGE' rights account.
Note: this is a set of instructions for shim versions issued prior to March 2007; After February, 2007, the second set of instructions, wheich are more granular as to security matters, would apply:
  1. Pre March 2007
    [herrold@couch ~]$ sudo yum -y install mysql-server php-mysql
    [herrold@couch ~]$ sudo /sbin/service mysqld start
    Starting MySQL:                                            [  OK  ]
    [herrold@couch ~]$ mysql -u root -p mysql
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    mysql> create database testing_shim ;
    Query OK, 1 row affected (0.01 sec)
    mysql> GRANT USAGE ON testing_shim.* TO 'shim'@'localhost' ;
    mysql> GRANT USAGE ON testing_shim.* TO 'shim'@'%' ;
    mysql> GRANT SUPER ON *.* TO 'shim'@'%' WITH GRANT OPTION ;
    mysql> GRANT SUPER ON *.* TO 'shim'@'localhost' WITH GRANT OPTION ;
    mysql> select * from user where User = 'shim' ;
     ...  much stuff ...
    mysql> select Host, User, Password, Super_priv  from user where User =
    'shim' ;
    | Host      | User | Password | Super_priv |
    | %         | shim |          | Y          |
    | localhost | shim |          | Y          |
    2 rows in set (0.00 sec)
  2. For post-February, 2007 versions:
    use mysql ;
    delete from user where User = 'shim' ;
    GRANT SUPER ON *.* TO 'shim'@'%'         WITH GRANT OPTION ;
    GRANT SUPER ON *.* TO 'shim'@'localhost' WITH GRANT OPTION ;
    GRANT CREATE TEMPORARY TABLES ON *.* TO 'shim'@'localhost';
            TO 'shim'@'localhost' ;
    	TO 'shim'@'%' ;
Then we edit /src/once.c , and src/data.c ; and bin/includes for your site specific values.

The file: once.c has entries for the host IP (no hostname to network IP lookup is presently performed -- use numeric IP's for now), and port (the default is: 7496) to connect to a running TWS instance at.

The file: data.c has similar entries for the database server, dataset, userid, and optional password keying, and more.

When the edits are done, they might look like this:
[herrold@couch src]$ pwd
[herrold@couch src]$ grep -A2 '7496' once.c
    : tws_port(7496),
      channels(c.mode.streams(p, c, f, self)),
[herrold@couch src]$ grep -A3 'localhost' data.c
  HostName("localhost"),    /* patch */ /* server host   (default:localhost ) */
  UserName("shim"),         /* patch */ /* username      (default:login name) */
  DbmsName("testing"),      /* patch */ /* database name         (no default) */
  PassWord(""),             /* patch */ /* password              (no default) */
[herrold@couch src]$             
... and a quick 'make' up a directory (we had built this before, so we 'touch' the two files, so that they are preceived as stale by 'make' as it processes the supplied Makefile).
[herrold@couch src]$ cd ..
[herrold@couch shim-070202]$ touch src/data.c src/once.c
[herrold@couch shim-070202]$ make
make -j8  shim
make[1]: Entering directory /home/herrold/shim/shim-070202'
distcc g++ -Wall -g -I/usr/include/mysql  -c -o once.o src/once.c
distcc g++ -Wall -g -I/usr/include/mysql  -c -o data.o src/data.c
date;   distcc g++ -g -o shim once.o make.o init.o mode.o data.o type.o
rule.o kind.o help.o else.o boot.o atom.o load.o shim.o time.o read.o flow.o
next.o send.o post.o wire.o echo.o term.o leaf.o call.o hash.o pool.o unit.o
-L/usr/lib/mysql -lmysqlclient -lm
Sun Feb  4 19:42:22 EST 2007
make[1]: Leaving directory /home/herrold/shim/shim-070202'
[herrold@couch shim-070202]$ 
And let's test it, first without populating the database, AND without starting a TWS enabled to listen on its ''
[herrold@couch shim-070202]$ ./shim --data

Usage: shim  [optional feature list]
terminate called after throwing an instance of
[herrold@couch shim-070202]$
which is of course expected, and documented elsewhere (toward the bottom).

So now we start the TWS, enable socket connections [Configure|API], and set the permitted (wrapper enabled Host IP list) to include the 'locahost' value of '', and the other IP's of the units permitted to conenct to that TWS instance [Configure|APITrusted IP addresses], [Create], (values), [Apply]

AND we can populate the database:
[herrold@couch shim-070202]$ cd sql
[herrold@couch sql]$ mysql -u shim -h localhost testing_shim < create.sql
[herrold@couch sql]$ cd ..
And, and then test again
[herrold@couch shim-070202]$ ./shim --data

The trading shim has finished program initialization, including the
construction of successful connections to the database and IB tws.

[herrold@couch shim-070202]$     
Success -- setting up logging, as into a pipe, so that we can watch the shim's interaction with the TWS comes next.
Last modified: Tue, 27 Mar 2007 18:23:53 -0400

HomeSearchInterior documentationProgram documentationFAQDownloadPDFsScreen shots ]  [ Contact UsSite MapBugzillaMailman |  Mailing List Archives: (MainLicenseAboutPressCopyright ]

Copyright (c) 2006 ... 2009, LLC, Columbus, OH