logo资料库

通达信V6股票代码文件格式分析.doc

第1页 / 共7页
第2页 / 共7页
第3页 / 共7页
第4页 / 共7页
第5页 / 共7页
第6页 / 共7页
第7页 / 共7页
资料共7页,全文预览结束
文件位置
数据格式
示例代码
示例:显示股票代码文件信息
单元:uDataBuffer
单元:uTnfData
单元:Unit1
通达信 V6 股票代码文件格式分析 文件位置 /jcb_zxjt/T0002/hq_cache/ shex.tnf /jcb_zxjt/T0002/hq_cache/ szex.tnf 数据格式 1、股票代码数据格式 (1)、文件头部信息 数据含义 IP 地址 未知 日期 时间 数据类型 Char[40] word Integer Integer (2)、股票代码格式 数据含义 数据类型 备注 股票代码 Char[9] 未知 未知 未知 byte word single 相当于 c 语言中的 float,在 DELPHI 中占 4 字节 Integer Integer Integer Char[186] 未知 未知 股票名称 Char[18] 未知 未知 昨日收盘 single byte 未知 Integer 未知 名称缩写 Char[9] 注意: 1)、每 250 个字节为一个记录。
示例代码 示例:显示股票代码文件信息 单元:uDataBuffer 备注:uDataBuffer 单元代码在“大智慧 Level2 日线数据文件格式分析”文档中。 单元:uTnfData unit uTnfData; interface uses uDataBuffer; type TFileHead_Tnf = packed record IP: array[0..39] of char; //--IP 地址 Unknown: word; //--未知 date: Integer; //--日期 time: Integer; //--时间 end; PFileHead_Stock = ^TFileHead_Tnf; TDataRecord_Tnf = packed record StockCode: array[0..8] of char; //--股票代码 Unknown1: byte; //--未知 Unknown2: word; //--未知 Unknown3: single; //--未知 Unknown4: Integer; //--未知 Unknown5: Integer; //--未知 StockName: array[0..17] of char; //--股票名称 Unknown6: Integer; //--未知 Unknown7: array[0..185] of char; //--未知 LastClose: single; //--昨日收盘 Unknown8: byte; //--未知 Unknown9: Integer; //--未知 StockNameSX: array[0..8] of char; //--名称缩写
end; PDataRecord_Stock = ^TDataRecord_Tnf; TStockDataStream_Tnf = class(TCustomStringBuffer) private FFileHead: TFileHead_Tnf; FDataCount: word; FDataSize: Integer; function GetDatas(Index: Integer): PDataRecord_Stock; function GetHead: PFileHead_Stock; protected public procedure ClearBuffer; override; procedure DoBufferChange; override; constructor Create; //--- property Head: PFileHead_Stock read GetHead; property Datas[Index: Integer]: PDataRecord_Stock read GetDatas; property DataCount: word read FDataCount; end; implementation constructor TStockDataStream_Tnf.Create; begin inherited; //--- FDataSize := sizeof(TDataRecord_Tnf); end; procedure TStockDataStream_Tnf.ClearBuffer; begin inherited; //--- FDataCount := 0; end; procedure TStockDataStream_Tnf.DoBufferChange; //--- function _ReadFileHead: Boolean; begin Result := self.BufferSize >= SizeOf(FFileHead); if Result then Move(self.Buffer^,FFileHead,SizeOf(FFileHead));
end; //--- function _ReadData: Boolean; var AStockDataLen: integer; begin AStockDataLen := self.BufferSize - SizeOf(FFileHead); FDataCount := AStockDataLen div FDataSize; //--- Result := AStockDataLen = FDataSize * FDataCount; inherited; //--- if FDataSize <= 0 then self.ClearBuffer end; begin else begin end; end; if not (_ReadFileHead and _ReadData) then self.ClearBuffer; function TStockDataStream_Tnf.GetDatas(Index: Integer): PDataRecord_Stock; begin Result := Pointer(self.Buffer + SizeOf(FFileHead) + FDataSize * Index); end; function TStockDataStream_Tnf.GetHead: PFileHead_Stock; begin Result := @FFileHead; end; end. 单元:Unit1 unit Unit1; interface
uses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms, Dialogs,StdCtrls,ExtCtrls; type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; GroupBox1: TGroupBox; OpenDialog1: TOpenDialog; RadioGroup1: TRadioGroup; Panel1: TPanel; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure ShowData_Tnf(const AFile: string; const AListBox: TListBox); procedure ShowData(const AFile: string; const AListBox: TListBox); private public end; var Form1: TForm1; implementation uses uTnfData; {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin with RadioGroup1.Items do begin clear; Add('股票代码数据'); end; RadioGroup1.ItemIndex := 0; //--- SendMessage(ListBox1.Handle,LB_SetHorizontalExtent,2000,longint(0)); end; procedure TForm1.Button1Click(Sender: TObject); begin with self.OpenDialog1 do
begin if Execute then self.ShowData(FileName,ListBox1); procedure TForm1.ShowData(const AFile: string; const AListBox: TListBox); begin case RadioGroup1.ItemIndex of 0: ShowData_Tnf(AFile,AListBox); end; end; end; end; var procedure TForm1.ShowData_Tnf(const AFile: string; const AListBox: TListBox); AStream: TStockDataStream_Tnf; //--- procedure _ShowHead; begin with AListBox.Items,AStream.Head^ do begin Add(Format('IP 地址:%s', [IP])); Add(Format('未知:%d', [Unknown])); Add(Format('日期:%d 时间:%d ', [date,time])); end; end; //--- procedure _ShowData; var AStockIndex: Integer; begin with AListBox.Items,AStream do begin for AStockIndex := 0 to DataCount - 1 do begin with Datas[AStockIndex]^ do Add(Format('%.4d 代码:%s 未知:%d 未知:%d 未知:%.2f 未知:%d 未 知:%d 名称:%s 未知:%d 未知:%s 昨收:%.2f 未知:%d 未知:%d 缩写:%s', [AStockIndex, StockCode,Unknown1,Unknown2,Unknown3,Unknown4,Unknown5, StockName,Unknown6,Unknown7,LastClose,Unknown8,Unknown 9,StockNameSX])); end;
end; end; begin AStream := TStockDataStream_Tnf.Create; try with AListBox.Items do begin BeginUpdate; Clear; with AStream do begin if ReadFile(AFile) then begin _ShowHead; _ShowData; end; end; EndUpdate; AStream.Free; end; finally end; end; end.
分享到:
收藏