Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[讨论]同样的策略在后台多账号交易时要根据账号个数写多个公式?

1楼
z7c9 发表于:2010/12/28 11:48:18

账号666666的策略:

以下内容为程序代码:

1 begintime:=currenttime>=091500 and currenttime<=145500;
2 endtime:=currenttime>=145930;
3
4 buycond:=begintime;
5 sellcond:=begintime;
6
7 if tbuyholdingex('666666',0,0)=0 then begin
8     if buycond then begin
9         buyprice:=close;
10         mycash:=taccount2(19,'666666');
11         lots:=intpart(mycash/(buyprice*multiplier*taccount(41)));
12         tbuy(1,lots,lmt,close,0,'666666',0);
13     end
14 end
15
16 if tsellholdingex('666666',0,0)=0 then begin
17     if sellcond then begin
18         sellprice:=close;
19         mycash:=taccount2(19,'666666');
20         lots:=intpart(mycash/(sellprice*multiplier*taccount(42)));
21         tbuyshort(1,lots,lmt,close,0,'666666',0);
22     end
23 end
24
25 if tbuyholdingex('666666',0,0)>0 then begin
26     if endtime then
27         tsell(1,tbuyholdingex('666666',0,0),lmt,close,'666666',0);
28 end
29
30 if tsellholdingex('666666',0,0)<0 then begin
31     if endtime then
32         tsellshort(1,tsellholdingex('666666',0,0),lmt,close,'666666',0);
33 end

 

账号888888的策略:

以下内容为程序代码:

1 begintime:=currenttime>=091500 and currenttime<=145500;
2 endtime:=currenttime>=145930;
3
4 buycond:=begintime;
5 sellcond:=begintime;
6
7 if tbuyholdingex('888888',0,0)=0 then begin
8     if buycond then begin
9         buyprice:=close;
10         mycash:=taccount2(19,'888888');
11         lots:=intpart(mycash/(buyprice*multiplier*taccount(41)));
12         tbuy(1,lots,lmt,close,0,'888888',0);
13     end
14 end
15
16 if tsellholdingex('888888',0,0)=0 then begin
17     if sellcond then begin
18         sellprice:=close;
19         mycash:=taccount2(19,'888888');
20         lots:=intpart(mycash/(sellprice*multiplier*taccount(42)));
21         tbuyshort(1,lots,lmt,close,0,'888888',0);
22     end
23 end
24
25 if tbuyholdingex('888888',0,0)>0 then begin
26     if endtime then
27         tsell(1,tbuyholdingex('888888',0,0),lmt,close,'888888',0);
28 end
29
30 if tsellholdingex('888888',0,0)<0 then begin
31     if endtime then
32         tsellshort(1,tsellholdingex('888888',0,0),lmt,close,'888888',0);
33 end

 

 

仅仅因为账号不同就需要写多个公式?这个不太合理吧。

[此贴子已经被作者于2010-12-28 12:09:48编辑过]
2楼
董小球 发表于:2010/12/28 14:06:14

也可以用 条件2 or 条件2 then的形式嘛

你认为怎样最好?

3楼
z7c9 发表于:2010/12/28 17:30:18
以下是引用董小球在2010-12-28 14:06:14的发言:

也可以用 条件2 or 条件2 then的形式嘛

你认为怎样最好?

那还是1个策略不是2个策略吧,总不能把所有的策略写在一个公式中吧。

 

总不能有多少个账号,就copy多少份代码吧?

 

就像一个策略可以应用在多个品种上,一个策略应该也可以应用在多个账号上才对。

[此贴子已经被作者于2010-12-28 17:32:22编辑过]
共3 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.01563 s, 3 queries.