This repository has been archived by the owner on Oct 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
TdxTicFile.bt
77 lines (66 loc) · 2.07 KB
/
TdxTicFile.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//------------------------------------------------
//--- 010 Editor v7.0.2 Binary Template
//
// File: TdxTicFileTemplate
// Authors: datochan
// Version: 0.0.1
//------------------------------------------------
typedef struct (int tradeCount, int VolCount) {
DWORD tradeData[tradeCount] <format=hex>;
BYTE volumeData[VolCount] <format=hex>;
} TickItemDetail <optimize=false>;
typedef struct (int detailSize){
DWORD dateTime;
WORD count; // ((WORD)+1)*16作为解压后数据的大小
WORD volOffset <format=hex>; // 成交量的偏移地址
WORD volSize <format=hex>; // 成交量数据的大小
WORD type <read=ReadTickType, comment="交易方向0=buy;1=sell;2=unknown">; // 还需要再处理
DWORD price <read=ReadTickPrice, comment="成交价格">;
DWORD volume; // 成交
TickItemDetail detail((detailSize-volSize)/sizeof(DWORD), volSize);
} TickItem <optimize=false>;
typedef struct {
BYTE market; // 市场类别
char code[7]; // 股票代码
DWORD date; // 日期
DWORD tickSize <format=hex, comment="分笔成交明细大小">;
DWORD unknown <format=hex>;
TickItem item(tickSize-0x14);
}StockTick <optimize=false>;
typedef struct {
WORD stockCount;
StockTick stockTickList[stockCount];
} TickFileData <optimize=false>;
/**
* 设置交易方向
*/
string ReadTickType(WORD &type) {
local string result = "";
SPrintf(result, "%d", type >> 0x0F);
return result;
}
/**
* 设置价格信息
**/
string ReadTickPrice(DWORD &price) {
local string result = "";
SPrintf(result, "%.2f", price * 0.01);
return result;
}
/**
* 设置相对时间
**/
string SetTradeTime(int timeVal) {
local string strOut = "";
local int result = 0x23A;
if (timeVal >= 0 && timeVal <= 0x78) {
result += timeVal;
} else if (timeVal <= 0xF0) {
result = 0x294 + timeVal;
}
SPrintf(strOut, "%02d:%02d", result/60%24, result%60);
return strOut;
}
LittleEndian();
SetBackColor( cLtGray );
TickFileData item;