通达信V6.1概念板块分类文件格式分析
通達信V6概念板塊分類文件格式分析
文件位置
/jcb_zxjt/T0002/hq_cache/ block.dat
?
數據格式
(1)、文件頭部信息
| 數據含義 | 數據類型 | 備注 |
| 文件信息 | Char[64] | ? |
| 板塊索引信息起始位置 | Integer | ? |
| 板塊記錄信息起始位置 | Integer | ? |
| 未知 | Integer * 3 | ? |
?
(2)、板塊索引信息,開始于0x0054h
| 數據含義 | 數據類型 | 備注 |
| 索引名稱 | Char[64] | ? |
| 未知 | Integer * 9 | ? |
注意:
1)、每個板塊索引信息占的長度為100個字節。
?
(3)、板塊記錄信息,開始于0x0180h
| 數據含義 | 數據類型 | 備注 |
| 板塊數量 | word | 起始位置為0x180h |
?
板塊記錄結構
| 數據含義 | 數據類型 | 備注 |
| 板塊名稱 | Char [9] | ? |
| 證券數量 | word | ? |
| 板塊級別 | word | ? |
| 證券代碼 | Char [7] * 400 | ? |
注意:
1)、第一個版塊的起始位置為0x182h。
2)、每個板塊占的長度為2813個字節。
3)、每個板塊最多包括400只股票。(2813 -9 - 2 - 2) / 7 =? 400
?
?
示例代碼
示例:顯示板塊數據文件信息
單元:uDataBuffer
備注:uDataBuffer單元代碼在“大智慧Level2日線數據文件格式分析”文檔中。
?
單元:uBlockData
unit uBlockData;
?
interface
?
uses
??? uDataBuffer;
?
type
??? TFileHead_Block = packed record
??????? FileInfo: array[0..63] of char; //--文件信息
??????? BlockIndexStart: Integer; //--板塊索引信息起始位置
??????? BlockDataStart: Integer; //--板塊記錄信息起始位置
??????? Unknown: array[0..2] of Integer; //--未知
??? end;
??? PFileHead_Block = ^TFileHead_Block;
?
??? TIndexRecord_Block = packed record
??????? IndexName: array[0..63] of char; //--索引名稱
??????? Unknown: array[0..8] of Integer; //--未知
??? end;
??? PIndexRecord_Block = ^TIndexRecord_Block;
?
??? TStockCode = array[0..6] of char;
?
??? TDataRecord_Block = packed record
??????? BlockName: array[0..8] of char; //--板塊名稱
??????? StockCount: word; //--證券數量
??????? BlockLevel: word; //--板塊級別
??????? StockCodes: array[0..399] of TStockCode; //--證券代碼
??? end;
??? PDataRecord_Block = ^TDataRecord_Block;
?
??? TStockDataStream_Block = class(TCustomStringBuffer)
??? private
??????? FFileHead: TFileHead_Block;
??????? FIndexCount: Integer;
??????? FIndexSize: Integer;
??????? FDataCount: word;
??????? FDataSize: Integer;
??????? function GetDatas(Index: Integer): PDataRecord_Block;
??????? function GetHead: PFileHead_Block;
??????? function GetIndexs(Index: Integer): PIndexRecord_Block;
??? protected
??????? procedure ClearBuffer; override;
??????? procedure DoBufferChange; override;
??? public
??????? constructor Create;
??????? //---
??????? property Head: PFileHead_Block read GetHead;
??????? property Datas[Index: Integer]: PDataRecord_Block read GetDatas;
??????? property DataCount: word read FDataCount;
??????? property Indexs[Index: Integer]: PIndexRecord_Block read GetIndexs;
??????? property IndexCount: Integer read FIndexCount;
??? end;
?
implementation
?
constructor TStockDataStream_Block.Create;
begin
??? inherited;
??? //---
??? FIndexSize := sizeof(TIndexRecord_Block);
??? FDataSize := sizeof(TDataRecord_Block);
end;
?
procedure TStockDataStream_Block.ClearBuffer;
begin
??? inherited;
??? //---
??? FIndexCount := 0;
??? FDataCount := 0;
end;
?
procedure TStockDataStream_Block.DoBufferChange;
??? //---
??? function _ReadFileHead: Boolean;
??? begin
??????? Result := self.BufferSize >= SizeOf(FFileHead);
??????? if Result then
??????????? Move(self.Buffer^,FFileHead,SizeOf(FFileHead));
??? end;
??? //---
??? function _ReadIndex: Boolean;
??? var
??????? ABlockIndexLen: integer;
??? begin
??????? Result := self.BufferSize >= FFileHead.BlockDataStart;
??????? if Result then
??????? begin
??????????? ABlockIndexLen := (FFileHead.BlockDataStart - FFileHead.BlockIndexStart);
??????????? FIndexCount := ABlockIndexLen div FIndexSize;
??????????? //---
??????????? Result := ABlockIndexLen = FIndexSize * FIndexCount;
??????? end;
??? end;
??? //---
??? function _ReadData: Boolean;
??????? //---
??????? function _GetDataCount: Boolean;
??????? var
??????????? p: Pchar;
??????? begin
??????????? Result := self.BufferSize >= FFileHead.BlockDataStart + SizeOf(FDataCount);
??????????? if Result then
??????????? begin
??? ????????????p := self.Buffer;
??????????????? inc(p,FFileHead.BlockDataStart);
??????????????? Move(p^,FDataCount,SizeOf(FDataCount));
??????????????? //---
??????????????? Result := FDataCount > 0;
??????????? end;
??????? end;
??????? //---
??????? function _CheckDataLen: Boolean;
??????? begin
??????????? Result := self.BufferSize = FFileHead.BlockDataStart + SizeOf(FDataCount) + FDataSize * FDataCount;
??????? end;
??? begin
??????? Result := _GetDataCount and _CheckDataLen;
??? end;
begin
??? inherited;
??? //---
??? if FDataSize <= 0 then
??????? self.ClearBuffer
??? else
??? begin
??????? if not (_ReadFileHead and _ReadIndex and _ReadData) then
??????????? self.ClearBuffer;
??? end;
end;
?
function TStockDataStream_Block.GetDatas(Index: Integer): PDataRecord_Block;
begin
??? Result := Pointer(self.Buffer + FFileHead.BlockDataStart + SizeOf(FDataCount) + FDataSize * Index);
end;
?
function TStockDataStream_Block.GetHead: PFileHead_Block;
begin
??? Result := @FFileHead;
end;
?
function TStockDataStream_Block.GetIndexs(Index: Integer): PIndexRecord_Block;
begin
??? Result := Pointer(self.Buffer + FFileHead.BlockIndexStart + FIndexSize * Index);
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);
??? private
??????? procedure ShowData_Block(const AFile: string; const AListBox: TListBox);
??? public
??????? procedure ShowData(const AFile: string; const AListBox: TListBox);
??? end;
?
var
??? Form1: TForm1;
?
implementation
?
uses uDayData,uCacheDayData,uZstData,uBlockData;
?
{$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);
??? end;
end;
?
procedure TForm1.ShowData(const AFile: string; const AListBox: TListBox);
begin
??? case RadioGroup1.ItemIndex of
??????? 0: ShowData_Block(AFile,AListBox);
??? end;
end;
?
procedure TForm1.ShowData_Block(const AFile: string;
??? const AListBox: TListBox);
var
??? AStream: TStockDataStream_Block;
??? //---
??? procedure _ShowHead;
??? var
??????? i: integer;
??? begin
??????? with AListBox.Items,AStream.Head^ do
??????? begin
??????????? Add(Format('文件信息:%s', [FileInfo]));
??????????? Add(Format('板塊索引起始位置:%d', [BlockIndexStart]));
??????????? Add(Format('板塊記錄起始位置:%d', [BlockDataStart]));
??????????? //---
??????????? for i := low(Unknown) to high(Unknown) do
??????????????? Add(Format('未知:%d', [Unknown[i]]));
??????? end;
??? end;
??? //---
??? procedure _ShowIndex;
??? var
??????? j,AIndex: Integer;
??? begin
??????? with AListBox.Items,AStream do
??????? begin
??????????? Add('--------索引---------');
??????????? //---
??????????? for AIndex := 0 to IndexCount - 1 do
??????????? begin
??????????????? with Indexs[AIndex]^ do
??????????????? begin
??????????????????? Add(Format('索引名稱:%s', [IndexName]));
??????????????????? //---
??????????????????? for j := low(Unknown) to high(Unknown) do
??????????? ????????????Add(Format('未知:%d', [Unknown[j]]));
??????????????? end;
??????????? end;
??????? end;
??? end;
??? //---
??? procedure _ShowData;
??? var
??????? ABlockIndex,AStockIndex: Integer;
??? begin
??????? with AListBox.Items,AStream do
??????? begin
??????????? Add('--------板塊---------');
??????????? //---
??????????? Add(Format('板塊數量:%d', [DataCount]));
??????????? if DataCount > 0 then
??????????????? Add(Format('板塊數據大小:%d', [sizeof(Datas[ABlockIndex]^) * DataCount]));
??????????? Add(' ');
??????? ????//---
??????????? for ABlockIndex := 0 to DataCount - 1 do
??????????? begin
??????????????? with Datas[ABlockIndex]^ do
??????????????? begin
??????????????????? Add(Format('板塊%d 板塊名稱:%s 證券數量:%d 板塊級別:%d', [ABlockIndex + 1,BlockName,StockCount,BlockLevel]));
??????????????????? for AStockIndex := low(StockCodes) to high(StockCodes) do
??????????????????????? Add(Format('%.3d 代碼:%s', [AStockIndex + 1,StockCodes[AStockIndex]]));
??????????????? end;
??????????? end;
??????? end;
??? end;
begin
??? AStream := TStockDataStream_Block.Create;
??? try
??????? with AListBox.Items do
??????? begin
??????????? BeginUpdate;
??????????? Clear;
??????????? with AStream do
??????????? begin
??????????????? if ReadFile(AFile) then
??????????????? begin
??????????????? ????_ShowHead;
??????????????????? _ShowIndex;
??????????????????? _ShowData;
??????????????? end;
??????????? end;
??????????? EndUpdate;
??????? end;
??? finally
??????? AStream.Free;
??? end;
end;
?
end.
?
總結
以上是生活随笔為你收集整理的通达信V6.1概念板块分类文件格式分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 拥有一台云服务器可以干什么?
- 下一篇: 百万富翁问题--安全多方计算