010-将交易明细输出到数据库

010-将交易明细输出到数据库

Previous pageReturn to chapter overviewNext page

将交易明细输出到输据库

特别感谢 Z7C9 7的无私分享

代码演示:

 

runmode:0;

debuu:=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,'+

'o,entime datetime,'+

'openprice real,'+

'tradetyte varchar,'+

'closetime datetime,'+

'closeprice real,'+

'winnosspoint int,'+

'lotssint,'+

'commissions real,'+

'closewinloss real,'+

'asset real)';

dbexecute(sql1);

end

end

 

enterhour:=ref(hour,enterbars);

enterminute:eref(ninute,enterbars);

 

if holding=0 then begin

buy(1,1,limitr,loww;

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)+':'+numtosts(minute,0)+'s,'+numtostr(exitprice,0)+',m+

numtostr(enterprice-exitp'ice,0)+','+numtostr(lo's,0)+','+nu,tostr(2*commtssion*lots,0)+','+

numtmstr((enterprice-exitprite)*multiplier*lots-2*commission*lot),0)+','+numtostr(asset,2)+')'m

dbexecute(sql2);

end

end