注意:
1)、每6508个字节为一天的数据。(6508 – 8 )/ 26 = 250
2)、每26个字节为一个分钟的记录。
2、当日分时数据格式
(1)、索引数据格式
| 数据含义 |
数据类型 |
备注 |
| 存储标记 |
Byte |
表示在指定地址是否有数据 |
| 起始地址 |
Integer |
股票分时数据块起始地址 |
注意:
1)、索引个数与“\jcb_zxjt\T0002\hq_cache\shex.tnf”或“\jcb_zxjt\T0002\hq_cache\szex.tnf”中的股票个数相同。
(2)、分时数据格式
| 数据含义 |
数据类型 |
备注 |
| 时间 |
Word |
如570/60=9.5,即9:30分 |
| 现价 |
Single |
|
| 均价 |
Single |
|
| 成交量 |
Integer |
|
| 预留 |
|
12个字节 |
注意:
1)、每6240个字节为一天的数据。6240 / 26 = 240
2)、每26个字节为一个分钟的记录。
示例代码
示例:显示分时数据文件信息
备注:uDataBuffer单元代码在“
大智慧Level2日线数据文件格式分析”文档中。
unit uZstData;
interface
uses
uDataBuffer;
type
TDataRecord_min = packed record
time: word;
//--时间
cur:
single; //--现价
avg:
single; //--均价
vol:
Integer; //--成交量
reservation: array[0..2] of Integer; //--保留
end;
TDataRecord_Zst = packed record
date:
Integer; //--日期
Last:
single; //--昨收盘
min:
array[0..249] of TDataRecord_min;
end;
PDataRecord_Zst = ^TDataRecord_Zst;
{历史分时数据}
TStockDataStream_Zst =
class(TRecordStream)
private
function
GetItems(Index: Integer): PDataRecord_Zst;
public
constructor
Create;
//---
property
Items[Index: Integer]: PDataRecord_Zst read GetItems;
default;
end;
implementation
constructor TStockDataStream_Zst.Create;
begin
inherited;
//---
DataSize := sizeof(TDataRecord_Zst);
end;
function TStockDataStream_Zst.GetItems(Index: Integer):
PDataRecord_Zst;
begin
Result := self.Datas[Index];
end;
end.
unit uTfzData;
interface
uses
uDataBuffer;
type
TIndexRecord_Tfz = packed record
UseSign:
byte; //--数据标记
StartAddress: Longword; //--起始地址
end;
PIndexRecord_Tfz = ^TIndexRecord_Tfz;
TDataRecord_min_Tfz = packed record
time: word;
//--时间
cur:
single; //--现价
avg:
single; //--均价
vol:
Integer; //--成交量
reservation: array[0..2] of Integer; //--保留
end;
TDataRecord_Tfz = packed record
min:
array[0..239] of TDataRecord_min_Tfz;
end;
PDataRecord_Tfz = ^TDataRecord_Tfz;
{当日分时数据}
TStockDataStream_Tfz =
class(TCustomStringBuffer)
private
FIndexCount: Integer;
FIndexSize:
Integer;
FDataCount:
word;
FDataSize:
Integer;
function
GetDatas(Index: Integer): PDataRecord_Tfz;
function
GetIndexs(Index: Integer): PIndexRecord_Tfz;
protected
procedure
ClearBuffer; override;
procedure
DoBufferChange; override;
public
constructor
Create;
//---
function
GetDataStartAddress(const AIndex: Integer): Longword;
//---
property
Datas[Index: Integer]: PDataRecord_Tfz read GetDatas;
property
DataCount: word read FDataCount;
property
Indexs[Index: Integer]: PIndexRecord_Tfz read GetIndexs;
property
IndexCount: Integer read FIndexCount;
end;
implementation
constructor TStockDataStream_Tfz.Create;
begin
inherited;
//---
FIndexSize :=
sizeof(TIndexRecord_Tfz);
FDataSize := sizeof(TDataRecord_Tfz);
end;
procedure TStockDataStream_Tfz.ClearBuffer;
begin
inherited;
//---
FIndexCount := 0;
FDataCount := 0;
end;
procedure TStockDataStream_Tfz.DoBufferChange;
const
CNT_MinStockCount = 1500;
//---
function _ReadIndex: Boolean;
var
AIndexLen:
integer;
begin
AIndexLen
:= (self.BufferSize - FDataSize * FDataCount);
FIndexCount
:= AIndexLen div FIndexSize;
//---
Result :=
(AIndexLen mod FIndexSize) = 0;
end;
//---
function _ReadData: Boolean;
begin
FDataCount
:= (self.BufferSize - FIndexSize * CNT_MinStockCount) div
FDataSize;
Result :=
FDataCount > 0;
end;
begin
inherited;
//---
if FDataSize <= 0 then
self.ClearBuffer
else
begin
if not
(_ReadData and _ReadIndex) then
self.ClearBuffer;
end;
end;
function TStockDataStream_Tfz.GetDatas(Index: Integer):
PDataRecord_Tfz;
begin
Result := Pointer(self.Buffer + FIndexSize
* FIndexCount + FDataSize * Index);
end;
function TStockDataStream_Tfz.GetIndexs(Index: Integer):
PIndexRecord_Tfz;
begin
Result := Pointer(self.Buffer + FIndexSize
* Index);
end;
function TStockDataStream_Tfz.GetDataStartAddress(const AIndex:
Integer):
Longword;
begin
Result := FIndexSize * FIndexCount +
FDataSize * AIndex;
end;
end.
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_Zst(const AFile: string; const AListBox: TListBox);
procedure
ShowData_Tfz(const AFile: string; const AListBox: TListBox);
public
procedure
ShowData(const AFile: string; const AListBox: TListBox);
end;
var