Rss & SiteMap

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

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

标题:请老师帮我编写一个程序

1楼
离殇 发表于:2014/1/25 11:35:10

我想编写一个股票交易模型


N:=INTPART((7-C)/0.05);

T=((7-C)/0.05;

买入条件:T=N,并且现在的价格低于上次买入的价格,买入量为10*N;

 

卖出条件:价格等于1.

大概是这么个意思,请老师给我帮帮忙

2楼
jinzhe 发表于:2014/1/26 9:55:15

INTPART

这个函数什么意思?

 

3楼
离殇 发表于:2014/1/27 9:58:52
老师,这个是取整函数啊
4楼
离殇 发表于:2014/1/27 9:59:38
因为我对金字塔的编写结构不是很熟悉,所以还多多麻烦老师了
5楼
jinzhe 发表于:2014/1/27 10:04:21


n:=round((7-c)/0.05);
T:=(7-C)/0.05;

variable:m=0;
if holding=0 and t=n and m=0 then begin
 buy(1,10*n,market);
 m:=1;
end

if holding=0 and m=1 and t=0 and c<enterprice then buy(1,10*n,market);

if h>=1 and l<=1 then  sell(1,0,market);

6楼
离殇 发表于:2014/1/27 11:05:38

老师,这里不需要四舍五入,只需要取整就可以了。

n:=INTPART((7-c)/0.05);
T:=(7-C)/0.05;
if date=1120502 and time=093100 then begin
 buy(1,1,THISCLOSE);
 
end

if  t=n and c<enterprice then buy(1,10*n,THISCLOSE);

if h>=1 and c<=1 then  sell(1,1,THISCLOSE);

修改之后的程序差不多是这个样子。

但是在计算的时候,出了问题。应该是每0.05就买入一次的,但是实际上每隔0.25才买入一次。还请老师帮我看看问题出在哪里

7楼
jinzhe 发表于:2014/1/27 11:15:35
0.05和0.25是怎么看出来的?
8楼
jinzhe 发表于:2014/1/27 11:16:17

取整,有向上取整,向下取整,四舍五入取整,这个不是随便的问题,要定义好

9楼
离殇 发表于:2014/1/27 11:28:57
我的模型的判断依据就是(7-c)/0.05在取整的时候买入。所以就应该是每0.05买入。而且我不需要四舍五入。我从计算的结果看到的,但是也有点问题,因为结果显示有四十多次交易,但是明细上只有几次,不知道哪个是对的
10楼
jinzhe 发表于:2014/1/27 13:41:14

推理 (7-c)/0.05=  (7-c)*20/(0.05*20)=(7-c)*20/1

 

就是推断(7-c)*20是不是整数

 

而根据上面的推断,

求某个数是不是整数的办法是

mod((7-c)*20*10,10)=0

 

所以你的下单条件要修改成

 

T:=(7-C)/0.05;

variable:m=0;

cond:=mod(t*20*10,10)=0;
if holding=0 and cond and m=0 then begin
 buy(1,10*n,market);
 m:=1;
end

if holding=0 and m=1 and cond and l<enterprice then buy(1,10*n,market);

if h>=1 and l<=1 then  sell(1,0,market);

共42 条记录, 每页显示 10 条, 页签: [1] [2][3][4][5]


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