Reading data from Dukascopy tick binary file

匿名 (未验证) 提交于 2019-12-03 01:56:01

问题:

I have downloaded the Dukascopy tick data and I have decompressing it with easylzma library. The original compressed binary file is EURUSD/2010/00/08/12h_ticks.bi5 (EURUSD/2010/ian/8/12h) After decompressing we get the following format:

+-------------------------+--------+-------+ |           time          |  Bid   |   Ask | +-------------------------+--------+-------+ 000003CA 00022EC0 00022EB6 40CCCCCD 41180000 000004F5 00022EB6 00022EB1 4099999A 404CCCCD 

(You can download original compressed file from: EURUSD/2010/00/08/12h_ticks.bi5. After decompressing it with lzma we get the file: 12h_ticks)

Reading the binary file:

int ii1; int ii2; int ii3; float ff1; float ff2; ifstream in("12h_ticks",ofstream::binary); in.read((char*)(&ii1), sizeof(int)); in.read((char*)(&ii2), sizeof(int)); in.read((char*)(&ii3), sizeof(int)); in.read((char*)(&ff1), sizeof(float)); in.read((char*)(&ff2), sizeof(float)); std::cout 

I get the following result:

ii1=-905773056 ii2=-1070726656 ii3=-1238498816 ff1=-4.29492e+08 ff2=8.70066e-42 

What is wrong? I can't read data from binary file. Please help me.

回答1:

The data appears to be stored in big endian format in the file. You'll need to convert it to little endian when you load it.

#include  #include  #include   template void ByteSwap(T* p) {     for (int i = 0;  i 

This gives the result:

ii1=970 ii2=143040 ii3=143030 ff1=6.4 ff2=9.5 

I grabbed the ByteSwap function from here if you want to read more about that subject. How do I convert between big-endian and little-endian values in C++?



回答2:

ii1 is seconds within this hour

ii2 is Ask * 10000

ii3 is Bid * 10000

ff1 is Ask Volume

ff2 is Bid Volume



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!