// libcctp.h // libcctp是把CTP的C++接口转换为C接口, 这样方便其他语言(比如go, python, java等)调用 // 同时对原有的接口进行封装和简化, 但不影响原有功能. 达到使用简单, 功能完全的目的。 // 本文件定义了libcctp的导出函数 #pragma once #ifdef _WINDOWS #ifdef LIBCCTP_EXPORTS #define LIBCCTP_API __declspec(dllexport) #else #define LIBCCTP_API __declspec(dllimport) #endif #else #define LIBCCTP_API #endif #ifdef __cplusplus extern "C" { #else typedef int bool; #endif #include "CTP/ThostFtdcUserApiStruct.h" // c only typedef struct CThostFtdcRspUserLoginField CThostFtdcRspUserLoginField; typedef struct CThostFtdcRspInfoField CThostFtdcRspInfoField; typedef struct CThostFtdcUserLogoutField CThostFtdcUserLogoutField; typedef struct CThostFtdcRspAuthenticateField CThostFtdcRspAuthenticateField; typedef struct CThostFtdcReqUserLoginField CThostFtdcReqUserLoginField; typedef struct CThostFtdcSpecificInstrumentField CThostFtdcSpecificInstrumentField; typedef struct CThostFtdcUserPasswordUpdateField CThostFtdcUserPasswordUpdateField; typedef struct CThostFtdcTradingAccountPasswordUpdateField CThostFtdcTradingAccountPasswordUpdateField; typedef struct CThostFtdcInputOrderField CThostFtdcInputOrderField; typedef struct CThostFtdcParkedOrderField CThostFtdcParkedOrderField; typedef struct CThostFtdcParkedOrderActionField CThostFtdcParkedOrderActionField; typedef struct CThostFtdcQueryMaxOrderVolumeField CThostFtdcQueryMaxOrderVolumeField; typedef struct CThostFtdcOrderField CThostFtdcOrderField; typedef struct CThostFtdcTradeField CThostFtdcTradeField; typedef struct CThostFtdcExchangeField CThostFtdcExchangeField; typedef struct CThostFtdcInstrumentField CThostFtdcInstrumentField; typedef struct CThostFtdcDepthMarketDataField CThostFtdcDepthMarketDataField; typedef struct CThostFtdcSettlementInfoField CThostFtdcSettlementInfoField; typedef struct CThostFtdcTransferBankField CThostFtdcTransferBankField; typedef struct CThostFtdcInvestorPositionDetailField CThostFtdcInvestorPositionDetailField; typedef struct CThostFtdcNoticeField CThostFtdcNoticeField; typedef struct CThostFtdcSettlementInfoConfirmField CThostFtdcSettlementInfoConfirmField; typedef struct CThostFtdcRemoveParkedOrderField CThostFtdcRemoveParkedOrderField; typedef struct CThostFtdcRemoveParkedOrderActionField CThostFtdcRemoveParkedOrderActionField; typedef struct CThostFtdcInvestorPositionField CThostFtdcInvestorPositionField; typedef struct CThostFtdcTradingAccountField CThostFtdcTradingAccountField; typedef struct CThostFtdcInvestorField CThostFtdcInvestorField; typedef struct CThostFtdcTradingCodeField CThostFtdcTradingCodeField; typedef struct CThostFtdcInstrumentMarginRateField CThostFtdcInstrumentMarginRateField; typedef struct CThostFtdcInstrumentCommissionRateField CThostFtdcInstrumentCommissionRateField; typedef struct CThostFtdcCFMMCTradingAccountKeyField CThostFtdcCFMMCTradingAccountKeyField; typedef struct CThostFtdcEWarrantOffsetField CThostFtdcEWarrantOffsetField; typedef struct CThostFtdcContractBankField CThostFtdcContractBankField; typedef struct CThostFtdcInvestorPositionCombineDetailField CThostFtdcInvestorPositionCombineDetailField; typedef struct CThostFtdcCancelAccountField CThostFtdcCancelAccountField; typedef struct CThostFtdcChangeAccountField CThostFtdcChangeAccountField; typedef struct CThostFtdcTransferSerialField CThostFtdcTransferSerialField; typedef struct CThostFtdcAccountregisterField CThostFtdcAccountregisterField; typedef struct CThostFtdcOrderActionField CThostFtdcOrderActionField; typedef struct CThostFtdcInstrumentStatusField CThostFtdcInstrumentStatusField; typedef struct CThostFtdcErrorConditionalOrderField CThostFtdcErrorConditionalOrderField; typedef struct CThostFtdcTradingNoticeInfoField CThostFtdcTradingNoticeInfoField; typedef struct CThostFtdcTradingNoticeField CThostFtdcTradingNoticeField; typedef struct CThostFtdcBrokerTradingParamsField CThostFtdcBrokerTradingParamsField; typedef struct CThostFtdcBrokerTradingAlgosField CThostFtdcBrokerTradingAlgosField; typedef struct CThostFtdcRspTransferField CThostFtdcRspTransferField; typedef struct CThostFtdcQryInstrumentField CThostFtdcQryInstrumentField; typedef struct CThostFtdcQryOrderField CThostFtdcQryOrderField; ///期货发起查询银行余额通知 typedef struct CThostFtdcNotifyQueryAccountField CThostFtdcNotifyQueryAccountField; typedef struct CThostFtdcQryInvestorPositionField CThostFtdcQryInvestorPositionField; ///期货发起银行资金转期货错误回报 typedef struct CThostFtdcReqTransferField CThostFtdcReqTransferField; ///系统运行时期货端手工发起冲正银行转期货错误回报 typedef struct CThostFtdcReqRepealField CThostFtdcReqRepealField; ///系统运行时期货端手工发起冲正期货转银行错误回报 typedef struct OnErrRtnRepealFutureToBankByFutureManual OnErrRtnRepealFutureToBankByFutureManual; ///期货发起查询银行余额错误回报 typedef struct CThostFtdcReqQueryAccountField CThostFtdcReqQueryAccountField; typedef struct CThostFtdcQryInvestorField CThostFtdcQryInvestorField; ///期货发起冲正期货转银行请求,银行处理完毕后报盘发回的通知 typedef struct CThostFtdcRspRepealField CThostFtdcRspRepealField; ///期货发起银行资金转期货应答 ///期货发起期货资金转银行应答 ///期货发起查询银行余额应答 typedef struct CThostFtdcQryTradingAccountField CThostFtdcQryTradingAccountField; ///银行发起银期开户通知 typedef struct CThostFtdcOpenAccountField CThostFtdcOpenAccountField; typedef struct CThostFtdcReqAuthenticateField CThostFtdcReqAuthenticateField; typedef struct CThostFtdcQryTradingCodeField CThostFtdcQryTradingCodeField; typedef struct CThostFtdcQryTradeField CThostFtdcQryTradeField; typedef struct CThostFtdcQryInstrumentCommissionRateField CThostFtdcQryInstrumentCommissionRateField; typedef struct CThostFtdcQryInstrumentMarginRateField CThostFtdcQryInstrumentMarginRateField; typedef struct CThostFtdcQrySettlementInfoField CThostFtdcQrySettlementInfoField; typedef struct CThostFtdcQryExchangeField CThostFtdcQryExchangeField; typedef struct CThostFtdcQryDepthMarketDataField CThostFtdcQryDepthMarketDataField; typedef struct CThostFtdcQryInvestorPositionDetailField CThostFtdcQryInvestorPositionDetailField; typedef struct CThostFtdcQryTransferBankField CThostFtdcQryTransferBankField; ///请求查询客户通知 typedef struct CThostFtdcQryNoticeField CThostFtdcQryNoticeField; ///请求查询结算信息确认 typedef struct CThostFtdcQrySettlementInfoConfirmField CThostFtdcQrySettlementInfoConfirmField; ///请求查询投资者持仓明细 typedef struct CThostFtdcQryInvestorPositionCombineDetailField CThostFtdcQryInvestorPositionCombineDetailField; ///请求查询保证金监管系统经纪公司资金账户密钥 typedef struct CThostFtdcQryCFMMCTradingAccountKeyField CThostFtdcQryCFMMCTradingAccountKeyField; ///请求查询仓单折抵信息 typedef struct CThostFtdcQryEWarrantOffsetField CThostFtdcQryEWarrantOffsetField; ///请求查询转帐流水 typedef struct CThostFtdcQryTransferSerialField CThostFtdcQryTransferSerialField; ///请求查询银期签约关系 typedef struct CThostFtdcQryAccountregisterField CThostFtdcQryAccountregisterField; ///请求查询签约银行 typedef struct CThostFtdcQryContractBankField CThostFtdcQryContractBankField; ///请求查询预埋单 typedef struct CThostFtdcQryParkedOrderField CThostFtdcQryParkedOrderField; ///请求查询预埋撤单 typedef struct CThostFtdcQryParkedOrderActionField CThostFtdcQryParkedOrderActionField; ///请求查询交易通知 typedef struct CThostFtdcQryTradingNoticeField CThostFtdcQryTradingNoticeField; ///请求查询经纪公司交易参数 typedef struct CThostFtdcQryBrokerTradingParamsField CThostFtdcQryBrokerTradingParamsField; ///请求查询经纪公司交易算法 typedef struct CThostFtdcQryBrokerTradingAlgosField CThostFtdcQryBrokerTradingAlgosField; ///登录请求响应 typedef void(*fnOnRspUserLogin)(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast, void* ctx); ///登出请求响应 typedef void(*fnOnRspUserLogout)(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast, void* ctx); ///错误应答 typedef void(*fnOnRspError)(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast, void* ctx); ///深度行情通知 typedef void(*fnOnRtnDepthMarketData)(CThostFtdcDepthMarketDataField *pDepthMarketData, void* ctx); ///请求查询交易所响应 typedef void(*fnOnRspQryExchange)(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast, void* ctx); ///请求查询合约响应 typedef void(*fnOnRspQryInstrument)(CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast, void* ctx); ///请求查询结算信息确认响应 typedef void(*fnOnRspSettlementInfoConfirm)(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast, void* ctx); /// 注册行情服务回调函数 LIBCCTP_API void CCTP_RegOnMdRspUserLogin(void* mdapi, fnOnRspUserLogin call_back, void* ctx); LIBCCTP_API void CCTP_RegOnMdRspUserLogout(void* mdapi, fnOnRspUserLogout call_back, void* ctx); LIBCCTP_API void CCTP_RegOnMdRspError(void* mdapi, fnOnRspError call_back, void* ctx); LIBCCTP_API void CCTP_RegOnRtnDepthMarketData(void* mdapi, fnOnRtnDepthMarketData call_back, void* ctx); // 注册交易服务回调函数 LIBCCTP_API void CCTP_RegOnTdRspUserLogin(void* tdapi, fnOnRspUserLogin call_back, void* ctx); LIBCCTP_API void CCTP_RegOnTdRspUserLogout(void* tdapi, fnOnRspUserLogout call_back, void* ctx); LIBCCTP_API void CCTP_RegOnTdRspError(void* tdapi, fnOnRspError call_back, void* ctx); LIBCCTP_API void CCTP_RegOnRspQryExchange(void* tdapi, fnOnRspQryExchange call_back, void* ctx); LIBCCTP_API void CCTP_RegOnRspQryInstrument(void* tdapi, fnOnRspQryInstrument call_back, void* ctx); /// 创建行情Api, 返回void*指针, 以下行情部分接口此指针作为行情上下文 LIBCCTP_API void* CCTP_MdApiCreate(const char* dir); /// 释放行情接口 LIBCCTP_API void CCTP_MdRelease(void* mdapi); /// 登录行情 LIBCCTP_API int CCTP_MdLogin( void* mdapi, const char* addr, const char* brokerId, const char* userId, const char* password); /// 登出行情 LIBCCTP_API int CCTP_MdLogout(void* mdapi, const char* brokerId, const char* userId); /// 订阅合约 LIBCCTP_API int CCTP_SubscribeMarketData(void* mdapi, char* instrumentIds[], int n); /// 取消订阅合约 LIBCCTP_API int CCTP_UnSubscribeMarketData(void* mdapi, char* instrumentIds[], int n); /// 创建交易Api, 返回void*指针, 以下行情部分接口此指针作为上下文信息 LIBCCTP_API void* CCTP_TdApiCreate(const char* dir); /// 释放交易接口 LIBCCTP_API void CCTP_TdRelease(void* tdapi); /// 登录交易 LIBCCTP_API int CCTP_TdLogin( void* tdapi, const char* addr, const char* brokerId, const char* userId, const char* password, const char* authCode, const char* userProductInfo); //// 登出交易 LIBCCTP_API int CCTP_TdLogout(void* tdapi, const char* brokerId, const char* userId); /// 查询合约, 如果instrmentId==nullptr, 查询所有合约 LIBCCTP_API int CCTP_ReqQryInstrument(void* tdapi, const char* instrumentId); /// 查询交易所, 如果instrmentId==nullptr, 查询所有合约 LIBCCTP_API int CCTP_ReqQryExchange(void* tdapi, const char* exchangeId); #ifdef __cplusplus } #endif