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

行情列表数据

行情列表数据接收

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

发送命令: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;
相关推荐
心随_风动3 小时前
SUSE Linux 发行版全面解析:从开源先驱到企业级支柱
linux·运维·开源
PythonFun4 小时前
DeepSeek-R1-0528:开源推理模型的革新与突破
语言模型·开源
CoderJia程序员甲6 小时前
MCP 技术完全指南:微软开源项目助力 AI 开发标准化学习
microsoft·ai·开源·ai教程·mcp
星哥说事6 小时前
使用VuePress2.X构建个人知识博客,并且用个人域名部署到GitHub Pages中
开源·github
想用offer打牌9 小时前
想为Seata社区进行贡献?这几点你需要了解😯
后端·开源
何双新14 小时前
第21讲、Odoo 18 配置机制详解
linux·python·开源
说私域21 小时前
定制开发开源AI智能名片驱动下的海报工厂S2B2C商城小程序运营策略——基于社群口碑传播与子市场细分的实证研究
人工智能·小程序·开源·零售
Python私教1 天前
字节跳动开源图标库:2000+图标一键换肤的魔法
python·开源
何双新1 天前
第2讲、Odoo深度介绍:开源ERP的领先者
python·开源
OpenTiny社区1 天前
开源之夏·西安电子科技大学站精彩回顾:OpenTiny开源技术下沉校园,点燃高校开发者技术热情
前端·开源