ctp手册
更新时间:2024-04-16 08:05:01 阅读量: 综合文库 文档下载
- CTP开发手册推荐度:
- 相关推荐
CTP交易报告 ——应用编程手册
1、历年版本
版本:v4.2 时间:2009-11-6 备注:英文版
2、索引
第一章 简介
1.1 背景
1.2 API文件介绍 第二章 结构 2.1 通讯模式 2.2 数据流
第三章 编程接口类型
3.1 对话模式的编程接口 3.2 私有模式的编程接口 3.3 广播模式的编程接口
第一章 介绍
综合交易平台(Comprehensive Transaction Platform),是专门为期货公司开发的一套期货经纪业务管理系统,由交易、风险控制和结算三大系统组成。
API,实现了客户端和综合交易平台之间的通讯。通过API,投资者可以接收来自上交所,大商所和郑商所的行情数据,发送交易指令,接收相应的反馈和交易状态等信息。
1.1 背景
2006年,上海金融期货交易所完成了新一代交易系统的开发,我们借助其成功经验,开发了CTP。
2007年4月,我们获得了来自中国期货公司交易的第一笔订单。通过近三年的不懈努力, 使用CTP的投资者遍布全球,国内使用CTP的期货公司已到达30家。
1.2 API文件
CTP上使用的API是基于C++程序库,来实现客户端和CTP服务器之间的数据传输。客户端包括,所有投资者都可以使用的CTP标准客户端(比如,Q7,popo,weisoft等第三方开发的客户端),以及个性化交易工具(由投资者个人或其合作者开发)。通过API,客户端可以发出或撤销普通单、条件单、查询委托或交易状态、查询账户实时信息和交易头寸。API程序库包括:
注:使用MS VC 6.0,MS VC.NET 2003等编程工具的,需要在编程设置中打开“multi-thread”选项。
第二章 结构
CTP的API和CTP服务器之间使用的通讯协议是期货交易数据协议(futures TradingData Exchange protocol ,FTD),它基于TCP协议。
2.1 通讯模式
在FTD协议中,通讯模式包括以下三种模式:
?对话模式,客户端给CTP发送请求,CTP将会相应返回结果。
?私有模式,CTP把特定的私人信息发送给对应的客户端,包括持仓信息、
交易确认信息等。
?广播模式,CTP将把公告等信息发送给所有的注册用户。
每种模式并不限于一种连接状态。也就是说,建立一种连接之后,客户端可以同时使用三种通讯模式 ,或者建立集中不同的连接之后,客户端也可以使用同样的通讯模式。比如,客户可以使用广播模式来接收设备状态的变动信息,同时也可接收私人信息(如下单确认等)。
下图描绘了三种通讯模式的工作流程:
2.2 数据流
CTP提供了对话、私有、广播等三种通讯模式。在对话模式中,传输的是对话数据流和查询数据流。
对话和查询数据流是双向数据流,客户端发出请求,CTP服务器返回结果。CTP服务器并不保存对话和查询数据流。当故障发生时,比如连接中断后又重新连接,对话和查询数据流将回复原值,之间传输的数据将丢失。
在私人通讯模式中,传输的是私人数据流。私人数据流是单向数据流,CTP服务器就是利用它来把相应的私人信息发给提出申请的客户端。私人信息包括,风险提示、指令状态、指令确认、交易确认等。私人数据流是可靠的。当客户端和CTP服务器失去连接后,在同一交易日的任何时间,客户端都可重新连上CTP服务器,获取一系列指定的私人信息而不用担心这些数据会丢失。
在广播通讯模式中,传输的是公共数据流。和私人数据流一样,它是单向数据流,而且可靠。区别在于,广播通讯数据会发送到所有连接的客户端上。它的主要用途就是发布公共设备的状态信息或重要的公共信息。
第三章 编程接口类型
CTP的交易API提供了两种编程接口:CThostFtdcTraderApi 与CThostFtdcTraderSpi。行情API提供的是CThostFtdcMdApi 与 CThostFtdcMdSpi等两种编程接口。这四种接口遵循FTD协议。客户端可使用CThostFtdcXXXApi来发送请求,并通过CThostFtdcXXXSpi来接收CTP返回的数据。
3.1 对话模式的编程接口
对话模式的通讯函数常常这样定义:
Request函数的第一个参数是请求的内容,不能为空。第二个参数是请求的ID,由client trade application保管,并且最好独一无二,这样,当客户端从CTP服务器接收到数据时,客户端可以用同一个ID重新建立请求并获得反馈。
当客户端收到CTP服务器发出的反馈时,callback函数CThostFtdcXXXSpi被激活。如果反馈多于一条,callback函数CThostFtdcXXXSpi会反复被激活,直到数据全部接收完毕。
Response函数的第一个参数是反馈的数据,它一般包括最初的请求数据。如
果故障发生或CTP不能找到请求的记录,那么这个参数就是空值。第二个参数是CTP用来判断反馈是否成功的一个标识。当callback函数被激活的次数超过一次,除第一次被激活外,其他callback过程发生时第二个参数的值均为空。第三个参数是反馈的ID,作用和Request函数中的一样。最后一个参数是结束标识,其值为“true”时表示进行的是该请求的最后一个反馈。
3.2 私有模式的编程接口
下面的例子为私有模式的常用接口:
在私有模式里并没有连接API与CTP服务器的行情函数。
当CTP服务器发出私有数据流时, CThostFtdcTradeSpi的callback函数将被激活。
所有callback函数的第一个参数都是CTP服务器返回的内容。
OnErrRtnCThostFtdcTradeSpi 函数的第二个参数是报错时详细的错误信息。
3.3 广播模式的编程接口
使用广播模式时,客户端可以用以下两种方式与CTP服务器进行通讯:
callback函数OnRtnInstrumentStatus 用于通知客户端设备状态的变化。 callback函数OnRtnDepthMarketData用于公布最新的交易所行情数据。
第四章 运作模式
4.1 工作线程
CTP客户端进程需要两种线程,一是应用程序线程,另一种是交易API工作线程。如果客户端想要接收行情数据,那么也需要行情API工作线程。API工作线程连接了客户端和CTP服务器。
交易API和行情API是安全线程,客户端的应用程序可以同时使用两种或多种的工作线程,而无须担心线程冲突。客户单的应用程序要能尽快的处理callback信息,这样才能避免未处理的callback信息堵塞工作线程。要避免通讯堵塞,客户端的应用程序需要使用缓冲层来储存从CTP接收的数据,当然缓冲层也可以用来保护客户端自有数据,以便使之与CTP API的数据区分开。
4.2 文件
CTP API 的动态链接数据库会产生一些文件来储存运行过程中的数据,这些文件的后缀名为“.con”。交易客户端的应用程序通过CreateFtdcTraderApi() 或CreateFtdcMdApi() 函数的第一个参数来判断这些文件的本地路径。
4.3 商业术语与接口函数对比
第五章 CTP API 特别说明
5.1 一般规则
客户端应用程序需要经过两步才能连接到CTP服务器:初始化与功能启用。 使用交易API,客户端交易应用程序需要编写: (1)创建一个“CThostFtdcTraderApi”实例。
(2)创建一个处理来自“CThostFtdcTraderSpi”接口的事件处理器,然后使用“CThostFtdcTraderApi”的“RegisterSpi”函数记录下这些事件。
(3)使用“CThostFtdcTraderApi”的“SubscribePrivateTopic”函数处理私有数据流。
(4)使用“CThostFtdcTraderApi”的“SubscribePublicTopic” 函数处理公共数据流。
(5)使用“CThostFtdcTraderApi”的“RegisterFront” 函数记录CTP服务器的前端地址。客户端多运行几次这种函数,以便与服务器建立更可靠的联系。强烈建议。
(6)使用“CThostFtdcTraderApi”的“Init“函数来连接CTP服务器。 (7)服务器连上之后,“CThostFtdcTraderSpi”接口的callback函数“OnFrontConnected”将被激活。函数运行过程中,客户端的应用程序需要使用“CThostFtdcTraderApi”的“ReqUserLogin” 函数来提交“login”请求。
(8)当CTP服务器确认登陆成功后,“CThostFtdcTraderSpi”接口的callback 函数“OnRspUserLogin” 将被激活。
(9)这样,客户端与CTP服务器的通讯就建立起来了。客户端交易应用程序可以使用其他CTP API来与CTP服务器进行通讯。
如果客户端应用程序需要使用行情API,客户端需要采取以下步骤来描述先前的数据流,不包括私有数据流和公共信息流。具体如下:
(1)所有request函数的参数都不能为空值;
(2)如果函数返回的数值为“int”,数值0意味着函数运行良好,其他数值则表示返回错误,具体的错误信息在“error.xml”文件里面。
5.2 CThostFtdcTraderSpi
CTP用CThostFtdcTraderSpi表示事件接口。客户端应用程序可以通过CThostFtdcTraderSpi 函数获得CTP服务器发出的通知。
5.2.1 OnFrontConnected
当客户端与CTP服务器连接上后,此函数被激活,进而,客户端可以使用“ReqUserLogin”来发送登陆请求。
定义:void OnFrontConnected();
5.2.2 OnFrontDisconnected
当连接终止或中断时,此函数被激活。如果该信息没有被处理,那么API会使用登陆地址列表上的一个前端地址,自动重新连接CTP服务器。
定义:void OnFrontDisconnected (int nReason); 参数:
nReason:the reason of disconnecion 0x1001 network reading failed 0x1002 network writing failed
0x2001 heartbeat receiving timeout 0x2002 heartbeat sending timeout 0x2003 received an error message
5.2.3 OnHeartBeatWarning
此函数用来表示与服务器长时间连接的接口是否可用。 定义:void OnHeartBeatWarning(int nTimeLapse);
参数: nTimeLapse:Length of time elapsed since the last received message
5.2.4 OnRspUserLogin
CTP服务器使用次callback 函数OnRspUserLogin 来通知客户端登陆函数OnRspUserLogin是否被服务器接受。
定义:void OnRspUserLogin(
CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pRspUserLogin:The pointer of the structure for user’s login response. The following is definition of the structure: struct CThostFtdcRspUserLoginField {
///trading day
TThostFtdcDateType TradingDay; ///time of login
TThostFtdcTimeType LoginTime; ///broker id
TThostFtdcBrokerIDType BrokerID; ///user id
TThostFtdcUserIDType UserID; ///trade system name
TThostFtdcSystemNameType SystemName; };
pRspInfo:Pointer of the structure for system response. The following is definition of the structure:
struct CThostFtdcRspInfoField {
///error id
TThostFtdcErrorIDType ErrorID; ///error information
TThostFtdcErrorMsgType ErrorMsg; };
5.2.5 OnRspUserLogout
CTP服务器利用此callback函数来通知客户端“RspUserLogout”是否运行成功。
定义:void OnRspUserLogout(
CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pRspUserLogout:Pointerof the structure for user’s logout response. The following is definition of the structure: struct CThostFtdcUserLogoutField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///user id
TThostFtdcUserIDType UserID; };
5.2.6 OnRspUserPasswordUpdate
CTP服务器使用此callback函数来通知客户端函数“RspUserPasswordUpdate”是否运行成功。
定义:void OnRspUserPasswordUpdate(
CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate,
CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pUserPasswordUpdate:Pointer of the structure for the response of user’s password modification. The following is definition of the structure: struct CThostFtdcUserPasswordUpdateField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///user id
TThostFtdcUserIDType UserID; ///old password
TThostFtdcPasswordTypeOldPassword; ///new password
TThostFtdcPasswordTypeNewPassword; };
5.2.7 OnRspTradingAccountPasswordUpdate
CTP服务器使用此callback函数来通知客户端是否函数“RspTradingAccountPasswordUpdate”运行成功。
定义:void OnRspTradingAccountPasswordUpdate( CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
///user id
TThostFtdcUserIDType UserID; ///order price type
TThostFtdcOrderPriceTypeType OrderPriceType; ///direction
TThostFtdcDirectionType Direction; ///combination order’s offset flag
TThostFtdcCombOffsetFlagType CombOffsetFlag; ///combination or hedge flag
TThostFtdcCombHedgeFlagType CombHedgeFlag; ///price
TThostFtdcPriceType LimitPrice; ///volume
TThostFtdcVolumeType VolumeTotalOriginal; ///valid date type
TThostFtdcTimeConditionType TimeCondition; ///GTD DATE
TThostFtdcDateType GTDDate; ///volume condition
TThostFtdcVolumeConditionType VolumeCondition; ///min volume
TThostFtdcVolumeType MinVolume; ///trigger condition
TThostFtdcContingentConditionType ContingentCondition; ///stop price
TThostFtdcPriceType StopPrice; ///force close reason
TThostFtdcForceCloseReasonType ForceCloseReason; /// auto suspend flag
TThostFtdcBoolType IsAutoSuspend; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///request ID
TThostFtdcRequestIDType RequestID; ///order local ID
TThostFtdcOrderLocalIDType OrderLocalID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///participant ID
TThostFtdcParticipantIDType ParticipantID; ///trading code
TThostFtdcClientIDTypeClientID; ///exchange instrument ID
TThostFtdcExchangeInstIDType ExchangeInstID;
///trader ID
TThostFtdcTraderIDType TraderID; ///install ID
TThostFtdcInstallIDType InstallID; ///order submit status
TThostFtdcOrderSubmitStatusType OrderSubmitStatus; ///order notify sequence
TThostFtdcSequenceNoType NotifySequence; ///trading day
TThostFtdcDateType TradingDay; ///settlement ID
TThostFtdcSettlementIDType SettlementID; ///order system ID
TThostFtdcOrderSysIDType OrderSysID; ///order source
TThostFtdcOrderSourceType OrderSource; ///order status
TThostFtdcOrderStatusType OrderStatus; ///order type
TThostFtdcOrderTypeType OrderType; ///volume traded
TThostFtdcVolumeType VolumeTraded; /// total volume
TThostFtdcVolumeType VolumeTotal; ///insert date
TThostFtdcDateType InsertDate; ///insert time
TThostFtdcTimeType InsertTime; ///active time
TThostFtdcTimeType ActiveTime; ///suspend time
TThostFtdcTimeType SuspendTime; ///update time
TThostFtdcTimeType UpdateTime; ///cancel time
TThostFtdcTimeType CancelTime; ///active trader ID
TThostFtdcTraderIDType ActiveTraderID; ///clear participant ID
TThostFtdcParticipantIDType ClearingPartID; ///sequence No.
TThostFtdcSequenceNoType SequenceNo; ///front ID
TThostFtdcFrontIDType FrontID;
///session ID
TThostFtdcSessionIDType SessionID; ///user product information
TThostFtdcProductInfoType UserProductInfo; ///status message
TThostFtdcErrorMsgType StatusMsg; };
5.2.14 OnRspQryTrade
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryTrade”的请求。
定义:void OnRspQryTrade(
CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pTrade:Pointer of the structure for the response of ReqQryTrade. The following is definition of the structure, struct CThostFtdcTradeField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///order reference
TThostFtdcOrderRefType OrderRef; ///user id
TThostFtdcUserIDType UserID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///trade ID
TThostFtdcTradeIDTypeTradeID; ///direction
TThostFtdcDirectionType Direction; ///order system ID
TThostFtdcOrderSysIDType OrderSysID; ///participant ID
TThostFtdcParticipantIDType ParticipantID; ///trading code
TThostFtdcClientIDTypeClientID; ///trading role
TThostFtdcTradingRoleType TradingRole; ///exchange instrument ID
TThostFtdcExchangeInstIDType ExchangeInstID; ///offset flag
TThostFtdcOffsetFlagType OffsetFlag; ///hedge flag
TThostFtdcHedgeFlagType HedgeFlag; ///price
TThostFtdcPriceType Price; ///volume
TThostFtdcVolumeType Volume; ///trade date
TThostFtdcDateType TradeDate; ///trade time
TThostFtdcTimeType TradeTime; ///trade type
TThostFtdcTradeTypeType TradeType; ///price source
TThostFtdcPriceSourceType PriceSource; ///trader ID
TThostFtdcTraderIDType TraderID; ///order local ID
TThostFtdcOrderLocalIDType OrderLocalID; ///clear participant ID
TThostFtdcParticipantIDType ClearingPartID; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///sequence No.
TThostFtdcSequenceNoType SequenceNo; ///trading day
TThostFtdcDateType TradingDay; ///settlement ID
TThostFtdcSettlementIDType SettlementID; };
5.2.15 OnRspQryInvestor
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryInvestor”的请求。
定义:void OnRspQry Investor (
CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pInvestor:Pointer of the structure for the response of ReqQryInvestor. The following is definition of the structure, struct CThostFtdcInvestorField {
///investor ID
TThostFtdcInvestorIDType InvestorID; ///broker id
TThostFtdcBrokerIDType BrokerID; ///investor group ID
TThostFtdcInvestorIDType InvestorGroupID; ///investor name
TThostFtdcPartyNameType InvestorName; ///Identified Card Type
TThostFtdcIdCardTypeType IdentifiedCardType; ///Identified Card No.
TThostFtdcIdentifiedCardNoType IdentifiedCardNo; ///is active
TThostFtdcBoolType IsActive; };
5.2.16 OnRspQryInvestorPosition
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryInvestorPosition”的请求。
定义:void OnRspQry InvestorPosition(
CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pInvestorPosition : Pointer of the structure for the response of ReqQryInvestorPosition. The following is definition of the structure, struct CThostFtdcInvestorPositionField {
///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///position direction
TThostFtdcPosiDirectionType PosiDirection; ///hedge flag
TThostFtdcHedgeFlagType HedgeFlag; ///position date
TThostFtdcPositionDateType PositionDate; ///position of last trading day
TThostFtdcVolumeType YdPosition; OpenVolume; ///close volume
TThostFtdcVolumeType CloseVolume; ///open amount
TThostFtdcMoneyType OpenAmount; ///close amount
TThostFtdcMoneyType CloseAmount; ///position cost
TThostFtdcMoneyType PositionCost; ///previous margin
TThostFtdcMoneyType PreMargin; ///used margin
TThostFtdcMoneyType UseMargin; ///frozen margin
TThostFtdcMoneyType FrozenMargin; ///frozen cash
TThostFtdcMoneyType FrozenCash; ///frozen commission
TThostFtdcMoneyType FrozenCommission; ///cash in
TThostFtdcMoneyType CashIn; ///commission
TThostFtdcMoneyType Commission; ///close profit
TThostFtdcMoneyType CloseProfit; ///position profit
TThostFtdcMoneyType PositionProfit; ///previous settlement price
TThostFtdcPriceType PreSettlementPrice; ///settlement price
TThostFtdcPriceType SettlementPrice; ///trading day
TThostFtdcDateType TradingDay; ///settlement ID
TThostFtdcSettlementIDType SettlementID; };
5.2.17 OnRspQryTradingAccount
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryTradingAccount”的请求。
定义:void OnRspQryTradingAccount(
CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pTradingAccount : Pointer of the structure for the response of ReqQryTradingAccount. The following is definition of the structure, struct CThostFtdcTradingAccountField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///account id
TThostFtdcAccountIDType AccountID; ///previous mortgage
TThostFtdcMoneyType PreMortgage; ///previous credit
TThostFtdcMoneyType PreCredit; ///previous deposit
TThostFtdcMoneyType PreDeposit; ///previous balance
TThostFtdcMoneyType PreBalance; ///premargin
TThostFtdcMoneyType PreMargin; ///interest base
TThostFtdcMoneyType InterestBase; ///interest
TThostFtdcMoneyType Interest; ///deposit
TThostFtdcMoneyType Deposit; ///withdraw
TThostFtdcMoneyType Withdraw; ///frozen margin
TThostFtdcMoneyType FrozenMargin; ///frozen cash
TThostFtdcMoneyType FrozenCash; ///frozen commission
TThostFtdcMoneyType FrozenCommission; ///current margin
TThostFtdcMoneyType CurrMargin; ///cash in
TThostFtdcMoneyType CashIn; ///commission
TThostFtdcMoneyType Commission; ///close profit
TThostFtdcMoneyType CloseProfit; ///position profit
TThostFtdcMoneyType PositionProfit; ///balance
TThostFtdcMoneyType Balance; ///available
TThostFtdcMoneyType Available; ///withdraw quota
TThostFtdcMoneyType WithdrawQuota; ///reserve
TThostFtdcMoneyType Reserve; ///trading day
TThostFtdcDateType TradingDay; ///settlement ID
TThostFtdcSettlementIDType SettlementID; ///credit
TThostFtdcMoneyType Credit; ///Mortgage
TThostFtdcMoneyType Mortgage; ///excahnge margin
TThostFtdcMoneyType ExchangeMargin; };
5.2.18 OnRspQryTradingCode
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryTradingCode”的请求。
定义:void OnRspQryTradingCode(
CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
参数:
pTradingCode:Pointer of the structure for the response of ReqQryTradingCode. The following is definition of the structure, struct CThostFtdcTradingCodeField {
///investor ID
TThostFtdcInvestorIDType InvestorID; ///broker id
TThostFtdcBrokerIDType BrokerID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///trading code
TThostFtdcClientIDTypeClientID;
///is active
TThostFtdcBoolType IsActive; };
5.2.19 OnRspQryExchange
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryExchange”的请求。
定义:void OnRspQryExchange(
CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
参数:
pExchange:Pointer of the structure for the response of ReqQryExchange. The following is definition of the structure, struct CThostFtdcExchangeField {
///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///exchange name
TThostFtdcExchangeNameType ExchangeName; ///exchange property
TThostFtdcExchangePropertyTypeExchangeProperty; };
5.2.20 OnRspQryInstrument
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryInstrument”的请求。
定义:void OnRspQryInstrument(
CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
参数:
pInstrument:Pointer of the structure for the response of ReqQryInstrument. The following is definition of the structure, struct CThostFtdcInstrumentField {
///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///instrument name
TThostFtdcInstrumentNameType InstrumentName; ///exchange instrument ID
TThostFtdcExchangeInstIDType ExchangeInstID; ///product ID DeliveryMonth;
///max volume for market order
TThostFtdcVolumeType MaxMarketOrderVolume; ///min volume for market order
TThostFtdcVolumeType MinMarketOrderVolume; ///max volume for limit order
TThostFtdcVolumeType MaxLimitOrderVolume; ///min volume for limit order
TThostFtdcVolumeType MinLimitOrderVolume; ///volume multiple of instrument
TThostFtdcVolumeMultipleType VolumeMultiple; ///price tick
TThostFtdcPriceType PriceTick; ///create date
TThostFtdcDateType CreateDate; ///open date
TThostFtdcDateType OpenDate; ///expire date
TThostFtdcDateType ExpireDate; ///start delivery date
TThostFtdcDateType StartDelivDate; ///end delivery date
TThostFtdcDateType EndDelivDate; ///instrument life phase
TThostFtdcInstLifePhaseTypeInstLifePhase; ///is trading
TThostFtdcBoolType IsTrading; ///position type
TThostFtdcPositionTypeType PositionType; ///position date type
TThostFtdcPositionDateTypeType PositionDateType; ///long margin ratio
TThostFtdcRatioType LongMarginRatio; ///short margin ratio
TThostFtdcRatioType ShortMarginRatio; };
5.2.21 OnRspQryDepthMarketData
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryDepthMarketData”的请求。
定义:void OnRspQryDepthMarketData(
CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
参数:
pDepthMarketData : Pointer of the structure for the response of ReqQryDepthMarketData. The following is definition of the structure, struct CThostFtdcDepthMarketDataField {
///trading day
TThostFtdcDateType TradingDay; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///exchange instrument ID
TThostFtdcExchangeInstIDType ExchangeInstID; ///last price
TThostFtdcPriceType LastPrice; ///previous settlement price
TThostFtdcPriceType PreSettlementPrice; ///previous close price
TThostFtdcPriceType PreClosePrice; ///previous open volume
TThostFtdcLargeVolumeType PreOpenInterest; ///open price
TThostFtdcPriceType OpenPrice; ///highest price
TThostFtdcPriceType HighestPrice; ///lowest price
TThostFtdcPriceType LowestPrice; ///trade volume
TThostFtdcVolumeType Volume; ///turnover
TThostFtdcMoneyType Turnover; ///open interest
TThostFtdcLargeVolumeType OpenInterest; ///close Price
TThostFtdcPriceType ClosePrice; ///settlement price
TThostFtdcPriceType SettlementPrice; ///upper limit price
TThostFtdcPriceType UpperLimitPrice;
///lower limit price
TThostFtdcPriceType LowerLimitPrice; ///pre-delta
TThostFtdcRatioType PreDelta; ///current delta
TThostFtdcRatioType CurrDelta; ///update time
TThostFtdcTimeType UpdateTime; ///Update Millisecond
TThostFtdcMillisecType UpdateMillisec; ///the first bid price
TThostFtdcPriceType BidPrice1; ///the first bid volume
TThostFtdcVolumeType BidVolume1; ///the first ask price
TThostFtdcPriceType AskPrice1; ///the first ask volume
TThostFtdcVolumeType AskVolume1; ///the second bid price
TThostFtdcPriceType BidPrice2; ///the second bid volume
TThostFtdcVolumeType BidVolume2; ///the second ask price
TThostFtdcPriceType AskPrice2; ///the second ask volume
TThostFtdcVolumeType AskVolume2; ///the third bid price
TThostFtdcPriceType BidPrice3; TThostFtdcPriceType AskPrice3; ///the third ask volume
TThostFtdcVolumeType AskVolume3; ///the forth bid price
TThostFtdcPriceType BidPrice4; ///the forth bid volume
TThostFtdcVolumeType BidVolume4; ///the forth ask price
TThostFtdcPriceType AskPrice4; ///the forth ask volume
TThostFtdcVolumeType AskVolume4; ///the fifth bid price
TThostFtdcPriceType BidPrice5; ///the fifth bid volume
TThostFtdcVolumeType BidVolume5; ///the fifth ask price
TThostFtdcPriceType AskPrice5; ///the fifth ask volume
TThostFtdcVolumeType AskVolume5; };
5.2.22 OnRspQrySettlementInfo
CTP服务器利用此callback函数反馈客户端应用程序“ReqQrySettlementInfo”的请求。
定义:void OnRspQrySettlementInfo(
CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
参数:
pSettlementInfo : Pointer of the structure for the response of ReqQrySettlementInfo. The following is definition of the structure, struct CThostFtdcSettlementInfoField {
///trading day
TThostFtdcDateType TradingDay; ///settlement ID
TThostFtdcSettlementIDType SettlementID; ///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///sequence No.
TThostFtdcSequenceNoType SequenceNo; ///content
TThostFtdcContentType Content; };
5.2.23 OnRspQryInvestorPositionDetail
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryInvestorPositionDetail”的请求。
定义:void OnRspQryInvestorPositionDetail(
CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
参数:
pInvestorPositionDetail : Pointer of the structure for the response of ReqQryInvestorPositionDetail. The following is definition of the structure, struct CThostFtdcInvestorPositionDetailField
{
///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///hedge flag
TThostFtdcHedgeFlagType HedgeFlag; ///direction
TThostFtdcDirectionType Direction; ///open date
TThostFtdcDateType OpenDate; ///trade ID
TThostFtdcTradeIDTypeTradeID; ///volume
TThostFtdcVolumeType Volume; ///open price
TThostFtdcPriceType OpenPrice; ///trading day
TThostFtdcDateType TradingDay; ///settlement ID
TThostFtdcSettlementIDType SettlementID; ///trade type
TThostFtdcTradeTypeType TradeType; ///combination instrument ID
TThostFtdcInstrumentIDTypeCombInstrumentID; };
5.2.24 OnRspQryNotice
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryNotice”的请求。
定义:void OnRspQryNotice(
CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pNotice:Pointer of the structure for the response of ReqQryNotice. The following is definition of the structure, struct CThostFtdcNoticeField {
///broker id
TThostFtdcBrokerIDType BrokerID;
///content
TThostFtdcContentType Content; ///Sequence Label of broker notice
TThostFtdcSequenceLabelType SequenceLabel; };
5.2.25 OnRspQryInstrument
CTP服务器利用此callback函数反馈客户端应用程序“ReqQryInstrument”的请求。
定义:void OnRspQryInstrument(
CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pRspInstrument:Pointer of the structure for the response of ReqQryInstrument. The following is definition of the structure, struct CThostFtdcInstrumentField {
///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///instrument name
TThostFtdcInstrumentNameType InstrumentName; ///exchange instrument ID
TThostFtdcExchangeInstIDType ExchangeInstID; ///product ID
TThostFtdcInstrumentIDTypeProductID; ///product class
TThostFtdcProductClassTypeProductClass; ///delivery year
TThostFtdcYearType DeliveryYear; ///delivery month
TThostFtdcMonthType DeliveryMonth; ///max volume for market order
TThostFtdcVolumeType MaxMarketOrderVolume; ///min volume for market order
TThostFtdcVolumeType MinMarketOrderVolume; ///max volume for limit order
TThostFtdcVolumeType MaxLimitOrderVolume; ///min volume for limit order
TThostFtdcVolumeType MinLimitOrderVolume;
///volume multiple of instrument
TThostFtdcVolumeMultipleType VolumeMultiple; ///price tick
TThostFtdcPriceType PriceTick; ///create date
TThostFtdcDateType CreateDate; ///open date
TThostFtdcDateType OpenDate; ///expire date
TThostFtdcDateType ExpireDate; ///start delivery date
TThostFtdcDateType StartDelivDate; ///end delivery date
TThostFtdcDateType EndDelivDate; ///instrument life phase
TThostFtdcInstLifePhaseTypeInstLifePhase; ///is trading
TThostFtdcBoolType IsTrading; ///position type
TThostFtdcPositionTypeType PositionType; ///position date type
TThostFtdcPositionDateTypeType PositionDateType; };
5.2.26 OnRtnTrade
CTP服务器利用此callback函数通知客户端应用程序,什么时候交易已经结束。
定义:void OnRtnTrade(CThostFtdcTradeField *pTrade); 参数:
pTrade:Pointer of the structure for the trade information. The following is definition of the structure, struct CThostFtdcTradeField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///order reference
TThostFtdcOrderRefType OrderRef; ///user id
TThostFtdcUserIDType UserID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///trade ID
TThostFtdcTradeIDTypeTradeID; ///direction
TThostFtdcDirectionType Direction; ///order system ID
TThostFtdcOrderSysIDType OrderSysID; ///participant ID
TThostFtdcParticipantIDType ParticipantID; ///trading code
TThostFtdcClientIDTypeClientID; ///trading role
TThostFtdcTradingRoleType TradingRole; ///exchange instrument ID
TThostFtdcExchangeInstIDType ExchangeInstID; ///offset flag
TThostFtdcOffsetFlagType OffsetFlag; ///hedge flag
TThostFtdcHedgeFlagType HedgeFlag; ///price
TThostFtdcPriceType Price; ///volume
TThostFtdcVolumeType Volume; ///trade date
TThostFtdcDateType TradeDate; ///trade time
TThostFtdcTimeType TradeTime; ///trade type
TThostFtdcTradeTypeType TradeType; ///price source
TThostFtdcPriceSourceType PriceSource; ///trader ID
TThostFtdcTraderIDType TraderID; ///order local ID
TThostFtdcOrderLocalIDType OrderLocalID; ///clear participant ID
TThostFtdcParticipantIDType ClearingPartID; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///sequence No.
TThostFtdcSequenceNoType SequenceNo; ///trading day
TThostFtdcDateType TradingDay; ///settlement ID
TThostFtdcSettlementIDType SettlementID; };
5.2.27 OnRtnOrder
CTP服务器利用此callback函数通知客户端应用程序,订单状态的变化。 定义:void OnRtnOrder(CThostFtdcOrderField *pOrder); 参数:
pOrder:Pointer of the structure for the order information. The following is definition of the structure, struct CThostFtdcOrderField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///order reference
TThostFtdcOrderRefType OrderRef; ///user id
TThostFtdcUserIDType UserID; ///order price type
TThostFtdcOrderPriceTypeType OrderPriceType; ///direction
TThostFtdcDirectionType Direction; ///combination order’s offset flag
TThostFtdcCombOffsetFlagType CombOffsetFlag; ///combination or hedge flag
TThostFtdcCombHedgeFlagType CombHedgeFlag; MinVolume;
///trigger condition
TThostFtdcContingentConditionType ContingentCondition; ///stop price
TThostFtdcPriceType StopPrice; ///force close reason
TThostFtdcForceCloseReasonType ForceCloseReason; /// auto suspend flag
TThostFtdcBoolType IsAutoSuspend; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///request ID
TThostFtdcRequestIDType RequestID; ///order local ID
TThostFtdcOrderLocalIDType OrderLocalID;
///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///participant ID
TThostFtdcParticipantIDType ParticipantID; ///trading code
TThostFtdcClientIDTypeClientID; ///exchange instrument ID
TThostFtdcExchangeInstIDType ExchangeInstID; ///trader ID
TThostFtdcTraderIDType TraderID; ///install ID
TThostFtdcInstallIDType InstallID; ///order submit status
TThostFtdcOrderSubmitStatusType OrderSubmitStatus; ///notify sequence
TThostFtdcSequenceNoType NotifySequence; ///trading day
TThostFtdcDateType TradingDay; VolumeTraded; ///volume total
TThostFtdcVolumeType VolumeTotal; ///insert date
TThostFtdcDateType InsertDate; ///insert time
TThostFtdcTimeType InsertTime; ///active time
TThostFtdcTimeType ActiveTime; ///suspend time
TThostFtdcTimeType SuspendTime; ///update time
TThostFtdcTimeType UpdateTime; ///cancel time
TThostFtdcTimeType CancelTime; ///active trader ID
TThostFtdcTraderIDType ActiveTraderID; ///clear participant ID
TThostFtdcParticipantIDType ClearingPartID; ///sequence No.
TThostFtdcSequenceNoType SequenceNo; ///front ID
TThostFtdcFrontIDType FrontID; ///session ID
TThostFtdcSessionIDType SessionID; ///user product information
TThostFtdcProductInfoType UserProductInfo; ///status message
TThostFtdcErrorMsgType StatusMsg; };
5.2.28 OnErrRtnOrderInsert
此callback函数用于通知客户端应用程序,CTP服务器或交易所的验证出错。 定义:void OnErrRtnOrderInsert(
CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo);
参数:
pInputOrder:Pointer of the structure for the order insertion information
including the response from server. The following is definition of the structure, struct CThostFtdcInputOrderField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///order reference
TThostFtdcOrderRefType OrderRef; ///user id
TThostFtdcUserIDType UserID; ///order price type
TThostFtdcOrderPriceTypeType OrderPriceType; ///direction
TThostFtdcDirectionType Direction; ///combination order’s offset flag
TThostFtdcCombOffsetFlagType CombOffsetFlag; ///combination or hedge flag
TThostFtdcCombHedgeFlagType CombHedgeFlag; ///price
TThostFtdcPriceType LimitPrice; ///volume
TThostFtdcVolumeType VolumeTotalOriginal; ///valid date
TThostFtdcTimeConditionType TimeCondition; ///GTD DATE
TThostFtdcDateType GTDDate; ///volume condition
TThostFtdcVolumeConditionType VolumeCondition; ///min volume
TThostFtdcVolumeType MinVolume; ///trigger condition
TThostFtdcContingentConditionType ContingentCondition; ///stop price
TThostFtdcPriceType StopPrice; ///force close reason
TThostFtdcForceCloseReasonType ForceCloseReason; /// auto suspend flag
TThostFtdcBoolType IsAutoSuspend; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///request ID
TThostFtdcRequestIDType RequestID; };
5.2.29 OnErrRtnOrderAction
此callback函数用于通知客户端应用程序,CTP服务器或交易所的验证出错。 定义:void OnErrRtnOrderAction (
CThostFtdcOrderActionField *pOrderAction, CThostFtdcRspInfoField *pRspInfo);
参数:
pOrderAction:Pointer of the structure for the order action information
including the response from server. The following is definition of the structure, struct CThostFtdcOrderActionField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///order action reference
TThostFtdcOrderActionRefType OrderActionRef; ///order reference
TThostFtdcOrderRefType OrderRef; ///request ID
TThostFtdcRequestIDType RequestID; ///front ID
TThostFtdcFrontIDType FrontID; ///session ID
TThostFtdcSessionIDType SessionID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///order system ID
TThostFtdcOrderSysIDType OrderSysID; ///action flag
TThostFtdcActionFlagType ActionFlag; ///price
TThostFtdcPriceType LimitPrice; ///volume change
TThostFtdcVolumeType VolumeChange; ///action date
TThostFtdcDateType ActionDate; ///action time
TThostFtdcTimeType ActionTime; ///trader ID
TThostFtdcTraderIDType TraderID; ///install ID
TThostFtdcInstallIDType InstallID; ///order local ID
TThostFtdcOrderLocalIDType OrderLocalID; ///action local ID
TThostFtdcOrderLocalIDType ActionLocalID; ///participant ID
TThostFtdcParticipantIDType ParticipantID; ///trading code
TThostFtdcClientIDTypeClientID; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///order action status
TThostFtdcOrderActionStatusTypeOrderActionStatus; ///user id
TThostFtdcUserIDType UserID; ///status message
TThostFtdcErrorMsgType StatusMsg; };
5.2.30 OnRspQrySettlementInfoConfirm
CTP服务器利用此callback函数反馈客户端应用程序“ReqQrySettlementInfoConfirm”运行成功。
定义:void OnRspQrySettlementInfoConfirm(
CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pSettlementInfoConfirm : Pointer of the structure for the response of ReqQrySettlementInfoConfirm. The following is definition of the structure, struct CThostFtdcSettlementInfoConfirmField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///confirm date
TThostFtdcDateType ConfirmDate; ///confirm time
TThostFtdcTimeType ConfirmTime; };;
5.2.31 RspQryParkedOrder
CTP服务器利用此callback函数反馈预报单(parked order)的查询。 定义:
void OnRspQryParkedOrder(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pParkedOrder:Pointer of the structure for the response of ReqQryParkedOrder. The following is
definition of the structure,
struct CThostFtdcParkedOrderField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///order reference
TThostFtdcOrderRefType OrderRef; ///user id
TThostFtdcUserIDType UserID; ///order price type
TThostFtdcOrderPriceTypeType OrderPriceType; ///direction
TThostFtdcDirectionType Direction; ///combination order’s offset flag
TThostFtdcCombOffsetFlagType CombOffsetFlag; ///combination or hedge flag
TThostFtdcCombHedgeFlagType CombHedgeFlag; ///price
TThostFtdcPriceType LimitPrice;
///volume
TThostFtdcVolumeType VolumeTotalOriginal; ///valid date
TThostFtdcTimeConditionType TimeCondition; ///GTD DATE
TThostFtdcDateType GTDDate; ///volume condition
TThostFtdcVolumeConditionType VolumeCondition; ///min volume
TThostFtdcVolumeType MinVolume; ///trigger condition
TThostFtdcContingentConditionType ContingentCondition; ///stop price
TThostFtdcPriceType StopPrice; ///force close reason
TThostFtdcForceCloseReasonType ForceCloseReason; /// auto suspend flag
TThostFtdcBoolType IsAutoSuspend; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///request ID
TThostFtdcRequestIDType RequestID; ///user force close flag
TThostFtdcBoolType UserForceClose; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///parked order system ID
TThostFtdcParkedOrderIDType ParkedOrderID; ///user type
TThostFtdcUserTypeType UserType; ///parked order status
TThostFtdcParkedOrderStatusType Status; };
5.2.32 RspQryParkedOrderAction
CTP服务器利用此callback函数反馈““RspQryParkedOrderAction”的查询。 定义:void OnRspQryParkedOrderAction(
CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pParkedOrderAction : Pointer of the structure for the response of ReqQryParkedOrderAction. The following is definition of the structure, struct CThostFtdcParkedOrderActionField
{
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///order action reference
TThostFtdcOrderActionRefType OrderActionRef; ///order reference
TThostFtdcOrderRefType OrderRef; ///request ID
TThostFtdcRequestIDType RequestID; ///front ID
TThostFtdcFrontIDType FrontID; ///session ID
TThostFtdcSessionIDType SessionID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///order system ID
TThostFtdcOrderSysIDType OrderSysID; ///action flag
TThostFtdcActionFlagType ActionFlag; ///price
TThostFtdcPriceType LimitPrice; ///volume change
TThostFtdcVolumeType VolumeChange; ///user id
TThostFtdcUserIDType UserID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///parked order action ID
TThostFtdcParkedOrderActionIDType ParkedOrderActionID; ///user type
TThostFtdcUserTypeType UserType; ///parked order action status
TThostFtdcParkedOrderStatusType Status; };
5.2.33 RspQryInvestorPositionCombineDetail
CTP服务器利用此callback函数反馈,投资者连接设备的位置查询。 定义:void OnRspQryInvestorPositionCombineDetail(
CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pInvestorPositionCombineDetail:Pointer of the structure for the response of ReqQryInvestorPositionCombineDetail. The following is definition of the structure,
struct CThostFtdcInvestorPositionCombineDetailField {
///trading day
TThostFtdcDateType TradingDay; ///open date
TThostFtdcDateType OpenDate; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///settlement ID
TThostFtdcSettlementIDType SettlementID; ///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///combination trade ID
TThostFtdcTradeIDTypeComTradeID; ///trade ID
TThostFtdcTradeIDTypeTradeID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///hedge flag
TThostFtdcHedgeFlagType HedgeFlag; ///direction
TThostFtdcDirectionType Direction; ///total amount
TThostFtdcVolumeType TotalAmt; ///margin
TThostFtdcMoneyType Margin; ///excahnge margin
TThostFtdcMoneyType ExchMargin; ///margin rate by money
TThostFtdcRatioType MarginRateByMoney; ///margin rate by volume
TThostFtdcRatioType MarginRateByVolume; ///combination instrument ID
TThostFtdcInstrumentIDTypeCombInstrumentID; };
5.2.34 RspParkedOrderInsert
CTP服务器利用此callback函数反馈客户端应用程序“ReqParkedOrderInsert”
运行成功。
定义:
void OnRspParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast); 参数:
pParkedOrder : Pointer of the structure for the response of
ReqParkedOrderInsert. The following is definition of the structure, struct CThostFtdcParkedOrderField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///order reference
TThostFtdcOrderRefType OrderRef; ///user id
TThostFtdcUserIDType UserID; ///order price type
TThostFtdcOrderPriceTypeType OrderPriceType; ///direction
TThostFtdcDirectionType Direction; ///combinationorder’s offset flag
TThostFtdcCombOffsetFlagType CombOffsetFlag; ///combination or hedge flag
TThostFtdcCombHedgeFlagType CombHedgeFlag; ///price
TThostFtdcPriceType LimitPrice; ///volume
TThostFtdcVolumeType VolumeTotalOriginal;
/// Valid date TThostFtdcTimeConditionType TimeCondition; ///GTD DATE
TThostFtdcDateType GTDDate; ///volume condition
TThostFtdcVolumeConditionType VolumeCondition; ///min volume
TThostFtdcVolumeType MinVolume; ///trigger condition
TThostFtdcContingentConditionType ContingentCondition; ///stop price
TThostFtdcPriceType StopPrice; ///force close reason
TThostFtdcForceCloseReasonType ForceCloseReason; /// auto suspend flag
TThostFtdcBoolType IsAutoSuspend; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///request ID
TThostFtdcRequestIDType RequestID; ///user force close flag
TThostFtdcBoolType UserForceClose; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///parked order system ID
TThostFtdcParkedOrderIDType ParkedOrderID; ///user type
TThostFtdcUserTypeType UserType; ///parked order status
TThostFtdcParkedOrderStatusType Status; };
5.2.35 RspParkedOrderAction
CTP服务器利用此callback函数反馈客户端应用程序“ReqParkedOrderAction”运行成功。
定义:void OnRspParkedOrderAction(
CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pParkedOrderAction : Pointer of the structure for the response of ReqParkedOrderAction. The following is definition of the structure, struct CThostFtdcParkedOrderActionField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///order action reference
TThostFtdcOrderActionRefType OrderActionRef; ///order reference
TThostFtdcOrderRefType OrderRef; ///request ID
TThostFtdcRequestIDType RequestID; ///front ID
TThostFtdcFrontIDType FrontID; ///session ID
TThostFtdcSessionIDType SessionID; ///exchange ID
TThostFtdcExchangeIDType ExchangeID; ///order system ID
TThostFtdcOrderSysIDType OrderSysID; ///action flag
TThostFtdcActionFlagType ActionFlag; ///price
TThostFtdcPriceType LimitPrice; ///volume change
TThostFtdcVolumeType VolumeChange; ///user id
TThostFtdcUserIDType UserID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///parked order action ID
TThostFtdcParkedOrderActionIDType ParkedOrderActionID; ///user type
TThostFtdcUserTypeType UserType; ///parked order action status
TThostFtdcParkedOrderStatusType Status; };
5.2.36 RspRemoveParkedOrder
CTP服务器利用此callback函数反馈客户端应用程序,是否“ReqRemoveParkedOrder”运行成功。
定义:void OnRspRemoveParkedOrder(
CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder
CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
参数:
pRemoveParkedOrder : Pointer of the structure for the response of ReqRemoveParkedOrder. The following is definition of the structure, struct CThostFtdcRemoveParkedOrderField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///parked order system ID
TThostFtdcParkedOrderIDType ParkedOrderID; };
5.2.37 RspRemoveParkedOrderAction
CTP服务器利用此callback函数反馈客户端应用程序,
“ReqRemoveParkedOrderAction”是否运行成功。
定义:void OnRspRemoveParkedOrderAction(
CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast); 参数:
pRemoveParkedOrderAction:Pointer of the structure for the response of ReqRemoveParkedOrderAction. The following is definition of the structure, struct CThostFtdcRemoveParkedOrderActionField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///parked order action trade ID
TThostFtdcParkedOrderActionIDType ParkedOrderActionID; };
5.3 CThostFtdcTraderApi
CThostFtdcTraderApi 接口的函数包括,指令插入、指令行动、指令和交易查询、以及其他信息查询,比如客户信息、账户信息、持仓头寸、设备信息、设备状态、交易所公告等等。
5.3.1 CreateFtdcTraderApi
CTP客户端应用程序使用此函数来创造一个“CThostFtdcTradeApi”事件。注意:创造事件时不要使用“new”。
定义:
static CThostFtdcTradeApi *CreateFtdcTradeApi(const char *pszFlowPath = \
参数:
pszFlowPath:Pointer of a constant string, point to one special file directory which used to store notified information sent from CTP server, if not specified, the current file directory is the default one.
return value:
A pointer of an instance of CThostFtdcTradeAp.
5.3.2 Release
CTP客户端应用程序使用此函数来删除“CThostFtdcTradeApi”事件。注意:不要使用“delete”来删除事件。
定义:void Release();
5.3.3 init
CTP客户端应用程序使用此函数来创造与CTP服务器的连接,之后可能才
能登陆。
定义:void Init();
5.3.4 join
CTP客户端服务器使用此函数来等待“CThostFtdcTradeApi”事件的结束。 定义:void Join();
5.3.5 GetTradingDay
CTP客户端服务器使用此函数来获得当前交易日信息,只用当客户端与服务器成功建立连接时该数值才有效。
定义:const char *GetTradingDay();
返回值:a pointer of a constant string identifies the current trading date.
5.3.6 RegisterSpi
CTP客户端使用此函数来记录CThostFtdcTraderSpi接口的事件。 定义:void RegisterSpi(CThostFtdcTraderSpi *pSpi) ;
参数:pSpi:the pointer of the CThostFtdcTraderSpi instance.
5.3.7 RegisterFront
CTP客户端使用此函数来读取CTP服务器的前端地址。该函数可以被调用多次以记录更多前端地址,然后API会从其中选择地址,直到能够成功建立连接为止。
定义:void RegisterFront(char *pszFrontAddress);
参数:pszFrontAddress:Pointer of the structure for the front address of the CTP server. The address format just like : “protocol://ipaddress:port”, for example, “tcp://127.0.0.1:17001”, “tcp” means the communication protocol,“127.0.0.1”
identifies the front address.”17001” identifies the server port.
5.3.8 SubscribePrivateTopic
CTP客户端使用此函数来读取CTP服务器的私有主题。该函数必须在 “init”函数被调用之后使用,否则客户端应用程序将无法接收私有信息流。
定义:void SubscribePrivateTopic(TE_RESUME_TYPE nResumeType); 参数:
nResumeType: the re-transmit mode of the private stream.
TERT_RESTART: re-transmit from the begin of the current trading day. TERT_RESUME: resume transmitting from the last received data.
TERT_QUICK: transmitting the new private stream data from the login time.
5.3.9 SubscribePublicTopic
CTP客户端使用此函数来读取CTP服务器的公共主题。该函数必须在 “init”函数被调用之后使用,否则客户端应用程序将无法接收公共信息流。
定义:void SubscribePublicTopic(TE_RESUME_TYPE nResumeType); 参数:
nResumeType: the re-transmit mode of the public stream.
TERT_RESTART: re-transmit from the begin of the current trading day. TERT_RESUME: resume transmitting from the last received data.
TERT_QUICK: transmitting the new public stream data from the login time.
5.3.10 ReqUserLogin
CTP客户端应用程序利用此函数向CTP服务器发送,登入请求。 定义:int ReqUserLogin(
CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID);
参数:
pReqUserLoginField:The pointer of the structure for user’s login request. The following is definition of the structure, struct CThostFtdcReqUserLoginField {
///trading day
TThostFtdcDateType TradingDay; ///broker id
TThostFtdcBrokerIDType BrokerID; ///user id
TThostFtdcUserIDType UserID; ///password
TThostFtdcPasswordType Password; ///user product information
TThostFtdcProductInfoType UserProductInfo; ///interface product information
TThostFtdcProductInfoType InterfaceProductInfo; ///protocol information
TThostFtdcProtocolInfoType ProtocolInfo; };
返回值: 0,success.
-1,net connection failure.
-2,over the max quantity of unhandled requests. -3,over the max requests per second.
5.3.11 ReqUserLogout
CTP客户端应用程序利用此函数向CTP服务器发送,登出请求。 定义: int ReqUserLogout(
CThostFtdcUserLogoutField *pUserLogout, int nRequestID);
参数:
pReqUserLogout:Pointer of the structure for user’s logout request. The following is definition of the structure,
struct CThostFtdcUserLogoutField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///user id
TThostFtdcUserIDType UserID; };
返回值: 0,success.
-1,net connection failure.
-2,over the max quantity of unhandled requests. -3,over the max requests per second.
5.3.12 ReqUserPasswordUpdate
CTP客户端应用程序利用此函数向CTP服务器发送,用户登陆密码更新请求。
定义:int ReqUserPasswordUpdate(
CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, int nRequestID);
参数:
pUserPasswordUpdate:Pointer of the structure for user password updation request. The following is definition of the structure, struct CThostFtdcUserPasswordUpdateField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///user id
TThostFtdcUserIDType UserID; ///old password
TThostFtdcPasswordType OldPassword; ///new password
TThostFtdcPasswordType NewPassword; };
5.3.13 ReqTradingAccountPasswordUpdate
CTP客户端应用程序利用此函数向CTP服务器发送,账户密码更新请求。 定义:int ReqTradingAccountPasswordUpdate(
CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, int nRequestID) ;
参数:
pUserPasswordUpdate:Pointer of the structure for account password updation request. The following is definition of the structure,
struct CThostFtdcTradingAccountPasswordUpdateField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///account id
TThostFtdcAccountIDType AccountID; ///old password
TThostFtdcPasswordType OldPassword; ///new password
TThostFtdcPasswordType NewPassword; };
5.3.14 ReqOrderInsert
CTP客户端应用程序利用此函数向CTP服务器发送,发出订单的请求。 定义:int ReqOrderInsert(
CThostFtdcInputOrderField *pInputOrder, int nRequestID);
参数:
pInputOrder:Pointer of the structure for order insertion request. The following is definition of the structure,
struct CThostFtdcInputOrderField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///instrument ID
TThostFtdcInstrumentIDType InstrumentID; ///order reference
TThostFtdcOrderRefType OrderRef; ///user id
TThostFtdcUserIDType UserID; ///order price type
TThostFtdcOrderPriceTypeType OrderPriceType; ///direction
TThostFtdcDirectionType Direction; ///combination order’s offset flag
TThostFtdcCombOffsetFlagType CombOffsetFlag; ///combination or hedge flag
TThostFtdcCombHedgeFlagType CombHedgeFlag; ///price
TThostFtdcPriceType LimitPrice; ///volume
TThostFtdcVolumeType VolumeTotalOriginal;
///valid date
TThostFtdcTimeConditionType TimeCondition; ///GTD DATE
TThostFtdcDateType GTDDate; ///volume condition
TThostFtdcVolumeConditionType VolumeCondition; ///min volume
TThostFtdcVolumeType MinVolume; ///trigger condition
TThostFtdcContingentConditionType ContingentCondition; ///stop price
TThostFtdcPriceType StopPrice; ///force close reason
TThostFtdcForceCloseReasonType ForceCloseReason; /// auto suspend flag
TThostFtdcBoolType IsAutoSuspend; ///business unit
TThostFtdcBusinessUnitType BusinessUnit; ///request ID
TThostFtdcRequestIDType RequestID; };
OrderRef:order reference指令目录会一直增加,当回应每一个“OnRspUserLogin”请求时,客户端应用程序会获得“MaxOrderRef”。另外需要注意,CTP服务器认为OrderRef为字符串,所以需要整理TThostFtdcOrderRefType的placet。
5.3.15 ReqOrderAction
CTP客户端应用程序利用此函数向CTP服务器发送,撤单指令。 定义:int ReqOrderAction(
CThostFtdcOrderActionField *pOrderAction, int nRequestID);
参数:
pOrderAction:Pointer of the structure for order delettion request. The following is definition of the structure, struct CThostFtdcOrderActionField {
///broker id
TThostFtdcBrokerIDType BrokerID; ///investor ID
TThostFtdcInvestorIDType InvestorID; ///order action reference
TThostFtdcOrderActionRefType OrderActionRef; ///order reference
TThostFtdcOrderRefType OrderRef;
正在阅读:
ctp手册04-16
移动基站项目可行性研究报告04-26
《藏羚羊》搜索引擎教学设计-2010.106-05
《母鸡》观课报告03-27
淮南市毛集流砂洼抛石工程施工管理报告06-30
2018年中国IT培训市场行情动态分析及发展前景趋势预测(目录) -05-23
财务管理(2017)章节练习 - 第2章 财务报表分析和财务预测04-05
信托市场研究 - 图文04-28
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 手册
- ctp
- 噬菌体的发现和研究历史
- 2016届江苏省镇江市高三下学期第一次模拟考试地理试题 解析版
- 桌面虚拟化测试报告(VGPU)
- 0024.北二注水站改造工程施工组织设计方案
- 备考2017新课标高考英语二轮复习语法10个专题(近六年高考真题单
- 2017中级会计职称《会计实务》高频考点:不确认递延所得税负债的
- 中考冠词用法复习小结
- 传播与沟通 - 在线作业 - 2
- MFC教程
- XL3418T材料力学多功能实验装置电测实验指导书(通用) - 图文
- 2016年北京市东城区高三一模物理试题及答案
- 有机化学 课后习题解答9
- 个人知识管理软件-文档大师 V2015 帮助手册 V2.5 - 图文
- 人教初一数学有理数单元检测题10套
- 当代局部战争简答题
- 电路板(PCB)项目立项报告
- 9.31 110KV电力系统调试方案
- 中国游乐场设备行业研究报告目录
- 线路类安规考试题库(答案)
- 安装给排水定额