期货量化交易客户端开源教学第十节——行情列表

行情列表数据

行情列表数据接收

行情列表接收到的数据根据接收到的数据进行字符处理。为了方便查看行情数据针对每个字段进行显示控制,并可根据显示器自动适配列宽。

发送命令:2

数据接受返回的格式:

2;13;1720682964;000;12021.00;24;12020.00;12020.00;77;0;0;182560;912607;11908.00;12021.00;12059.00;11899.00;0;11911.00;167886;0;11911.00;

数据接受返回的格式:2;商品ID;更新时间;更新毫秒;卖1;卖1量;现价;买1;买1量;涨停板价;跌停板价;成交量;持仓量;今开盘;今收盘;最高价;最低价;当日均价;昨收盘;昨持仓量;成交金额;昨日结算价格;

行情列表数据接收处理代码

Delphi 复制代码
if strList.Strings[0] = '2' then
  begin
    try
      for I := 0 to Length(VGStocks) - 1 do
      begin
        if VGStocks[I].id = strList.Strings[1] then
        begin
          try
            strBodong := FloatToStr(VGStocks[I].smallest_fluctuation);
          except
          end;
          VGStocks[I].curr_unix_datetime := strList.Strings[2];
          VGStocks[I].curr_time := FormatDateTime('YYYY-MM-DD hh:mm:ss ',UnixToDateTime(StrToInt(strList.Strings[2])+28800)) + strList.Strings[3];
          if StrToFloat(strList.Strings[4]) <= 0  then
            VGStocks[I].sell_price := '--'
          else
            VGStocks[I].sell_price := FormatDigital(strBodong,strList.Strings[4]);
          VGStocks[I].sell_num := FormatDigital('0',strList.Strings[5]);
          if StrToFloat(strList.Strings[6]) <= 0  then
            VGStocks[I].curr_price := '--'
          else
            VGStocks[I].curr_price := FormatDigital(strBodong,strList.Strings[6]);
          if StrToFloat(strList.Strings[7]) <= 0  then
            VGStocks[I].buy_price := '--'
          else
            VGStocks[I].buy_price := FormatDigital(strBodong,strList.Strings[7]);
          VGStocks[I].buy_num := FormatDigital('0',strList.Strings[8]);
          if StrToFloat(strList.Strings[9]) <= 0 then
            VGStocks[I].harden_price := '--'
          else
            VGStocks[I].harden_price := FormatDigital(strBodong,strList.Strings[9]);
          if StrToFloat(strList.Strings[10]) <= 0 then
            VGStocks[I].dropstop_price := '--'
          else
            VGStocks[I].dropstop_price := FormatDigital(strBodong,strList.Strings[10]);
          VGStocks[I].deal_num := FormatDigital('0',strList.Strings[11]);
          VGStocks[I].position_num := FormatDigital('0',strList.Strings[12]);
          if StrToFloat(strList.Strings[13]) <= 0 then
            VGStocks[I].open_price := '--'
          else
            VGStocks[I].open_price := FormatDigital(strBodong,strList.Strings[13]);
          if StrToFloat(strList.Strings[14]) <= 0 then
            VGStocks[I].close_price := '--'
          else
            VGStocks[I].close_price := FormatDigital(strBodong,strList.Strings[14]);
          if StrToFloat(strList.Strings[15]) <= 0 then
            VGStocks[I].highest_price := '--'
          else
            VGStocks[I].highest_price := FormatDigital(strBodong,strList.Strings[15]);
          if StrToFloat(strList.Strings[16]) <= 0 then
            VGStocks[I].lowest_price := '--'
          else
            VGStocks[I].lowest_price := FormatDigital(strBodong,strList.Strings[16]);
          if StrToFloat(strList.Strings[17]) <= 0 then
            VGStocks[I].average_price := '--'
          else
            VGStocks[I].average_price := FormatDigital(strBodong,strList.Strings[17]);
          if StrToFloat(strList.Strings[18]) <= 0 then
            VGStocks[I].yesterday_close_price := '--'
          else
            VGStocks[I].yesterday_close_price := FormatDigital(strBodong,strList.Strings[18]);
          if FormatDigital('0',strList.Strings[19]) = '0' then
            VGStocks[I].yesterday_position_num := '--'
          else
            VGStocks[I].yesterday_position_num := FormatDigital('0',strList.Strings[19]);
          if StrToFloat(strList.Strings[20]) <= 0 then
            VGStocks[I].deal_jine := '--'
          else
            VGStocks[I].deal_jine := FormatDigital(strBodong,strList.Strings[20]);
          if StrToFloat(strList.Strings[21]) <= 0 then
            VGStocks[I].yesterday_jiesuan := '--'
          else
            VGStocks[I].yesterday_jiesuan := FormatDigital(strBodong,strList.Strings[21]);
          VGStocks[I].ups_downs := FloatToStr( StrToFloat(VGStocks[I].curr_price) - StrToFloat(VGStocks[I].yesterday_jiesuan));   {涨跌=现价-昨结算价}
          VGStocks[I].ups_downs_perc := Format('%0.2f',[StrToFloat(VGStocks[I].ups_downs) / StrToFloat(VGStocks[I].yesterday_jiesuan) * 100]) + '%';
          for J := 0 to Length(ArrMarketFuture) - 1 do
          begin
            if Assigned(ArrMarketFuture[J]) then
              ArrMarketFuture[J].refreshFutureData(I);
          end;
相关推荐
AI服务老曹1 天前
预警提醒并生成日志,便于后期追溯的智慧地产开源了
大数据·人工智能·安全·开源·智慧城市
布瑞泽的童话1 天前
Vue 也能这样玩?Vuetify 打造超强大的UI体验
前端·vue.js·ui·开源
DogDaoDao1 天前
音视频开发常见的开源项目汇总
ffmpeg·开源·音视频·webrtc·x264·live555·obs
绘绘~2 天前
PDF扫描版文字识别OCR
pdf·开源·github·ocr
数云界2 天前
使用 Elementary 实现开源数据可观测性 — 从零到精通(第一部分)
数据库·开源
专家大圣2 天前
Linux:开源世界的璀璨明珠
linux·运维·开源
像风一样自由20202 天前
深入了解Linux操作系统:开源世界的基石
linux·运维·开源
OpenAnolis小助手2 天前
专访AMD:AMD 正式加入龙蜥社区首秀:开源协作与 AI 创新的交汇点
ai·开源·操作系统·龙蜥社区·龙蜥操作系统大会
AI服务老曹3 天前
可对画面进行平台传输,实时查看监控的智慧交通开源了
大数据·人工智能·物联网·开源
奥利给少年3 天前
Machine Learning: A Probabilistic Perspective 机器学习:概率视角 PDF免费分享
人工智能·机器学习·开源