




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Shibor数据接口使用手册登入服务器:启动客户端程序,进入登入界面,输入用户名和密码,如下图1图1点击确定后,程序自动从互联网下载最新一天的数据并提示运作状态,如下图2.1, 如果登入的时间为当日11:30分之前,会出现如图2.2的提示。图2.1 图2.2之后登入成功进入程序主界面。数据下载进入程序主界面后自动进入数据下载页面,如下图3,通过下拉菜单选择所需下载的某年某月的数据图3注:如数据下载完成后提示“数据下载成功,但文件保存失败”,请查看程序安装目录下的save目录中的文件是否已被损坏,如果损坏请手动删除该文件,重新下载历史数据。数据转换在主界面点击数据转换按钮,进入数据转换页面,如下图4 图4输入所需转换的时间段,点击导出按钮,弹出转换结果后,在程序的安装路径下的convert目录中会生成转换后的文件。(例如:程序的安装路径为C:ShiborDataClient,那么生成的转换文件在C:ShiborDataClientconvert目录下)Imix数据解析说明iMIX消息传输示例1、iMIX消息分为消息头(Header)、消息体(Body)、消息尾(Trailer)三部分,消息头(Header)主要承载消息传输协议本身所需要的一些信息;消息体(Body)主要承载消息内容本身;消息尾(Trailer)主要负责检验等工作。2、由于iMIX协议基于“FIX4.4”制定,目前还没有制定完成,所以我们暂时使用“FIX4.4”协议作为“iMIX1.0”协议,进行iMIX消息的传输示例。2.1、为保证消息被正确传输,域“8、9、10、34、35、49、52、56”在“iMIX1.0”协议中为必需域,在消息头(Header)、消息尾(Trailer)中使用。8BeginString9BodyLength35MsgType49SenderCompID56TargetCompID34MsgSeqNum52SendingTime10CheckSum2.2、域“43、50、57、89、90、91、93、97、115、116、122、128、129、142、143、144、145、212、213、347、369、627、628、629、630”在iMIX协议中作为可选域,在消息头(Header)、消息尾(Trailer)中使用,来保证消息被正确、安全地在多方之间传输。2.3、消息头(Header)中的MsgType域(域 35)被用来设定消息类型; 其中, 0、1、2、3、4、5、A 六种消息类型被用来作为 Admin消息,以保证消息通讯。其他消息类型均为App消息。3、API提供下列方法来构造消息:3.1Message message = new Message();3.2NewOrderSingle newOrderSingle1 = new NewOrderSingle();3.3NewOrderSingle newOrderSingle2 = new NewOrderSingle(new ClOrdID(123), new Side(Side.BUY), new TransactTime(), new OrdType(2);3.4Message message = new Message(String string);3.5Message message = Message.createMessage(String beginString, String msgType);4、API提供下列方法来得到消息头(Header)和消息尾(Trailer):4.1message.getHeader();4.2message.getTrailer();5、API提供下列2类方式来构造域: 5.1.1new StringField(Field_Tag, String_Value);new CharField (Field_Tag, Char_Value);new BooleanField (Field_Tag, Boolean_Value);new IntField(Field_Tag, Int_Value);new DoubleField(Field_Tag, Double_Value);5.1.2new StringField(Field_Tag);new CharField (Field_Tag);new BooleanField (Field_Tag);new IntField(Field_Tag);new DoubleField(Field_Tag);5.2.1new ClOrdID(123); 5.2.2new Price();6、提供下列方法来把一个具体的域添加到一条消息中去:6.1Message.setField(new XXField(Field_Tag, XX_Value);6.2message.setField(new Text(Cancel My Order!);6.3newOrderSingle.set(new Price(1);6.4String string = Field_Tag=value001 + Field_Tag=value001;7、设置group的方式与设置消息体(Body)的方式相似,并提供下列方法添加Group到一条消息中去:7.1Group group = createGroup(String beginString, String msgType, int correspondingFieldID);Group group = new Group(int field, int delim);7.2message.addGroup(group);MarketDataSnapshotFullRefresh.NoMDEntries group = new MarketDataSnapshotFullRefresh.NoMDEntries();group.set(new MDEntryType(0);group.set(new MDEntryPx(12.32);group.set(new MDEntrySize(100);group.set(new OrderID(ORDERID);message.addGroup(group);8、对于接收到的消息,可以提供下列两种方式分别从消息头(Header)、消息体(Body)、消息尾(Trailer)中取出具体的域和值(包括group):一是根据消息中应包含的具体的域取值;二是用迭代的方法取值。public void fromApp(iMixMessage message, Operator operator) messageCrack(message);8.1.1onMessage(NewOrderSingle order, Operator operator) Symbol symbol = new Symbol(); Side side = new Side(); OrdType ordType = new OrdType(); OrderQty orderQty = new OrderQty(); Price price = new Price(); ClOrdID clOrdID = new ClOrdID(); order.get(ordType);order.get(symbol); order.get(side); order.get(orderQty); order.getField(price); order.get(clOrdID);8.1.2MarketDataSnapshotFullRefresh.NoMDEntries group =new MarketDataSnapshotFullRefresh.NoMDEntries(); NoMDEntries noMDEntries = new NoMDEntries(); int GroupNum = message.get(noMDEntries).getValue(); MDEntryType MDEntryType = new MDEntryType(); MDEntryPx MDEntryPx = new MDEntryPx();MDEntrySize MDEntrySize = new MDEntrySize();OrderID orderID = new OrderID();for(int i = 1; i 1) System.out.println(prefix + -); fieldMap.getGroup(i, g); printFieldMap(prefix + , dd, msgType, g); i+; 解析实例:首先在工程中导入Imix的jar包(iMIXProtocol.jar),然后引入解析时所需的解析文件iMIX10.xml和MessageUtils.java,下面给出具体解析实例。注:上述红色字体文件均可在“上海银行间同业拆放利率数据下载与转换工具”程序在本地安装的example目录中找到。示例一:Shibor数据解析: public static void getShibor()DefaultMessageFactory msgFactory = new DefaultMessageFactory();DataDictionary dd = null;DBResultDataSet quoteData = new DBResultDataSet();try dd = new DataDictionary(iMIX10.xml);Message msg = (Message)MessageUtils.parse(msgFactory, dd, inImaxString);/ inImaxString 为传入需要解析的数据TransactTime tt1 = new TransactTime();NoMDTypes nomdtypes1 = new NoMDTypes();/-shibor-MDType mdtype1 = new MDType();NoRelatedSym norelatedsym1 = new NoRelatedSym();SecurityID securityid1 = new SecurityID();SecurityIDSource securityidsource1 = new SecurityIDSource();MDEntryType mdentrytype1 = new MDEntryType();MDEntryPx mdentrypx1 =new MDEntryPx();NoMDEntries nomdentries1 = new NoMDEntries();msg.getField(tt1);String tmp = DataUtil.date2StringDate(tt1.getValue();/msg.getGroup(1, nomdtypes1);nomdtypes1.get(mdtype1);int colSize = nomdtypes1.get(new imix.field.NoRelatedSym().getValue();String shiborStr = new StringcolSize+1;shiborStr0 = tmp;for(int i = 1; i = nomdtypes1.get(new imix.field.NoRelatedSym().getValue(); i+)nomdtypes1.getGroup(i, norelatedsym1);norelatedsym1.get(securityid1);securityid1.getValue();/termCodenorelatedsym1.get(securityidsource1);for(int j = 1; j = norelatedsym1.get(new imix.field.NoMDEntries().getValue(); j+)norelatedsym1.getGroup(j, nomdentries1);nomdentries1.get(mdentrytype1);nomdentries1.get(mdentrypx1);shiborStri = new BigDecimal(mdentrypx1.getValue().setScale(4,BigDecimal.ROUND_HALF_UP).toString();/ quoteData.addRow(shiborStr);System.out.println(print: Shibor);for(int y=0;yshiborStr.length;y+)System.out.print (shiborStry+ ); System.out.println(); catch (Exception e1) e1.printStackTrace();示例二: 银行报价解析: public static void getQuote()DefaultMessageFactory msgFactory = new DefaultMessageFactory();DataDictionary dd = null;DBResultDataSet quoteData = new DBResultDataSet();try dd = new DataDictionary(iMIX10.xml);Message msg = (Message)MessageUtils.parse(msgFactory, dd, inImaxString); / inImaxString 为传入需要解析的数据TransactTime tt1 = new TransactTime();SecurityID securityid1 = new SecurityID();SecurityIDSource securityidsource1 = new SecurityIDSource();NoQuoteSets noquotesets1 = new NoQuoteSets();QuoteSetID quotesetid1 = new QuoteSetID();NoPartyIDs nopartyids1 = new NoPartyIDs();PartyID partyid1 = new PartyID();NoPartySubIDs nopartysubids1 = new NoPartySubIDs();PartySubID partysubid1 = new PartySubID();PartySubIDType partysubidtype1 = new PartySubIDType();NoQuoteEntries noquoteentries1 = new NoQuoteEntries();securityid1 = new SecurityID();securityidsource1 = new SecurityIDSource();NoLegs nolegs3 = new NoLegs();LegSecurityID legsecurityid1 = new LegSecurityID();LegSide legside1 = new LegSide();LegPrice legprice1 = new LegPrice();msg.getField(tt1);System.out.println(print:Quote);for(int i = 1; i = msg.getField(new imix.field.NoQuoteSets().getValue(); i+)msg.getGroup(i, noquotesets1);int colSize = noquotesets1.get(new imix.field.NoQuoteEntries().getValue();String shiborStr = new StringcolSize*2+2;shiborStr0 = DataUtil.date2StringDate(tt1.getValue();/noquotesets1.get(quotesetid1);for(int k = 1; k = noquotesets1.get(new imix.field.NoPartyIDs().getValue(); k+)noquotesets1.getGroup(k, nopartyids1);nopartyids1.get(partyid1);for(int j = 1; j = nopartyids1.get(new imix.field.NoPartySubIDs().getValue(); j+)nopartyids1.getGroup(j, nopartysubids1);nopartysubids1.get(partysubid1);shiborStr1 = partysubid1.getValue();/nopartysubids1.get(partysubidtype1); for(int n = 1; n = noquotesets1.get(new imix.field.NoQuoteEntries().getValue(); n+)noquotesets1.getGroup(n, noquoteentries1);noquoteentries1.get(securityid1);noquoteentries1.get(securityidsource1);for(int m = 1; m = noquoteentries1.get(new imix.field.NoLegs().getValue(); m+)noquoteentries1.getGroup(m, nolegs3);nolegs3.get(legsecurityid1);nolegs3.get(legside1);nolegs3.get(legprice1);shiborStrn*2+m-1 = new BigDecimal(legprice1.getValue().setScale(4,BigDecimal.ROUND_HALF_UP).toString();/ quoteData.addRow(shiborStr);for(int y=0;yshiborStr.length;y+)System.out.print (shiborStry+ ); System.out.println();System.out.println();System.out.println(); catch (Exception e1) e1.printStackTrace();示例三:Shibor均值解析: public static void getTendency()DefaultMessageFactory msgFactory = new DefaultMessageFactory();DataDictionary dd = null;DBResultDataSet quoteData = new DBResultDataSet();try dd = new DataDictionary(iMIX10.xml);Message msg = (Message)MessageUtils.parse(msgFactory, dd, inImaxString); / inImaxString 为传入需要解析的数据TransactTime tt1 = new TransactTime();NoMDTypes nomdtypes1 = new NoMDTypes();/-shibor-MDType mdtype1 = new MDType();NoRelatedSym norelatedsym1 = new NoRelatedSym();SecurityID securityid1 = new SecurityID();SecurityIDSource securityidsource1 = new SecurityIDSource();MDEntryType mdentrytype1 = new MDEntryType();MDEntryPx mdentrypx1 =new MDEntryPx();NoMDEntries nomdentries1 = new NoMDEntries();nomdtypes1 = new NoMDTypes();mdtype1 = new MDType();norelatedsym1 = new NoRelatedSym();securityid1 = new SecurityID();securityidsource1 = new SecurityIDSource();mdentrytype1 = new MDEntryType();mdentrypx1 =new MDEntryPx();nomdentries1 = new NoMDEntries();msg.getGroup(1, nomdtypes1);int colSize = nomdtypes1.get(new imix.field.NoRelatedSym().getValue();String shiborStr =
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电梯 通讯协议书
- 彩棉生物质能源创新创业项目商业计划书
- 2025年肿瘤科化疗药物特点与应用综合评估考试卷答案及解析
- 小苍兰创新创业项目商业计划书
- 餐桌安全性测试题及答案解析
- 2025年遗传病学家族遗传病筛查技术考察试题答案及解析
- 实验室安全题库问答及答案解析
- 蛋壳定金协议书
- 安全套接协议书
- 2025年急诊医学院校选拔考试答案及解析
- 中国密闭空间检测无人机行业市场前景预测及投资价值评估分析报告
- 2025面向机器学习的数据标注规范
- YY/T 0339-2024呼吸道用吸引导管
- 围手术期高血压专家管理共识
- 外科患者疼痛护理与管理
- 租金延迟缴纳申请书
- 学校体育学(唐炎-刘昕版)重点、知识点
- DL-T 2563-2022 分布式能源自动发电控制与自动电压控制系统测试技术规范
- 食堂工作人员培训内容
- 泛影葡胺在消化道造影中的应用
- 2022年11月四川省凉山州中级人民法院逐级遴选4名法官笔试题库含答案解析
评论
0/150
提交评论