通达信的股票代码和名称数据结构
可以通过读取通达信的缓存数据,来获取一份股票代码和名称列表。
通达信中,股票名称的数据文件的后缀是tnf。相关文件有:
- 沪市:
T0002/hq_cache/shex.tnf - 深市:
T0002/hq_cache/szex.tnf
下面的C++程序代码,示例了如何从通达信的缓存数据中读取股票的代码和名称列表。
/***************************************************
* 股票代码列表和股票名称
* 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);
}