您的位置:首页 > 其它

通达信V6.1日线数据文件格式分析

2010-09-04 16:36 519 查看

通达信V6日线数据文件格式分析

文件位置

1、历史日线数据
/jcb_zxjt/Vipdoc/sh/lday/sh000001.day
/jcb_zxjt/Vipdoc/sz/lday/sz000001.day

2、临时日线数据
/jcb_zxjt/T0002/cache/sz000005.day

数据格式

1、历史日线数据格式
数据含义
数据类型
实际值
单位
日期
Integer
开盘价
Integer
当前值 / 100

最高价
Integer
当前值 / 100

最低价
Integer
当前值 / 100

收盘价
Integer
当前值 / 100

成交金额
single

成交量
Integer

保留
Integer
注意:
1)、每32byte为一条股票数据分配记录.

2、临时日线数据格式
数据含义
数据类型
单位
日期
Integer
开盘价
Single

最高价
Single

最低价
Single

收盘价
Single

成交金额
single

成交量
Integer

保留
Integer
注意:
1)、每32byte为一条股票数据分配记录。
2)、文件头部有一个4字节的附加信息。

示例代码

示例:显示日线数据文件信息

单元:uDataBuffer
备注:uDataBuffer单元代码在“大智慧Level2日线数据文件格式分析”文档中。

单元:uDayData
unit uDayData;

interface

uses
uDataBuffer;

type
{历史日线数据}
TDataRecord_Day = packed record
date: Integer; //--日期
open: Integer; //--开盘
high: Integer; //--最高
low: Integer; //--最低
close: Integer; //--收盘
amount: single; //--成交金额
vol: Integer; //--成交数量
reservation: Integer; //--保留
end;
PTDataRecord_Day = ^TDataRecord_Day;

TStockDataStream_Day = class(TRecordStream)
private
function GetItems(Index: Integer): PTDataRecord_Day;
public
constructor Create;
//---
property Items[Index: Integer]: PTDataRecord_Day read GetItems; default;
end;

implementation

constructor TStockDataStream_Day.Create;
begin
inherited;
//---
DataSize := sizeof(TDataRecord_Day);
end;

function TStockDataStream_Day.GetItems(Index: Integer): PTDataRecord_Day;
begin
Result := self.Datas[Index];
end;

end.

单元:uCacheDayData
unit uCacheDayData;

interface

uses
uDataBuffer;

type
{临时日线数据}
TDataRecord_CacheDay = packed record
date: Integer; //--日期
open: single; //--开盘
high: single; //--最高
low: single; //--最低
close: single; //--收盘
amount: single; //--成交金额
vol: Integer; //--成交数量
reservation: Integer; //--保留
end;
PTDataRecord_CacheDay = ^TDataRecord_CacheDay;

TStockDataStream_CacheDay = class(TCustomStringBuffer)
private
FCount: Integer;
FDataSize: Integer;
FFileHeadSize: Integer;
function GetItems(Index: Integer): PTDataRecord_CacheDay;
protected
procedure ClearBuffer; override;
procedure DoBufferChange; override;
public
constructor Create;
//---
property Count: Integer read FCount;
property Items[Index: Integer]: PTDataRecord_CacheDay read GetItems; default;
end;

implementation

constructor TStockDataStream_CacheDay.Create;
begin
inherited;
//---
FDataSize := sizeof(TDataRecord_CacheDay);
FFileHeadSize := 4;
end;

procedure TStockDataStream_CacheDay.ClearBuffer;
begin
inherited;
//---
FCount := 0;
end;

procedure TStockDataStream_CacheDay.DoBufferChange;
//---
procedure _RefreshCount;
var
ADataLen: integer;
begin
ADataLen := self.BufferSize - FFileHeadSize;
//---
FCount := ADataLen div FDataSize;
if FDataSize * FCount <> ADataLen then
self.ClearBuffer;
end;
begin
inherited;
//---
if FDataSize <= 0 then
self.ClearBuffer
else
_RefreshCount;
end;

function TStockDataStream_CacheDay.GetItems(Index: Integer): PTDataRecord_CacheDay;
var
p: PChar;
begin
p := self.Buffer;
inc(p,FFileHeadSize + FDataSize * Index);
//---
Result := Pointer(p);
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_Day(const AFile: string; const AListBox: TListBox);
procedure ShowData_CacheDay(const AFile: string; const AListBox: TListBox);
public
procedure ShowData(const AFile: string; const AListBox: TListBox);
end;

var
Form1: TForm1;

implementation

uses uDayData,uCacheDayData;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
with RadioGroup1.Items do
begin
clear;
Add('历史日线数据');
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_Day(AFile,AListBox);
1: ShowData_CacheDay(AFile,AListBox);
end;
end;

procedure TForm1.ShowData_Day(const AFile: string; const AListBox: TListBox);
var
AStream: TStockDataStream_Day;
i: Integer;
begin
AStream := TStockDataStream_Day.Create;
try
with AListBox.Items do
begin
BeginUpdate;
Clear;
with AStream do
begin
if ReadFile(AFile) then
begin
for i := 0 to Count - 1 do
begin
with items[i]^ do
Add(Format('%.3d %d 开%d 高%d 低%d 收%d 额%.2f 量%d 保留%d', [i,date,
open,high,low,close,amount,vol,reservation]));
end;
end;
end;
EndUpdate;
end;
finally
AStream.Free;
end;
end;

procedure TForm1.ShowData_CacheDay(const AFile: string;
const AListBox: TListBox);
var
AStream: TStockDataStream_CacheDay;
i: Integer;
begin
AStream := TStockDataStream_CacheDay.Create;
try
with AListBox.Items do
begin
BeginUpdate;
Clear;
with AStream do
begin
if ReadFile(AFile) then
begin
for i := 0 to Count - 1 do
begin
with items[i]^ do
Add(Format('%.3d %d 开%.2f 高%.2f 低%.2f 收%.2f 额%.2f 量%d 保留%d', [i,date,
open,high,low,close,amount,vol,reservation]));
end;
end;
end;
EndUpdate;
end;
finally
AStream.Free;
end;
end;

end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: