以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://www.weistock.com/bbs/index.asp) -- 高级功能研发区 (http://www.weistock.com/bbs/list.asp?boardid=5) ---- [原创]将交易明细输出到数据库 (http://www.weistock.com/bbs/dispbbs.asp?boardid=5&id=4801) |
-- 作者:z7c9 -- 发布时间:2011/1/12 21:36:40 -- [原创]将交易明细输出到数据库
阅读版:
以下内容为程序代码:
1 runmode:0; 2 3 debug:=1; 4 5 database(\'provider=microsoft.jet.oledb.4.0;data source=test.mdb\'); 6 7 if debug=1 then begin 8 database(\'provider=microsoft.jet.oledb.4.0;data source=test.mdb\'); 9 if barpos=1 then begin 10 sql1:=\'create table tradedetail(opendate datetime,\'+ 11 \'contractname varchar,\'+ 12 \'opentime datetime,\'+ 13 \'openprice real,\'+ 14 \'tradetype varchar,\'+ 15 \'closetime datetime,\'+ 16 \'closeprice real,\'+ 17 \'winlosspoint int,\'+ 18 \'lots int,\'+ 19 \'commissions real,\'+ 20 \'closewinloss real,\'+ 21 \'asset real)\'; 22 dbexecute(sql1); 23 end 24 end 25 26 enterhour:=ref(hour,enterbars); 27 enterminute:=ref(minute,enterbars); 28 29 if holding=0 then begin 30 buy(1,1,limitr,low); 31 end 32 33 if holding>0 then begin 34 sell(1,holding,limitr,high); 35 lots:=1; 36 commission:=6; 37 38 if debug=1 then begin 39 sql2:=\'insert into tradedetail(opendate,contractname,opentime,openprice,tradetype,closetime,closeprice,winlosspoint,lots,commissions,closewinloss,asset) values("\'+ 40 numtostr(year,0)+\'-\'+numtostr(month,0)+\'-\'+numtostr(day,0)+\'","\'+stklabel+\'","\'+ 41 numtostr(enterhour,0)+\':\'+numtostr(enterminute,0)+\'",\'+numtostr(enterprice,0)+\',"Buy","\'+ 42 numtostr(hour,0)+\':\'+numtostr(minute,0)+\'",\'+numtostr(exitprice,0)+\',\'+ 43 numtostr(enterprice-exitprice,0)+\',\'+numtostr(lots,0)+\',\'+numtostr(2*commission*lots,0)+\',\'+ 44 numtostr((enterprice-exitprice)*multiplier*lots-2*commission*lots,0)+\',\'+numtostr(asset,2)+\')\'; 45 dbexecute(sql2); 46 end 47 end
拷贝版:
runmode:0;
debug:=1; database(\'provider=microsoft.jet.oledb.4.0;data source=test.mdb\'); if debug=1 then begin database(\'provider=microsoft.jet.oledb.4.0;data source=test.mdb\'); if barpos=1 then begin sql1:=\'create table tradedetail(opendate datetime,\'+ \'contractname varchar,\'+ \'opentime datetime,\'+ \'openprice real,\'+ \'tradetype varchar,\'+ \'closetime datetime,\'+ \'closeprice real,\'+ \'winlosspoint int,\'+ \'lots int,\'+ \'commissions real,\'+ \'closewinloss real,\'+ \'asset real)\'; dbexecute(sql1); end end enterhour:=ref(hour,enterbars); enterminute:=ref(minute,enterbars); if holding=0 then begin buy(1,1,limitr,low); end if holding>0 then begin sell(1,holding,limitr,high); lots:=1; commission:=6; if debug=1 then begin sql2:=\'insert into tradedetail(opendate,contractname,opentime,openprice,tradetype,closetime,closeprice,winlosspoint,lots,commissions,closewinloss,asset) values("\'+ numtostr(year,0)+\'-\'+numtostr(month,0)+\'-\'+numtostr(day,0)+\'","\'+stklabel+\'","\'+ numtostr(enterhour,0)+\':\'+numtostr(enterminute,0)+\'",\'+numtostr(enterprice,0)+\',"Buy","\'+ numtostr(hour,0)+\':\'+numtostr(minute,0)+\'",\'+numtostr(exitprice,0)+\',\'+ numtostr(enterprice-exitprice,0)+\',\'+numtostr(lots,0)+\',\'+numtostr(2*commission*lots,0)+\',\'+ numtostr((enterprice-exitprice)*multiplier*lots-2*commission*lots,0)+\',\'+numtostr(asset,2)+\')\'; dbexecute(sql2); end end
[此贴子已经被作者于2011-1-12 21:38:51编辑过]
|
-- 作者:董小球 -- 发布时间:2011/1/13 10:13:10 -- 很好的范例 |