欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件高级功能研发区 → [原创]将交易明细输出到数据库

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有5117人关注过本帖平板打印复制链接

主题:[原创]将交易明细输出到数据库

帅哥哟,离线,有人找我吗?
z7c9
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
[原创]将交易明细输出到数据库  发帖心情 Post By: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编辑过]

版主评定:好评,获得1个金币奖励好评,获得1个金币奖励
(理由:好文章)
 回到顶部