/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 |
|
未知 |
Integer |
|
未知 |
Integer |
|
股票名称 |
Char[18] |
|
未知 |
Integer |
|
未知 |
Char[186] |
|
昨日收盘 |
single |
|
未知 |
byte |
|
未知 |
Integer |
|
名称缩写 |
Char[9] |
|
注意:
1)、每250个字节为一个记录。
备注:uDataBuffer单元代码在“大智慧Level2日线数据文件格式分析”文档中。
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
procedure ClearBuffer; override;
procedure DoBufferChange; override;
public
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;
end;
begin
inherited;
//---
if FDataSize <= 0 then
self.ClearBuffer
else
begin
if not (_ReadFileHead and _ReadData) then
self.ClearBuffer;
end;
end;
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.
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_Tnf(const AFile: string; const AListBox: TListBox);
public
procedure ShowData(const AFile: string; const AListBox: TListBox);
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);
end;
end;
procedure TForm1.ShowData(const AFile: string; const AListBox: TListBox);
begin
case RadioGroup1.ItemIndex of
0: ShowData_Tnf(AFile,AListBox);
end;
end;
procedure TForm1.ShowData_Tnf(const AFile: string;
const AListBox: TListBox);
var
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,Unknown9,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;
end;
finally
AStream.Free;
end;
end;
end.