通达信的日记文件数据格式

通达信的日记文件数据特点如下:

  • 每只股票的日记数据单独存储
  • 日记数据被分为索引和内容两个文件
  • 日记的内容文件路径:T0002/diary/sz/002036.cnt
  • 日记的索引文件路径:T0002/diary/sz/002036.idx

下面的C++程序代码示例通达信日记相关的数据文件的数据结构

/**************************************************
* Tdx Diary File Structure
*
* Diary Path:  T0002/diary/sz/002036.idx (index)
*              T0002/diary/sz/002036.cnt (content)
*
*  File need purge after diary was modifed
**************************************************/

struct TdxDiary_Idx {
  int   id;        // 0xffffffff = deleted, auto incr
  char  dummy1;    // = 0x00
  char  symbol[7]; // 7 char = 6 char symbol + 1 char '\0'
  int   date;      // 20110407
  int   time;      // 13:14:25 = 131425
  int   weather;   // 00 = 晴, 01=阴, 02=雨, 03=雪
  char  title[64]; // title
  int   offset;    // offset in "symbol.cnt"
  int   length;    // content length
  int   date2;     // date2 = date
  int   time2;     // time2 = time

  void set(const char *symbol, const char *title, int offset, int length){
    memset(this->symbol, '\0', 7);
    memset(this->title, '\0', 64);
    this->dummy1 = '\0';
    this->weather=0x03;
    strcpy(this->symbol, symbol);
    strcpy(this->title, title);
    this->offset = offset;
    this->length = length;
  }
  void datetime(int date, int time){
    this->date  = date; this->time  = time;
    this->date2 = date; this->time2  = time;
  }
};