FAQ > 金融建模 > 应用案例 > 指标或功能实现

Q:获取指定日分钟线市场A股的涨跌停数    

  • A:获取指定日全市场A股的分钟线的涨停数与跌停数的实现如下:
    Function FAQ_getMinZDTCount();
    Begin
      endt:=20260706T;//指定日
      stocks:=getAbkbydate("A股",endt);
      //取指定日涨跌停价
      ret:=select thisrow as "StockID",
         spec(StockZtClose(endt),thisrow) as "涨停价",
         spec(StockDtClose(endt),thisrow) as "跌停价"
         from stocks where spec(istradeday(endt),thisrow) end;
      //return getzdCount(ret,20260806.10T); //指定某个时间点的
      //每个分钟线的
      setsysparam(pn_cycle(),cy_1m());
      Tarr:=MarketTradeDayQk(endt,endt+15/24);
      return select datetimetostr(thisrow) as "date",
         [zts,dts]:=getzdCount(ret,thisrow) as nil,
         zts as "涨停数",dts as "跌停数"
         from Tarr end;
    End;
    Function getzdCount(ret,endtime); //某时刻的
    begin
      with *,array(Pn_cycle():cy_1m(),pn_date():endtime) do //设置分钟级别
      begin
        ret:=select *,spec(close(),["StockID"]) as "价格" from ret end;
        ztT:=select * from ret where ["涨停价"]>0 and ["价格"]>=["涨停价"] end;
        dtT:=select * from ret where ["跌停价"]>0 and ["价格"]<=["跌停价"] end;
      end;
      return array(length(ztT),length(dtT));
    end

    执行结果如下: