通达信数据格式

@ 2011-08-06 11:49:32
标签:

日K线数据格式

/*
* 文件路径: Vipdoc/sz/*.lday
*          Vipdoc/sh/*.lday
*/
struct TdxRecord {     // 日K线数据结构
  unsigned int date;   // e.g. 20100304
  int _open;           // *0.01 开盘价
  int _high;           // *0.01 最高价
  int _low;            // *0.01 最低价
  int _close;          // *0.01 收盘价
  float amount;        // 成交额
  int vol;             // 成交量(手)
  int reserved;        

  float open(){  return 0.01*_open; }
  float high(){  return 0.01*_high; }
  float low(){   return _low*0.01; }
  float close(){ return _close*0.01; }
};

日记文件数据格式

/**************************************************
* 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;
  }
};

股票代码和名称数据格式

/***************************************************
* 股票代码列表和股票名称
*  T0002/hq_cache/shex.tnf
*  T0002/hq_cache/szex.tnf
***************************************************/

struct TdxSymbolMap {
  char symbol[6];    // 6 digits
  char dummy1[18]
  char name[8];      // 4 characters in GB2312
  char dummy2[218];
}


void tdx_read_symbols(const char *file){
  FILE *fp=fopen(file.c_str(),"rb");
  fseek(fp, 50, SEEK_SET);
  char buf[250];
  while(250 == fread(buf,1,250,fp)){
    std::string symbol(buf,0,6);
    std::string name(buf+24,8);
  }
  fclose(fp);
}
标签:

分享到:
comments powered by Disqus

25/28ms