加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

通达信股票软件日线数据分析

(2012-11-28 05:53:41)
标签:

通达信

日线

数据

分析

软件

股票

分类: 一些研究总结

日线文件以"代号"+"股票代码"+".day"命名,代号为"sh"或"sz",股票代码6位,一个记录32个字节。


以深发展1997年1月2日的数据为例:
00000000h: 36 B8 30 01 72 06 00 00 86 06 00 00 60 06 00 00 ;
00000010h: 72 06 00 00 77 69 D4 4C 68 FE 66 00 74 06 00 00 ;


以下是分解
00000000h:|36 B8 30 01|72 06 00 00|86 06 00 00|60 06 00 00|;
[36 B8 30 01] = 0x0130B836 = 19970102        日期[unsigned long]
[72 06 00 00] = 0x00000672 = 1650/100 = 16.50    开盘[unsigned long]
[86 06 00 00] = 0x00000686 = 1670/100 = 16.70    最高[unsigned long]
[60 06 00 00] = 0x00000660 = 1632/100 = 16.32    最低[unsigned long]
00000010h:|72 06 00 00|77 69 D4 4C|68 FE 66 00|74 06 00 00|;
[72 06 00 00] = 0x00000672 = 1650/100 = 16.50    收盘[unsigned long]
[77 69 D4 4C] = 0x4CD46977 = 111365048.0    成交额[float]
[68 FE 66 00] = 0x0066FE68 = 6749800        成交量[unsigned long]
[74 06 00 00] = 0x00000674 = 1652/100 = 16.52    上日收盘[unsigned long](保留)


1-4字节 Date:LongInt; //日期
   5-8字节 OPen:LongInt; //开盘*100(元)
9-12字节 High:LongInt; //最高价*100(元)

13-16字节 Low:LongInt; //最低价*100(元)
   17-20字节 Close:LongInt; //收盘*100(元)
    
   21-24字节 single; //Amount
25-28字节 Volume:LongInt; //Volume 成交量(股)
29-32字节 // Reserved

#include
#include
#include
using namespace std;

struct TDSData_Day
{
    unsigned long date;             //日期
    unsigned long open;             //开盘价,单位:分
    unsigned long high;             //最高价,单位:分
    unsigned long low;              //最低价,单位:分
    unsigned long close;            //收盘价,单位:分
    float amount;                   //交易金额,单位:元
    unsigned long vol;              //成交量,单位:股
    int reserv;                     //保留,有时用来保存上一交易日收盘价
};

void showData(TDSData_Day data)
{
     cout << "日  期:" << data.date << endl;
     cout << "开盘价:" << setw(8) << setprecision(2) << data.open / 100.0 << " 元\t";
     cout << "最高价:" << setw(8) << data.high / 100.0 << " 元\t";
     cout << "最低价:" << setw(8) << data.low / 100.0 << " 元\t";
     cout << "收盘价:" << setw(8) << data.close / 100.0 << " 元\t" <<endl;
     cout << "成交额:" << setw(12) << fixed << setprecision(0) << data.amount << " 元" <<endl;
     cout << "成交量:" << setw(12) << data.vol << " 股" <<endl;
     cout << "昨收盘:" << setw(8) << setprecision(2) << data.reserv/100.0 << " 元" <<endl;
}

int main()
{
    TDSData_Day myIn;
    cout << "文件读出测试" << endl;
   
    ifstream fin;
    const char* fname = "D:\\new_dgzq\\Vipdoc\\sz\\lday\\sz000001.day";
    fname ="sz000001.day";
    fin.open(fname,ios::binary | ios::in);
    for(int i = 0; i < 5; i++)
    {
            fin.read(reinterpret_cast(&myIn), sizeof(TDSData_Day));
            showData(myIn);
    }
    fin.close();
    fname ="sz000002.day";
    fin.open(fname,ios::binary | ios::in);
    for(int i = 0; i < 5; i++)
    {
            fin.read(reinterpret_cast(&myIn), sizeof(TDSData_Day));
            showData(myIn);
    }
    fin.close();

    cout << "Done!";
    return 0;
}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有