多品种订阅,“策略交易”板块显示多个品种订阅成功,但log只显示收到首个品种的行情推送

------------------修改Onbar()后,已解决-----------------------

 //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组
    OnBar(ArrayRef<Integer> indexs)
    {
        Integer i;
        For i = 0 To GetArraySize(indexs) - 1
        {
            msgbox("Symbol="+Data[indexs[i]].Symbol);
            
        }
    }

-------------------------------------------------------------

 

OnInit(){
        // 订阅buylist,退订selllist
            //SubscribeBar("688185.SSE", "1m");
            SubscribeBar("300750.SZSE", "1m", s_time);
            SubscribeBar("002594.SZSE", "1m", s_time);
            SubscribeBar("000300.SSE","1d",s_time);//订阅沪深300指数日K线行情
            SubscribeBar("000300.SSE","1m",s_time);//订阅沪深300指数1分钟K线行情
            SubscribeBar("IF888.CFFEX","1m",s_time);//订阅沪深300期货1分钟K线行情
            //CreateTimer(1000);    
    }

 

图1显示代码订阅的几个品种都加入了策略订阅

但 图2 的日志显示只有首个品种收到了推送行情

 

 

help,订阅多个品种时怎么正确取到正确的属性值?
订阅行情显示问题
么让订阅的商品品种直接应用当前单元的商品品种,有函数直接输出吗?
订阅所有行情
如何用tbpy做多品种交易?
关于订阅行情
订阅显示
根据品种获取所属的板块
多品种开仓问题
多品种回测

补充日志函数:

Defs

//写日志,方便代码调试
    Integer msgbox(StringRef msg)
    {
        FileAppend(output_path+FormulaName, "[" + DateTimeToString(SystemDateTime) + "] " + msg);
        Return 0;
    }

这是函数的定义,函数的调用呢?

工具可能没什么问题,用的方法对吗?

日志打印只是在OnBar()中简单的调用

Vars
    Numeric Lots;// 交易手数
    Series<Numeric> Ma;// 均线
    String output_path("D:\\TBQ\\log\\");
    Array<String> baught_arr;
    Global Integer count(0);
    Global Bool flag(False);
    Global Bool resetGlobal(False);
    Integer s_time(20220911);
Defs
    //写日志,方便代码调试
    Integer msgbox(StringRef msg)
    {
        FileAppend(output_path+FormulaName, "[" + DateTimeToString(SystemDateTime) + "] " + msg);
        Return 0;
    }
        
Events
    OnInit(){
        // 订阅buylist,退订selllist
        If(!flag){
            //SubscribeBar("688185.SSE", "1m");
            SubscribeBar("300750.SZSE", "1m", s_time);
            SubscribeBar("002594.SZSE", "1m", s_time);
            SubscribeBar("000300.SSE","1d",s_time);//订阅沪深300指数日K线行情
            SubscribeBar("000300.SSE","1m",s_time);//订阅沪深300指数1分钟K线行情
            SubscribeBar("IF888.CFFEX","1m",s_time);//订阅沪深300期货1分钟K线行情
            //CreateTimer(1000);    
        }Else{
            SubscribeBar("002594.SZSE", "1m");
            //Bool ret = UnsubscribeBar(subsbId3);
            //msgbox("UnsubscribeBar:" + IIFString(ret,"True","False"));
        }
    }
    OnReady()
    {   
        //msgbox("onready");
        Integer i;
        For i = 0 To A_AccountCount - 1
        {
            msgbox("AccountId:" + A_AccountID(i));
            Array<String> symbols;
            //获取账户持仓的合约代码 
            Bool ret = A_GetPositionSymbols(symbols, i);
            msgbox("A_GetPositionSymbols:" + IIFString(ret, "True", "False") + "," + TextArray(symbols));
            Bool isContain = ArrayFind(symbols, "002709.SZSE");
            //数组中包含查找元素
            msgbox(IIFString(isContain,"002709.SZSE"+"数组中包含查找元素","002709.SZSE"+"数组中不包含查找元素"));
            
            Integer j;
            For j = 0 To GetArraySize(symbols) - 1
            {
                Position pos;
                //获取指定合约/股票当前仓位
                Bool ret = A_GetPosition(symbols[j], pos, "", i);
                msgbox("A_GetPosition: " + symbols[j] + IIFString(ret, "True", "False") + "," + Text(pos.longCanSellVolume));
            }
            
            String id = A_AccountID(i);
            Account acc;
            Bool ret2 = A_GetAccount(acc, i);
            msgbox("accountId:" + id + ",A_GetAccount:" + IIFString(ret2,"True","False") + ",value:" + Text(acc.available)); // 待交易时间重开再测
        }      
    }
    
    //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组
    OnBar(ArrayRef<Integer> indexs)
    {
        msgbox("Symbol="+Symbol);
    }
    
    OnTimer(Integer id,Integer millsecs)
    {
        count = count+1;
        msgbox("OnTimer count:" + Text(count));
        if(count == 10) 
        { 
            flag = True;
            StopTimer(id);
            ReStart(resetGlobal);
        }
    }
 

补充:上周也出现过类似情况,重建策略单元或者重启tbq解决了。但这次不行。运行环境:windows11