搜索
查看: 3579|回复: 4

请教分析家5分钟线安装数据文件的格式?

[复制链接]
发表于 2009-11-14 11:46 | 显示全部楼层

请教分析家5分钟线安装数据文件的格式?

来自:MACD论坛(bbs.macd.cn) 作者:pang2042 浏览:3579 回复:4

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
请教分析家5分钟线安装数据文件的格式?我需要把数据读取出来,请教其二进制格式。
金币:
奖励:
热心:
注册时间:
2005-12-29

回复 使用道具 举报

发表于 2009-11-15 16:55 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
金币:
奖励:
热心:
注册时间:
2009-11-10

回复 使用道具 举报

发表于 2009-12-18 14:55 | 显示全部楼层
我也在做这个,刚刚把数据格式分析出来,以每月的5分钟安装文件为例:
前20个字节为文件头。随后28个字节为股票头,之后每32个字节为一条5分钟行情记录,此股票行情会以"FF FF FF FF"结尾(不包括在32个字节的行情记录内)。"FF FF FF FF"为下一个股票的股票头(28字节),然后继续每32个字节一条5分钟行情记录,...,直到文件结束。

水平有限,若有错漏,欢迎指正。

附VBA程序如下

Option Explicit

Type fxjHeadType
w1 As Single
w2 As Single
numStocks As Long
w4 As Single
w5 As Single
End Type

Type fxjStockDefType
code As String * 8
w3 As Single
w4 As Single
name As String * 12
End Type

Type fxj5minQuoteType
w1 As Long 'date
open As Single
high As Single
low As Single
close As Single
volume As Single
amount As Single
w8 As Long
End Type

Public Sub test()
Dim filename As String
Dim fxjHead As fxjHeadType
Dim fxjStockDef As fxjStockDefType
Dim fxj5minQuote As fxj5minQuoteType
Dim d1 As Long
Dim d2 As Single
Dim currentDate As Date
Dim i, anchor As Long
filename = "D:\my own research\trading data\fxj5min\200904.DAD"
Open filename For Binary As #1
Get #1, , fxjHead
anchor = 21
Do While True
    Seek #1, anchor
    Get #1, , fxjStockDef
    anchor = anchor + 28
    Do While True
        Get #1, , fxj5minQuote
        anchor = anchor + 32
        If fxj5minQuote.w1 = -1 Then
            anchor = anchor - 32 + 4
            Exit Do
        End If
        currentDate = CDate("1970-1-1") + fxj5minQuote.w1 / 86400
        Debug.Print fxjStockDef.code & currentDate & fxj5minQuote.close
    Loop
Loop
Close #1
End Sub

附2:SAS读取的程序
libname HF "D:\my own research\trading data\";
run;


%let FinDataDataSet=HF.fxj5min;
%let FxjDataFile = D:\my own research\trading data\fxj5min\200801.DAD;

filename FxjFile "&FxjDataFile.";
data ResultTable;
        format code $8. datetime datetime. date yymmdd10. time time.;
        infile FxjFile recfm=n end=eof;
        p=21;
        i=0;
        do while (not(eof));
                input @(p) code $8.  @(p+16) name $10;
                p=p+28;
                flag=0;       
                do while (flag ne -1 and not(eof));               
                        input @(p+0) date ib4. @(p+4) TOpen float4. @(p+8) high float4. @(p+12) low float4.
                  @(p+16) TClose float4. @(p+20) volume float4. @(p+24) amount float4.;
                        time=floor(date/86400);
                    datetime = date+(DHMS(MDY(1,1,1970),0,0,0)-DHMS(MDY(1,1,1960),0,0,0) );
                        date=datepart(datetime);
                        time=timepart(datetime);
                        if code in:('SH50','SH51','SZ184','SZ15','SZ16','SH58','SZ03') and date>mdy(3,3,2003) then
                                roundunit=0.001;          else roundunit=0.01;
                        TOpen=round(TOpen,roundunit);
                        high=round(high,roundunit);
                        low=round(low,roundunit);
                        TClose=round(TClose,roundunit);
                        volume=round(volume*100,1);
                        amount=round(amount,0.01);
                        input @(p+32) flag ib4.;       
                        output;
                        if not(flag=-1) then do;
                                p=p+32;
                                end;
                        else do;
                                p=p+36;
                                end;
                        i=i+1;
                end;
        end;
        stop;
        keep code date time TOpen high low TClose volume amount;
run;
金币:
奖励:
热心:
注册时间:
2009-11-11

回复 使用道具 举报

发表于 2010-8-6 11:32 | 显示全部楼层

超牛啊

楼主超牛啊,刚想从DAD数据中找规律,然后用SAS导入,没想到楼主连SAS代码都出来了,佩服。
金币:
奖励:
热心:
注册时间:
2007-7-2

回复 使用道具 举报

签到天数: 2 天

发表于 2010-9-5 22:46 | 显示全部楼层
谢谢分享,收藏
金币:
奖励:
热心:
注册时间:
2002-4-9

回复 使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站声明:1、本站所有广告均与MACD无关;2、MACD仅提供交流平台,网友发布信息非MACD观点与意思表达,因网友发布的信息造成任何后果,均与MACD无关。
MACD俱乐部(1997-2019)官方域名:macd.cn   MACD网校(2006-2019)官方域名:macdwx.com
值班热线[9:00—17:30]:18292674919   24小时网站应急电话:18292674919
找回密码、投诉QQ:89918815 友情链接QQ:95008905 广告商务联系QQ:17017506 电话:18292674919
增值电信业务经营许可证: 陕ICP19026207号—2  陕ICP备20004035号

举报|意见反馈|Archiver|手机版|小黑屋|MACD俱乐部 ( 陕ICP备20004035号 )

GMT+8, 2024-4-25 09:01 , Processed in 0.071411 second(s), 9 queries , Redis On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表