大智慧SUPERSTK.DAD日线五分钟线数据解析

先公布DAD格式吧,比较简单
5分钟请在转换时间的时候考虑时区的影响
DAT格式,在以后和RPT格式一起公布

 

大智慧的日线五分线数据下载在菜单-》终端-》数据管理-》数据管理中

 

#include "stdafx.h"
#include <io.h>
#include <dos.h>
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>


typedef struct tagFXJADDDAYHEAD
{
char acUnknown1[8];
long nDataNum;
char acUnknown2[4];
} FXJADDDAYHEAD,*PFXJADDDAYHEAD;

typedef struct tagFXJADDDAYINDEX
{
long nFlag;
char acCode[9];
char acTemp[7];
char acName[12];
} FXJADDDAYINDEX,*PFXJADDDAYINDEX;

typedef struct tagFXJDAYUNIT
{
time_t tTime;
float fOpen;
float fHigh;
float fLow;
float fClose;
float fVolume;
float fAmount;
short nUpStockNum;
short nDownStockNum;
} FXJDAYUNIT,*PFXJDAYUNIT;

int main(int argc, char* argv[])
{
FILE *fpDadFile=fopen("d:\\superstk.dad","rb");
if(!fpDadFile) return -1;
FXJADDDAYHEAD fxjAddDayHead;
FXJADDDAYINDEX fxjAddDayIndex;
FXJDAYUNIT fxjAddDayUnit;
fread(&fxjAddDayHead,sizeof(FXJADDDAYHEAD),1,fpDadFile);
for(int i=0; i<600; i++)
{
char acTempBuffer[32];
long nFlag=0;
fread(&acTempBuffer,32,1,fpDadFile);
memcpy(&nFlag,acTempBuffer,sizeof(long));
if(nFlag==-1)
{
memcpy(&fxjAddDayIndex,acTempBuffer,sizeof(FXJADDDAYINDEX));
printf("first stock:%s,%s\n",fxjAddDayIndex.acCode,fxjAddDayIndex.acName);
getch();
continue;
}
memcpy(&fxjAddDayUnit,acTempBuffer,sizeof(FXJDAYUNIT));
struct tm *ptmTime=localtime(&fxjAddDayUnit.tTime);
printf("first date:%04d-%02d-%02d %02d:%02d:%02d\n",ptmTime->tm_year+1900,ptmTime->tm_mon+1,ptmTime->tm_mday,ptmTime->tm_hour,ptmTime->tm_min,ptmTime->tm_sec);
printf("fOpen:%f\n",fxjAddDayUnit.fOpen);
printf("fHigh:%f\n",fxjAddDayUnit.fHigh);
printf("fLow:%f\n",fxjAddDayUnit.fLow);
printf("fClose:%f\n",fxjAddDayUnit.fClose);
printf("fVolume:%f\n",fxjAddDayUnit.fVolume);
printf("fAmount:%f\n",fxjAddDayUnit.fAmount);
printf("nUpStockNum:%d\n",fxjAddDayUnit.nUpStockNum);
printf("nDownStockNum:%d\n",fxjAddDayUnit.nDownStockNum);
}
fclose(fpDadFile);


return 0;
}
分享到:

评论已关闭