<table cellspacing='0' cellpadding='0' border='0' ><tr><td valign='top' style='font: inherit;'>Thanks for your answer Bill, I'll check these points.<br><br>Sam.<br><br>--- En date de : <b>Mar 17.6.08, Bill Pippin <i><pippin@owlriver.net></i></b> a écrit :<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">De: Bill Pippin <pippin@owlriver.net><br>Objet: Avoiding the enumeration of product/route pairs<br>À: sam_backtester@yahoo.fr, "trading-shim general mailing list" <ts-general@trading-shim.org><br>Date: Mardi 17 Juin 2008, 19h53<br><br><pre>Sam,<br><br>You ask about the history detail records written to the table<br>HistoryBar:<br><br>> If I'm correct, the historical bars are printed in the ShimText file,<br>> with some extra information, and filled into the table HistoryBar.<br><br>> But in this table, the field sym doesn't match the cid, right ?<br>> Is there a way to
match these two ? I'm sorry, I'm lost with<br>these<br>> cid, ibid, etc, etc. ...<br><br>In order to understand the database structure, it helps to focus<br>on the foreign key references, such as one of the attributes you<br>mentioned, cid, named for the contract id.<br><br>To see how they tie tables together, you may like to begin with<br>the files syms.ps and xact.ps, which give the foreign key<br>dependency graphs for the symbology and order records.<br><br>They are produced by the script bin/fkey.rb, which requires that<br>you have the graphviz package installed. In the recent releases,<br>although the script is included, the outputs were not; I'll add<br>syms.ps and xact.ps to future releases, for those lacking graphviz,<br>and have included them as attachments in this post as well.<br><br>Returning to your question, and the foreign key attributes that<br>are the essence of the answer, note that they are always declared<br>as foreign key
attributes in the create table statement; the<br>create table statements are found in various instances of files<br>matching sql/????.sql and source'd by create.sql. So, first,<br>starting with the create table statement for Contract:<br><br>create table Contract<br>(<br> uid int unsigned not null auto_increment primary key,<br> tag int unsigned not null references Product(uid),<br> route int unsigned not null references Exchange(uid),<br> unique key(tag, route),<br><br> foreign key (tag) references Product(uid),<br> foreign key (route) references Exchange(uid)<br><br>) engine = InnoDb;<br><br>Looking at the foreign key declarations, we see that a Contract,<br>then, is a Product/Exchange pair. Going on to look at HistoryBar,<br>we see that the Product/Exchange keys are spelled out in place of a<br>Contract key:<br><br>create table HistoryBar<br>(<br> uid
int unsigned not null auto_increment primary key,<br> sym int unsigned not null references Product(uid),<br> ecn int unsigned not null references Exchange(uid),<br> bid int unsigned not null references HistoryTag(uid),<br> time datetime not null, unique key(sym, ecn, bid, time),<br> open decimal(10,4) not null,<br> high decimal(10,4) not null,<br> low decimal(10,4) not null,<br> close decimal(10,4) not null,<br> vol int not null, -- -1 for NA<br> wap decimal(10,4) not null, -- -1.0 " "<br> has_gaps bool not null,<br><br> foreign key (sym) references Product(uid),<br> foreign key (ecn) references Exchange(uid),<br> foreign key (bid) references HistoryTag(uid)<br><br>) engine = InnoDB;<br><br>The use of Product/Exchange pairs reflects the fact that
the<br>Contract table is being de-emphasized, and may be deprecated and<br>eventually eliminated. There are just too many possible contracts,<br>most of which would be routed to obscure exchanges, and so it's<br>better to work with the Product/Exchange pairs rather than storing<br>all the possible contracts in the database. This is particularly<br>significant for options, of which there are far too many specific<br>products to start with, before considering all the possible routes.<br> <br>Thanks,<br><br>Bill</pre></blockquote></td></tr></table><br>
<hr size="1">
Envoyé avec <a href="http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html">Yahoo! Mail</a>.<br>Une boite mail plus intelligente. </a>