OrderRef BrokerID BrokerOrderSeq ExchangeID OrderSysID OnRtnTrade 与 OnRtnOrder 对应 BrokerID BrokerOrderSeq ExchangeID OrderSysID 成交价格: Price 成交时间:TradeTime 限价单 市价单 任意价格 价格为 0 触发单 ///触发条件:用户设定 ContingentCondition …… ///止损价:用户设定 StopPrice …… /// 报单价格条件类型:限价 OrderPriceType THOST_FTDC_OPT_LimitPrice /// 价格:用户设定 LimitPrice …… /// 有效期类型类型:当日有效 TimeCondition THOST_FTDC_TC_GFD 关于平仓 上期所区分昨仓和今仓。
平昨仓时,开平标志类型设置为平仓 THOST_FTDC_OF_Close 平今仓时,开平标志类型设置为平今仓 THOST_FTDC_OF_CloseToday 其他交易所不区分昨仓和今仓。
开平标志类型统一设置为平仓 THOST_FTDC_OF_Close十二、 撤单 ReqOrderAction OnRspOrderAction Thost 收到撤单指令,如果没有通过参数校验,拒绝接受撤单指令 OnErrRtnOrderAction 如果交易所认为报单错误 OnRtnOrder 报单状态 THOST_FTDC_OST_Canceled 标识 FrontID SessionID OrderRef ExchangeID OrderSysID推荐十三、 查持仓 ReqQryInvestorPosition OnRspQryInvestorPosition 合约多空今昨 持仓为 0 报单未成交 持仓全部平掉 ReqQryInvestorPositionDetail 推荐 OnRspQryInvestorPositionDetail 合成为 InvestorPositionField十四、 查资金 ReqQryTradingAccount OnRspQryTradingAccount 静态权益上日结算-出金金额入金金额 account.PreBalance - account.Withdraw account.Deposit 动态权益静态权益 平仓盈亏 持仓盈亏- 手续费 静 态 权 益 account.CloseProfit account.PositionProfit - account.Commission 可用资金动态权益-占用保证金- 冻结保证金- 冻结手续费- 交割保证 金 account.Available十五、 查手续费 ReqQryInstrumentCommissionRate OnRspQryInstrumentCommissionRate 按合约查询以品种响应十六、 查保证金 ReqQryInstrumentMarginRate OnRspQryInstrumentMarginRate 只能按合约查询十七、 银期转帐 ReqQryAccountregister查签约银行 OnRspQryAccountregister 银行卡号 ReqFromBankToFutureByFuture银转期 OnRspFromBankToFutureByFuture 错误响应 OnRtnFromBankToFutureByFuture 成功 ReqFromFutureToBankByFuture期转银 OnRspFromFutureToBankByFuture 错误响应 OnRtnFromFutureToBankByFuture 成功 要点 涉及农行/中行的指令需要输入银行密码 BankBranchID”0000”十八、 附录 官方接口及文档 http://pan.baidu.com/share/linkshareid31291uk3959766851 Tick 数据 http://pan.baidu.com/share/linkshareid8031uk3959766851 开发分享 http://pan.baidu.com/share/linkshareid45562uk3959766851 C封装源码 CTP 示例C十九、 QA Q:错误提示 A:在 windows 环境中要使用 VC编译器否则会出现上面的提示. Q:生产环境中遇到郑商所报单响应 OnRtnorder 在 OnRtnTrade 之前响应的情况. A: Q:OrderRef 报单失败 A:大商所与郑商所在报单未到达交易所时用 OrderRef 撤单会失败. Q:新版接口20120530中 CThostFtdcInputOrderField 中的 IsSwapOrder 是什 么 A: Q:中金所套利编码 A: OrderInsert 中的 CombHedgeFlag 字段设置为:THOST_FTDC_HF_Arbitrage Q:客户端认证 A:认证过程 Client API Front Tkernel ReqAuthenticate ReqAuthenticate BrokerID 1 Auth UserID Code BrokerID UserProductInfo Auth UserID Code 未认证 UserProductInfo RspAuthenticate(挑战) 2 BrokerID UserID UserProductInfo 挑战 TimeStamp TimeStamp ReqAuthenticate 3 ReqAuthenticate BrokerID 4 UserID FrontID Auth UserProductInfo 挑战 SessionID Code BrokerID AuthInfo TimeStamp UserID UserProductInfo TimeStamp AuthInfo RspAuthenticate(认证结果) RspAuthenticate(认证结果) 5 6 FrontID RspAuthenticate(认证结果) BrokerID SessionID 7 BrokerID UserID BrokerID UserID UserProductInfo 认证结果 UserID UserProductInfo UserProductInfo 认证结果二十、 预告 交易终端编程、K 线生成与入库、策略平台架构二十一、 C中调用 Matlab 函数 Matlab 打开工具 选择.Net Assembly 添加 class添加 files生成 dll VS 中 引用MATLABR2011btoolboxdotnetbuilderbinwin32v2.0MWArray.dll 引用刚才生成的 Matlab 的 dll此处为 Untitiled1 C中调用 matlab 的函数: Matlab 要安装 x86 版本 C编译 x86 版本受 CTP 接口只有 32 位限制
上一篇:
软件编程实训36
下一篇:
我国中小企业融资现状和对策研究