以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  金字塔软件问题提交  (http://weistock.com/bbs/list.asp?boardid=2)
----  为什么这个程序不能显示的当月合约的价格  (http://weistock.com/bbs/dispbbs.asp?boardid=2&id=148700)

--  作者:yin8jun
--  发布时间:2017/3/6 18:15:19
--  为什么这个程序不能显示的当月合约的价格
M1:=if(MONTH()>1,MONTH()-1,1);
HY1:=\'IF\' + If(M1>9,numtostr(M1,0),\'0\'+numtostr(M1,0));  //当前月合约
HY2:=\'IF\' + If(M1+1>9,numtostr(M1+1,0),\'0\'+numtostr(M1+1,0));//下月合约
HY0:=\'IF00\';
VHY0:=CALLSTOCK(HY0,VTVOL,6,0),linethick0;
VHY1:=CALLSTOCK(HY1,VTVOL,6,0),linethick0;
VHY2:=CALLSTOCK(HY2,VTVOL,6,0),linethick0;
if VHY1=VHY0 then CurMonth:=Month();
if VHY2=VHY0 then CurMonth:=Month()+1; 
主力:curmonth,linethick0;
curmonth1:if(CurMonth<12,curmonth+1,1),linethick0;

thisif:=\'if\'+If(curmonth>9,numtostr(curmonth,0),\'0\'+numtostr(curmonth,0)); 
nextif:=\'if\'+If(curmonth1>9,numtostr(curmonth1,0),\'0\'+numtostr(curmonth1,0));

c1:CALLSTOCK(\'if00\',vtclose,1,0);
if00c:CALLSTOCK(thisif,vtclose,1,0);

问题:if00c同c1的输出为什么不一样?

--  作者:wenarm
--  发布时间:2017/3/7 8:56:57
--  

你代码逻辑有问题,你自己输出的处理条件

EXPLAIN(1,thisif);
EXPLAIN(1,nextif);

对应的不是主力合约


--  作者:yin8jun
--  发布时间:2017/3/7 9:39:57
--  
逻辑引用来自如下

 http://www.weistock.com/bbs/dispbbs.asp?boardid=10&Id=9750

--  作者:gxx978
--  发布时间:2017/3/7 10:21:22
--  

1,可以使用msgout输出当前主力具体合约看下,尝试把第一条语句改为M1:=if(MONTH()>1,MONTH(),1);

2,针对12月份的,防止出现下个月合约为IF13,需要单独判定下if m1=12 then HY2:=\'IF01\';


--  作者:wenarm
--  发布时间:2017/3/7 10:37:35
--  

1可以考虑直接使用DYNAINFO(210)

[此贴子已经被作者于2017-3-7 10:37:55编辑过]