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

行情列表数据

行情列表数据接收

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

发送命令: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;
相关推荐
自由鬼1 小时前
开源AI开发工具:OpenAI Codex CLI
人工智能·ai·开源·软件构建·开源软件·个人开发
韩仔搭建3 小时前
美乐迪电玩大厅加载机制与 RoomList 配置结构分析
游戏·小程序·开源·lua
灏瀚星空5 小时前
用Obsidian四个插件打造小说故事关联管理系统:从模板到图谱的全流程实践
经验分享·笔记·开源
爱的叹息6 小时前
开源作业调度框架Quartz框架详细使用说明
开源
自由鬼7 小时前
开源漏洞扫描器:OpenVAS
运维·服务器·安全·网络安全·开源·漏洞管理
ModelWhale7 小时前
四川气象数据智能体示范应用入围中国信通院“开源大模型+”案例
开源
FIT2CLOUD飞致云19 小时前
问答页面支持拖拽和复制粘贴文件,MaxKB企业级AI助手v1.10.6 LTS版本发布
人工智能·开源
爱喝奶茶的企鹅19 小时前
Ethan独立开发产品日报 | 2025-04-24
人工智能·程序员·开源
少年、潜行20 小时前
【开源】STM32HAL库移植Arduino OneWire库驱动DS18B20和MAX31850
stm32·嵌入式硬件·开源·ds18b20·max31850
努力犯错1 天前
昆仑万维开源SkyReels-V2,解锁无限时长电影级创作,总分83.9%登顶V-Bench榜单
大数据·人工智能·语言模型·开源