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

行情列表数据

行情列表数据接收

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

发送命令: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;
相关推荐
LunarCod7 小时前
Ubuntu使用Docker搭建SonarQube企业版(含破解方法)
linux·运维·服务器·ubuntu·docker·开源·sonarqube
无心水10 小时前
【程序员AI入门:模型】19.开源模型工程化全攻略:从选型部署到高效集成,LangChain与One-API双剑合璧
人工智能·langchain·开源·ai入门·程序员ai开发入门·程序员的 ai 开发第一课·程序员ai入门
zkmall11 小时前
商业架构 2.0 时代:ZKmall开源商城前瞻性设计如何让 B2B2C 平台领先同行 10 年?
架构·开源
zkmall16 小时前
Java + 鸿蒙双引擎:ZKmall开源商城如何定义下一代B2C商城技术标准?
java·开源·harmonyos
说私域17 小时前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的低集中度市场运营策略研究
人工智能·小程序·开源·零售
charles_vaez17 小时前
开源模型应用落地-模型上下文协议(MCP)-Resources-资源的使用逻辑
深度学习·语言模型·自然语言处理·开源
一个没有感情的程序猿18 小时前
当 PyIceberg 和 DuckDB 遇见 AWS S3 Tables:打造 Serverless 数据湖“开源梦幻组合”
开源·serverless·aws
yzx99101318 小时前
Gensim 是一个专为 Python 设计的开源库
开发语言·python·开源
时序数据说18 小时前
IoTDB集群的一键启停功能详解
大数据·数据库·开源·时序数据库·iotdb
小众AI18 小时前
Suna: 开源多面手 AI 代理
人工智能·开源