有关集合竞价第一个tick的问题
//------------------------------------------------------------------------
// 简称: gp1
// 名称: 
// 类别: 策略应用
// 类型: 用户应用
// 输出: Void
//------------------------------------------------------------------------

Params
    // 参数定义
    Numeric numdate(1);
Vars
    // 变量定义
    Global Numeric i;
    Global Numeric k;
    Global Numeric n;
    Global array<string> mysymbol;
    Global Numeric CurrentBarIndex; 
    Global Array<Numeric> prevClose;  // 昨日收盘价
    Global Array<Numeric> currentfx;


Events
    // 初始化事件函数
    OnInit()
    {
        mysymbol=["399317.SZSE","002129.SZSE", "600732.SSE", "300438.SZSE"]; 

        Numeric date1=PreTradingDay(mysymbol[0], CurrentDate(), numdate);

        for i =0 to GetArraySize(mysymbol)-1
        {
            SubscribeBar(mysymbol[i],"1m",date1);
        }
        for i =0 to GetArraySize(mysymbol)-1
        {
            SubscribeBar(mysymbol[i],"1d",date1);
        }

        n=GetArraySize(mysymbol);
    }

OnBaropen(ArrayRef<Integer> indexs)
{
    CurrentBarIndex = data[0].BarsSinceToday();
}
    
OnBar(ArrayRef<Integer> indexs)
{
    for k = 0 to GetArraysize(indexs) - 1
    {
        i = indexs[k];
             
        if (i<n)
        {
            // 获取昨日收盘价
            prevClose[i] = data[n + i].close[1]; //n 为股票数量
            currentfx[i] = rounddown(data[i].close / prevClose[i] * 100 - data[0].close / prevClose[0] * 100, 0);
            print(DateTimeToString(date+time) +data[i].SymbolName+"正常运行"+text(currentfx[i]));
        }
    }       
}

集合竞价就是每天的第一个tick,我想问一下,如果我在这个onbar中,调用了两个数据源的集合竞价数据,如data[0].close-data[1].close,这样写可以吗?为什么上面我的程序在集合竞价时不输出内容呢?

(1)之前集合竞价只是调用了一个数据源,如print(text(data[i].close)),这样是正常的。

(2)print(text(data[i].close-data[0].close))不正常了,并且onbar中其他的所有部分也都不工作了。

(3)正常开盘,也就是第二个tick所有功能又都正常运行了。

请问这种情况是运行机制的问题吗,还是我哪里出错了没发现?或者说如何避免呢?

tick图怎样不显示集合竞价?
有关交易下单问题
如何获得股票集合竞价开盘价?
tick订阅报错,和tb版本有关联吗
使用tick数据的问题
关于tick推送的问题
如何缓存tick
有关Dic基础数据的教程的需求
请教!!!使用 TICK 数据的问题
如何尽可能早获得股票集合竞价开盘价

1、需要校验数据是否对齐(数据对齐后才能操作多数据源)

2、需要检测是否实盘状态(要么都是休市状态,要么都是集合竞价状态,要么都是连续交易状态)

多谢指点!我明天试试。



OnBar(ArrayRef<Integer> indexs)
{
    if (Date>=CurrentDate)
    {
        for k = 0 to GetArraysize(indexs) - 1
        {
            i = indexs[k];
    
            if (i < n)
            {
                // 获取昨日收盘价
                prevClose[i] = data[n + i].close[1]; //n 为股票数量
                currentfx[i] = rounddown(data[i].close / prevClose[i] * 100 - data[0].close / prevClose[0] * 100, 0);
                print(DateTimeToString(CurrentTime) + data[i].SymbolName + "正常运行" + text(currentfx[i]));
            }
        }
    }    
}
忘记标注了,源代码只在当日执行(Date>=CurrentDate)


你直接print(currenttime) ,如果有集合竞价的时间 说明就是有的

我这个里面只有当i=0时,在9:25正常print了。

也就是i不等于0时,下面只要包含下面这个语句,onbar内所有的print都不正常运行。

“tick到来的时间不一致,导致只要onbar里包含下面这个语句,所有部分都不运行。”

存在引号内部这种机制吗?

currentfx[i] = rounddown(data[i].close / prevClose[i] * 100 - data[0].close / prevClose[0] * 100, 0);