commit
c6c72053df
@ -7,7 +7,8 @@ from vnpy.trader.ui import MainWindow, create_qapp
|
|||||||
from vnpy.gateway.bitmex import BitmexGateway
|
from vnpy.gateway.bitmex import BitmexGateway
|
||||||
from vnpy.gateway.futu import FutuGateway
|
from vnpy.gateway.futu import FutuGateway
|
||||||
from vnpy.gateway.ib import IbGateway
|
from vnpy.gateway.ib import IbGateway
|
||||||
from vnpy.gateway.ctp import CtpGateway
|
#from vnpy.gateway.ctp import CtpGateway
|
||||||
|
from vnpy.gateway.femas import FemasGateway
|
||||||
from vnpy.gateway.tiger import TigerGateway
|
from vnpy.gateway.tiger import TigerGateway
|
||||||
from vnpy.gateway.oes import OesGateway
|
from vnpy.gateway.oes import OesGateway
|
||||||
from vnpy.gateway.okex import OkexGateway
|
from vnpy.gateway.okex import OkexGateway
|
||||||
@ -29,7 +30,8 @@ def main():
|
|||||||
event_engine = EventEngine()
|
event_engine = EventEngine()
|
||||||
|
|
||||||
main_engine = MainEngine(event_engine)
|
main_engine = MainEngine(event_engine)
|
||||||
main_engine.add_gateway(CtpGateway)
|
# main_engine.add_gateway(CtpGateway)
|
||||||
|
main_engine.add_gateway(FemasGateway)
|
||||||
main_engine.add_gateway(IbGateway)
|
main_engine.add_gateway(IbGateway)
|
||||||
main_engine.add_gateway(FutuGateway)
|
main_engine.add_gateway(FutuGateway)
|
||||||
main_engine.add_gateway(BitmexGateway)
|
main_engine.add_gateway(BitmexGateway)
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,206 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///@system 风控前置系统
|
|
||||||
///@company 上海金融期货信息技术有限公司
|
|
||||||
///@file USTPFtdcMduserApi.h
|
|
||||||
///@brief 定义了客户端接口
|
|
||||||
///@history
|
|
||||||
///20130520 徐忠华 创建该文件
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#if !defined(USTP_FTDCMDUSERAPI_H)
|
|
||||||
#define USTP_FTDCMDUSERAPI_H
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
#include "USTPFtdcUserApiStruct.h"
|
|
||||||
|
|
||||||
#if defined(ISLIB) && defined(WIN32)
|
|
||||||
#ifdef LIB_MDUSER_API_EXPORT
|
|
||||||
#define MDUSER_API_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define MDUSER_API_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define MDUSER_API_EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class CUstpFtdcMduserSpi
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
|
||||||
virtual void OnFrontConnected(){};
|
|
||||||
|
|
||||||
///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
|
|
||||||
///@param nReason 错误原因
|
|
||||||
/// 0x1001 网络读失败
|
|
||||||
/// 0x1002 网络写失败
|
|
||||||
/// 0x2001 接收心跳超时
|
|
||||||
/// 0x2002 发送心跳失败
|
|
||||||
/// 0x2003 收到错误报文
|
|
||||||
virtual void OnFrontDisconnected(int nReason){};
|
|
||||||
|
|
||||||
///心跳超时警告。当长时间未收到报文时,该方法被调用。
|
|
||||||
///@param nTimeLapse 距离上次接收报文的时间
|
|
||||||
virtual void OnHeartBeatWarning(int nTimeLapse){};
|
|
||||||
|
|
||||||
///报文回调开始通知。当API收到一个报文后,首先调用本方法,然后是各数据域的回调,最后是报文回调结束通知。
|
|
||||||
///@param nTopicID 主题代码(如私有流、公共流、行情流等)
|
|
||||||
///@param nSequenceNo 报文序号
|
|
||||||
virtual void OnPackageStart(int nTopicID, int nSequenceNo){};
|
|
||||||
|
|
||||||
///报文回调结束通知。当API收到一个报文后,首先调用报文回调开始通知,然后是各数据域的回调,最后调用本方法。
|
|
||||||
///@param nTopicID 主题代码(如私有流、公共流、行情流等)
|
|
||||||
///@param nSequenceNo 报文序号
|
|
||||||
virtual void OnPackageEnd(int nTopicID, int nSequenceNo){};
|
|
||||||
|
|
||||||
|
|
||||||
///错误应答
|
|
||||||
virtual void OnRspError(CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///风控前置系统用户登录应答
|
|
||||||
virtual void OnRspUserLogin(CUstpFtdcRspUserLoginField *pRspUserLogin, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///用户退出应答
|
|
||||||
virtual void OnRspUserLogout(CUstpFtdcRspUserLogoutField *pRspUserLogout, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///深度行情通知
|
|
||||||
virtual void OnRtnDepthMarketData(CUstpFtdcDepthMarketDataField *pDepthMarketData) {};
|
|
||||||
|
|
||||||
///订阅合约的相关信息
|
|
||||||
virtual void OnRspSubMarketData(CUstpFtdcSpecificInstrumentField *pSpecificInstrument, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///退订合约的相关信息
|
|
||||||
virtual void OnRspUnSubMarketData(CUstpFtdcSpecificInstrumentField *pSpecificInstrument, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///获取行情主题信息应答
|
|
||||||
virtual void OnRspGetMarketTopic(CUstpFtdcRspMarketTopicField *pRspMarketTopic, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///获取行情快照应答
|
|
||||||
virtual void OnRspGetMarketData(CUstpFtdcRspDepthMarketDataField *pRspDepthMarketData, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class MDUSER_API_EXPORT CUstpFtdcMduserApi
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
///创建MduserApi
|
|
||||||
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
|
|
||||||
///@return 创建出的UserApi
|
|
||||||
static CUstpFtdcMduserApi *CreateFtdcMduserApi(const char *pszFlowPath = "");
|
|
||||||
|
|
||||||
///获取系统版本号
|
|
||||||
///@param nMajorVersion 主版本号
|
|
||||||
///@param nMinorVersion 子版本号
|
|
||||||
///@return 系统标识字符串
|
|
||||||
static const char *GetVersion(int &nMajorVersion, int &nMinorVersion);
|
|
||||||
|
|
||||||
///删除接口对象本身
|
|
||||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
|
||||||
virtual void Release() = 0;
|
|
||||||
|
|
||||||
///初始化
|
|
||||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
|
||||||
virtual void Init() = 0;
|
|
||||||
|
|
||||||
///等待接口线程结束运行
|
|
||||||
///@return 线程退出代码
|
|
||||||
virtual int Join() = 0;
|
|
||||||
|
|
||||||
/// 是否使用多播方式接收行情
|
|
||||||
/// @param bUseMulti 默认为false,表示不使用多播接收行情
|
|
||||||
/// @remark 如果使用多播,则无需登录,也使用不了需要登录才能使用的接口
|
|
||||||
virtual void SetUseMultiChannel(bool bUseMulti = false) = 0;
|
|
||||||
|
|
||||||
///注册多播通道
|
|
||||||
///@param pMultiChannel 多播通道地址地址,
|
|
||||||
///@remark 网络地址的例子:”multi://172.25.125@232.0.0.1:5131”。
|
|
||||||
///@remark “multi”代表使用多播传输;“172.25.125”用来确定接收多播的网卡;”232.0.0.1:5131”代表多播通道及端口。
|
|
||||||
///@remark 可以多次调用,注册多个通道,接收多个通道中速度最优的行情
|
|
||||||
virtual void RegisterMultiChannel(const char *pMultiChannel) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
///获取当前交易日
|
|
||||||
///@retrun 获取到的交易日
|
|
||||||
///@remark 只有登录成功后,才能得到正确的交易日
|
|
||||||
virtual const char *GetTradingDay() = 0;
|
|
||||||
|
|
||||||
///注册前置机网络地址
|
|
||||||
///@param pszFrontAddress:前置机网络地址。
|
|
||||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。
|
|
||||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
|
|
||||||
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
|
||||||
|
|
||||||
///注册名字服务器网络地址
|
|
||||||
///@param pszNsAddress:名字服务器网络地址。
|
|
||||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。
|
|
||||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。
|
|
||||||
///@remark RegisterFront优先于RegisterNameServer
|
|
||||||
virtual void RegisterNameServer(char *pszNsAddress) = 0;
|
|
||||||
|
|
||||||
///注册回调接口
|
|
||||||
///@param pSpi 派生自回调接口类的实例
|
|
||||||
virtual void RegisterSpi(CUstpFtdcMduserSpi *pSpi) = 0;
|
|
||||||
|
|
||||||
///加载证书
|
|
||||||
///@param pszCertFileName 用户证书文件名
|
|
||||||
///@param pszKeyFileName 用户私钥文件名
|
|
||||||
///@param pszCaFileName 可信任CA证书文件名
|
|
||||||
///@param pszKeyFilePassword 用户私钥文件密码
|
|
||||||
///@return 0 操作成功
|
|
||||||
///@return -1 可信任CA证书载入失败
|
|
||||||
///@return -2 用户证书载入失败
|
|
||||||
///@return -3 用户私钥载入失败
|
|
||||||
///@return -4 用户证书校验失败
|
|
||||||
virtual int RegisterCertificateFile(const char *pszCertFileName, const char *pszKeyFileName,
|
|
||||||
const char *pszCaFileName, const char *pszKeyFilePassword) = 0;
|
|
||||||
|
|
||||||
///订阅市场行情。
|
|
||||||
///@param nTopicID 市场行情主题
|
|
||||||
///@param nResumeType 市场行情重传方式
|
|
||||||
/// USTP_TERT_RESTART:从本交易日开始重传
|
|
||||||
/// USTP_TERT_RESUME:从上次收到的续传(非订阅全部合约时,不支持续传模式)
|
|
||||||
/// USTP_TERT_QUICK:先传送当前行情快照,再传送登录后市场行情的内容
|
|
||||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到私有流的数据。
|
|
||||||
virtual void SubscribeMarketDataTopic(int nTopicID, USTP_TE_RESUME_TYPE nResumeType) = 0;
|
|
||||||
|
|
||||||
///订阅合约行情。
|
|
||||||
///@param ppInstrumentID 合约ID
|
|
||||||
///@param nCount 要订阅/退订行情的合约个数
|
|
||||||
///@remark
|
|
||||||
virtual int SubMarketData(char *ppInstrumentID[], int nCount)=0;
|
|
||||||
|
|
||||||
///退订合约行情。
|
|
||||||
///@param ppInstrumentID 合约ID
|
|
||||||
///@param nCount 要订阅/退订行情的合约个数
|
|
||||||
///@remark
|
|
||||||
virtual int UnSubMarketData(char *ppInstrumentID[], int nCount)=0;
|
|
||||||
|
|
||||||
///获取行情订阅号。
|
|
||||||
///@param *ppExchangeID 合约ID
|
|
||||||
///@param nCount 要获取行情订阅号的交易所个数
|
|
||||||
///@remark
|
|
||||||
virtual int GetMarketTopic(char *pExchangeID)=0;
|
|
||||||
|
|
||||||
///获取行情快照。
|
|
||||||
///@param *ppExchangeID 交易所ID
|
|
||||||
///@param ppInstrumentID 合约ID
|
|
||||||
///@param nCount 要获取行情订阅号的交易所个数
|
|
||||||
///@remark
|
|
||||||
virtual int GetMarketData(char *pExchangeID, char *pInstrumentID) = 0;
|
|
||||||
|
|
||||||
///设置心跳超时时间。
|
|
||||||
///@param timeout 心跳超时时间(秒)
|
|
||||||
virtual void SetHeartbeatTimeout(unsigned int timeout) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
///风控前置系统用户登录请求
|
|
||||||
virtual int ReqUserLogin(CUstpFtdcReqUserLoginField *pReqUserLogin, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///用户退出请求
|
|
||||||
virtual int ReqUserLogout(CUstpFtdcReqUserLogoutField *pReqUserLogout, int nRequestID) = 0;
|
|
||||||
protected:
|
|
||||||
~CUstpFtdcMduserApi(){};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,409 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///@system 风控前置系统
|
|
||||||
///@company CFFEX
|
|
||||||
///@file USTPFtdcTraderApi.h
|
|
||||||
///@brief 定义了客户端接口
|
|
||||||
///@history
|
|
||||||
///20130520 佘鹏飞 创建该文件
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#if !defined(USTP_FTDCTRADERAPI_H)
|
|
||||||
#define USTP_FTDCTRADERAPI_H
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
#include "USTPFtdcUserApiStruct.h"
|
|
||||||
|
|
||||||
#if defined(ISLIB) && defined(WIN32)
|
|
||||||
#ifdef LIB_TRADER_API_EXPORT
|
|
||||||
#define TRADER_API_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define TRADER_API_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define TRADER_API_EXPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class CUstpFtdcTraderSpi
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
|
||||||
virtual void OnFrontConnected(){};
|
|
||||||
virtual void OnQryFrontConnected(){};
|
|
||||||
///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
|
|
||||||
///@param nReason 错误原因
|
|
||||||
/// 0x1001 网络读失败
|
|
||||||
/// 0x1002 网络写失败
|
|
||||||
/// 0x2001 接收心跳超时
|
|
||||||
/// 0x2002 发送心跳失败
|
|
||||||
/// 0x2003 收到错误报文
|
|
||||||
virtual void OnFrontDisconnected(int nReason){};
|
|
||||||
virtual void OnQryFrontDisconnected(int nReason){};
|
|
||||||
|
|
||||||
///心跳超时警告。当长时间未收到报文时,该方法被调用。
|
|
||||||
///@param nTimeLapse 距离上次接收报文的时间
|
|
||||||
virtual void OnHeartBeatWarning(int nTimeLapse){};
|
|
||||||
|
|
||||||
///报文回调开始通知。当API收到一个报文后,首先调用本方法,然后是各数据域的回调,最后是报文回调结束通知。
|
|
||||||
///@param nTopicID 主题代码(如私有流、公共流、行情流等)
|
|
||||||
///@param nSequenceNo 报文序号
|
|
||||||
virtual void OnPackageStart(int nTopicID, int nSequenceNo){};
|
|
||||||
|
|
||||||
///报文回调结束通知。当API收到一个报文后,首先调用报文回调开始通知,然后是各数据域的回调,最后调用本方法。
|
|
||||||
///@param nTopicID 主题代码(如私有流、公共流、行情流等)
|
|
||||||
///@param nSequenceNo 报文序号
|
|
||||||
virtual void OnPackageEnd(int nTopicID, int nSequenceNo){};
|
|
||||||
|
|
||||||
|
|
||||||
///错误应答
|
|
||||||
virtual void OnRspError(CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///风控前置系统用户登录应答
|
|
||||||
virtual void OnRspUserLogin(CUstpFtdcRspUserLoginField *pRspUserLogin, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///用户退出应答
|
|
||||||
virtual void OnRspUserLogout(CUstpFtdcRspUserLogoutField *pRspUserLogout, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///用户密码修改应答
|
|
||||||
virtual void OnRspUserPasswordUpdate(CUstpFtdcUserPasswordUpdateField *pUserPasswordUpdate, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///报单录入应答
|
|
||||||
virtual void OnRspOrderInsert(CUstpFtdcInputOrderField *pInputOrder, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///报单操作应答
|
|
||||||
virtual void OnRspOrderAction(CUstpFtdcOrderActionField *pOrderAction, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///报价录入应答
|
|
||||||
virtual void OnRspQuoteInsert(CUstpFtdcInputQuoteField *pInputQuote, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///报价操作应答
|
|
||||||
virtual void OnRspQuoteAction(CUstpFtdcQuoteActionField *pQuoteAction, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///询价请求应答
|
|
||||||
virtual void OnRspForQuote(CUstpFtdcReqForQuoteField *pReqForQuote, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///客户申请组合应答
|
|
||||||
virtual void OnRspMarginCombAction(CUstpFtdcInputMarginCombActionField *pInputMarginCombAction, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///用户请求出入金应答
|
|
||||||
virtual void OnRspUserDeposit(CUstpFtdcstpUserDepositField *pstpUserDeposit, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///用户主次席出入金应答
|
|
||||||
virtual void OnRspTransferMoney(CUstpFtdcstpTransferMoneyField *pstpTransferMoney, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///数据流回退通知
|
|
||||||
virtual void OnRtnFlowMessageCancel(CUstpFtdcFlowMessageCancelField *pFlowMessageCancel) {};
|
|
||||||
|
|
||||||
///成交回报
|
|
||||||
virtual void OnRtnTrade(CUstpFtdcTradeField *pTrade) {};
|
|
||||||
|
|
||||||
///报单回报
|
|
||||||
virtual void OnRtnOrder(CUstpFtdcOrderField *pOrder) {};
|
|
||||||
|
|
||||||
///报单录入错误回报
|
|
||||||
virtual void OnErrRtnOrderInsert(CUstpFtdcInputOrderField *pInputOrder, CUstpFtdcRspInfoField *pRspInfo) {};
|
|
||||||
|
|
||||||
///报单操作错误回报
|
|
||||||
virtual void OnErrRtnOrderAction(CUstpFtdcOrderActionField *pOrderAction, CUstpFtdcRspInfoField *pRspInfo) {};
|
|
||||||
|
|
||||||
///合约交易状态通知
|
|
||||||
virtual void OnRtnInstrumentStatus(CUstpFtdcInstrumentStatusField *pInstrumentStatus) {};
|
|
||||||
|
|
||||||
///账户出入金回报
|
|
||||||
virtual void OnRtnInvestorAccountDeposit(CUstpFtdcInvestorAccountDepositResField *pInvestorAccountDepositRes) {};
|
|
||||||
|
|
||||||
///报价回报
|
|
||||||
virtual void OnRtnQuote(CUstpFtdcRtnQuoteField *pRtnQuote) {};
|
|
||||||
|
|
||||||
///报价录入错误回报
|
|
||||||
virtual void OnErrRtnQuoteInsert(CUstpFtdcInputQuoteField *pInputQuote, CUstpFtdcRspInfoField *pRspInfo) {};
|
|
||||||
|
|
||||||
///报价撤单错误回报
|
|
||||||
virtual void OnErrRtnQuoteAction(CUstpFtdcQuoteActionField *pQuoteAction, CUstpFtdcRspInfoField *pRspInfo) {};
|
|
||||||
|
|
||||||
///询价回报
|
|
||||||
virtual void OnRtnForQuote(CUstpFtdcReqForQuoteField *pReqForQuote) {};
|
|
||||||
|
|
||||||
///增加组合规则通知
|
|
||||||
virtual void OnRtnMarginCombinationLeg(CUstpFtdcMarginCombinationLegField *pMarginCombinationLeg) {};
|
|
||||||
|
|
||||||
///客户申请组合确认
|
|
||||||
virtual void OnRtnMarginCombAction(CUstpFtdcInputMarginCombActionField *pInputMarginCombAction) {};
|
|
||||||
|
|
||||||
///用户请求出入金
|
|
||||||
virtual void OnRtnUserDeposit(CUstpFtdcstpUserDepositField *pstpUserDeposit) {};
|
|
||||||
|
|
||||||
///查询前置系统用户登录应答
|
|
||||||
virtual void OnRspQueryUserLogin(CUstpFtdcRspUserLoginField *pRspUserLogin, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///报单查询应答
|
|
||||||
virtual void OnRspQryOrder(CUstpFtdcOrderField *pOrder, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///成交单查询应答
|
|
||||||
virtual void OnRspQryTrade(CUstpFtdcTradeField *pTrade, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///可用投资者账户查询应答
|
|
||||||
virtual void OnRspQryUserInvestor(CUstpFtdcRspUserInvestorField *pRspUserInvestor, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///交易编码查询应答
|
|
||||||
virtual void OnRspQryTradingCode(CUstpFtdcRspTradingCodeField *pRspTradingCode, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///投资者资金账户查询应答
|
|
||||||
virtual void OnRspQryInvestorAccount(CUstpFtdcRspInvestorAccountField *pRspInvestorAccount, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///合约查询应答
|
|
||||||
virtual void OnRspQryInstrument(CUstpFtdcRspInstrumentField *pRspInstrument, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///交易所查询应答
|
|
||||||
virtual void OnRspQryExchange(CUstpFtdcRspExchangeField *pRspExchange, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///投资者持仓查询应答
|
|
||||||
virtual void OnRspQryInvestorPosition(CUstpFtdcRspInvestorPositionField *pRspInvestorPosition, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///合规参数查询应答
|
|
||||||
virtual void OnRspQryComplianceParam(CUstpFtdcRspComplianceParamField *pRspComplianceParam, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///投资者手续费率查询应答
|
|
||||||
virtual void OnRspQryInvestorFee(CUstpFtdcInvestorFeeField *pInvestorFee, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///投资者保证金率查询应答
|
|
||||||
virtual void OnRspQryInvestorMargin(CUstpFtdcInvestorMarginField *pInvestorMargin, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///交易编码组合持仓查询应答
|
|
||||||
virtual void OnRspQryInvestorCombPosition(CUstpFtdcRspInvestorCombPositionField *pRspInvestorCombPosition, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///交易编码单腿持仓查询应答
|
|
||||||
virtual void OnRspQryInvestorLegPosition(CUstpFtdcRspInvestorLegPositionField *pRspInvestorLegPosition, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///合约组信息查询应答
|
|
||||||
virtual void OnRspQryInstrumentGroup(CUstpFtdcRspInstrumentGroupField *pRspInstrumentGroup, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///组合保证金类型查询应答
|
|
||||||
virtual void OnRspQryClientMarginCombType(CUstpFtdcRspClientMarginCombTypeField *pRspClientMarginCombType, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///行权录入应答
|
|
||||||
virtual void OnRspExecOrderInsert(CUstpFtdcInputExecOrderField *pInputExecOrder, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///行权操作应答
|
|
||||||
virtual void OnRspExecOrderAction(CUstpFtdcInputExecOrderActionField *pInputExecOrderAction, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
|
|
||||||
///行权通知
|
|
||||||
virtual void OnRtnExecOrder(CUstpFtdcExecOrderField *pExecOrder) {};
|
|
||||||
|
|
||||||
///行权录入错误回报
|
|
||||||
virtual void OnErrRtnExecOrderInsert(CUstpFtdcInputExecOrderField *pInputExecOrder, CUstpFtdcRspInfoField *pRspInfo) {};
|
|
||||||
|
|
||||||
///行权操作错误回报
|
|
||||||
virtual void OnErrRtnExecOrderAction(CUstpFtdcInputExecOrderActionField *pInputExecOrderAction, CUstpFtdcRspInfoField *pRspInfo) {};
|
|
||||||
|
|
||||||
///主次席资金同步通知
|
|
||||||
virtual void OnRtnTransferMoney(CUstpFtdcSyncMoneyTransferField *pSyncMoneyTransfer) {};
|
|
||||||
|
|
||||||
///系统时间查询应答
|
|
||||||
virtual void OnRspQrySystemTime(CUstpFtdcRspQrySystemTimeField *pRspQrySystemTime, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class TRADER_API_EXPORT CUstpFtdcTraderApi
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
///创建TraderApi
|
|
||||||
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
|
|
||||||
///@return 创建出的UserApi
|
|
||||||
static CUstpFtdcTraderApi *CreateFtdcTraderApi(const char *pszFlowPath = "");
|
|
||||||
|
|
||||||
///获取系统版本号
|
|
||||||
///@param nMajorVersion 主版本号
|
|
||||||
///@param nMinorVersion 子版本号
|
|
||||||
///@return 系统标识字符串
|
|
||||||
static const char *GetVersion(int &nMajorVersion, int &nMinorVersion);
|
|
||||||
|
|
||||||
///删除接口对象本身
|
|
||||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
|
||||||
virtual void Release() = 0;
|
|
||||||
|
|
||||||
///初始化
|
|
||||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
|
||||||
virtual void Init() = 0;
|
|
||||||
|
|
||||||
///等待接口线程结束运行
|
|
||||||
///@return 线程退出代码
|
|
||||||
virtual int Join() = 0;
|
|
||||||
|
|
||||||
///获取当前交易日
|
|
||||||
///@retrun 获取到的交易日
|
|
||||||
///@remark 只有登录成功后,才能得到正确的交易日
|
|
||||||
virtual const char *GetTradingDay() = 0;
|
|
||||||
|
|
||||||
///注册前置机网络地址
|
|
||||||
///@param pszFrontAddress:前置机网络地址。
|
|
||||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。
|
|
||||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
|
|
||||||
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
|
||||||
virtual void RegisterQryFront(char *pszFrontAddress) = 0;
|
|
||||||
|
|
||||||
///注册名字服务器网络地址
|
|
||||||
///@param pszNsAddress:名字服务器网络地址。
|
|
||||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。
|
|
||||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。
|
|
||||||
///@remark RegisterFront优先于RegisterNameServer
|
|
||||||
virtual void RegisterNameServer(char *pszNsAddress) = 0;
|
|
||||||
|
|
||||||
///注册回调接口
|
|
||||||
///@param pSpi 派生自回调接口类的实例
|
|
||||||
virtual void RegisterSpi(CUstpFtdcTraderSpi *pSpi) = 0;
|
|
||||||
|
|
||||||
///加载证书
|
|
||||||
///@param pszCertFileName 用户证书文件名
|
|
||||||
///@param pszKeyFileName 用户私钥文件名
|
|
||||||
///@param pszCaFileName 可信任CA证书文件名
|
|
||||||
///@param pszKeyFilePassword 用户私钥文件密码
|
|
||||||
///@return 0 操作成功
|
|
||||||
///@return -1 可信任CA证书载入失败
|
|
||||||
///@return -2 用户证书载入失败
|
|
||||||
///@return -3 用户私钥载入失败
|
|
||||||
///@return -4 用户证书校验失败
|
|
||||||
virtual int RegisterCertificateFile(const char *pszCertFileName, const char *pszKeyFileName,
|
|
||||||
const char *pszCaFileName, const char *pszKeyFilePassword) = 0;
|
|
||||||
|
|
||||||
///订阅私有流。
|
|
||||||
///@param nResumeType 私有流重传方式
|
|
||||||
/// USTP_TERT_RESTART:从本交易日开始重传
|
|
||||||
/// USTP_TERT_RESUME:从上次收到的续传
|
|
||||||
/// USTP_TERT_QUICK:只传送登录后私有流的内容
|
|
||||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到私有流的数据。
|
|
||||||
virtual void SubscribePrivateTopic(USTP_TE_RESUME_TYPE nResumeType) = 0;
|
|
||||||
|
|
||||||
///订阅公共流。
|
|
||||||
///@param nResumeType 公共流重传方式
|
|
||||||
/// USTP_TERT_RESTART:从本交易日开始重传
|
|
||||||
/// USTP_TERT_RESUME:从上次收到的续传
|
|
||||||
/// USTP_TERT_QUICK:只传送登录后公共流的内容
|
|
||||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到公共流的数据。
|
|
||||||
virtual void SubscribePublicTopic(USTP_TE_RESUME_TYPE nResumeType) = 0;
|
|
||||||
|
|
||||||
///订阅交易员流。
|
|
||||||
///@param nResumeType 交易员流重传方式
|
|
||||||
/// USTP_TERT_RESTART:从本交易日开始重传
|
|
||||||
/// USTP_TERT_RESUME:从上次收到的续传
|
|
||||||
/// USTP_TERT_QUICK:只传送登录后交易员流的内容
|
|
||||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到交易员流的数据。
|
|
||||||
virtual void SubscribeUserTopic(USTP_TE_RESUME_TYPE nResumeType) = 0;
|
|
||||||
|
|
||||||
///订阅询价流。
|
|
||||||
///@param nResumeType 交易员流重传方式
|
|
||||||
/// USTP_TERT_RESTART:从本交易日开始重传
|
|
||||||
/// USTP_TERT_RESUME:从上次收到的续传
|
|
||||||
/// USTP_TERT_QUICK:只传送登录后交易员流的内容
|
|
||||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到交易员流的数据。
|
|
||||||
virtual void SubscribeForQuote(USTP_TE_RESUME_TYPE nResumeType) = 0;
|
|
||||||
|
|
||||||
///设置心跳超时时间。
|
|
||||||
///@param timeout 心跳超时时间(秒)
|
|
||||||
virtual void SetHeartbeatTimeout(unsigned int timeout) = 0;
|
|
||||||
|
|
||||||
///打开请求日志文件
|
|
||||||
///@param pszReqLogFileName 请求日志文件名
|
|
||||||
///@return 0 操作成功
|
|
||||||
///@return -1 打开日志文件失败
|
|
||||||
virtual int OpenRequestLog(const char *pszReqLogFileName) = 0;
|
|
||||||
|
|
||||||
///打开应答日志文件
|
|
||||||
///@param pszRspLogFileName 应答日志文件名
|
|
||||||
///@return 0 操作成功
|
|
||||||
///@return -1 打开日志文件失败
|
|
||||||
virtual int OpenResponseLog(const char *pszRspLogFileName) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
///风控前置系统用户登录请求
|
|
||||||
virtual int ReqUserLogin(CUstpFtdcReqUserLoginField *pReqUserLogin, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///用户退出请求
|
|
||||||
virtual int ReqUserLogout(CUstpFtdcReqUserLogoutField *pReqUserLogout, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///用户密码修改请求
|
|
||||||
virtual int ReqUserPasswordUpdate(CUstpFtdcUserPasswordUpdateField *pUserPasswordUpdate, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///报单录入请求
|
|
||||||
virtual int ReqOrderInsert(CUstpFtdcInputOrderField *pInputOrder, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///报单操作请求
|
|
||||||
virtual int ReqOrderAction(CUstpFtdcOrderActionField *pOrderAction, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///请求报价录入
|
|
||||||
virtual int ReqQuoteInsert(CUstpFtdcInputQuoteField *pInputQuote, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///报价操作请求
|
|
||||||
virtual int ReqQuoteAction(CUstpFtdcQuoteActionField *pQuoteAction, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///客户询价请求
|
|
||||||
virtual int ReqForQuote(CUstpFtdcReqForQuoteField *pReqForQuote, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///客户申请组合请求
|
|
||||||
virtual int ReqMarginCombAction(CUstpFtdcInputMarginCombActionField *pInputMarginCombAction, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///用户请求出入金
|
|
||||||
virtual int ReqUserDeposit(CUstpFtdcstpUserDepositField *pstpUserDeposit, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///用户主次席出入金请求
|
|
||||||
virtual int ReqTransferMoney(CUstpFtdcstpTransferMoneyField *pstpTransferMoney, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///报单查询请求
|
|
||||||
virtual int ReqQryOrder(CUstpFtdcQryOrderField *pQryOrder, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///成交单查询请求
|
|
||||||
virtual int ReqQryTrade(CUstpFtdcQryTradeField *pQryTrade, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///可用投资者账户查询请求
|
|
||||||
virtual int ReqQryUserInvestor(CUstpFtdcQryUserInvestorField *pQryUserInvestor, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///交易编码查询请求
|
|
||||||
virtual int ReqQryTradingCode(CUstpFtdcQryTradingCodeField *pQryTradingCode, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///投资者资金账户查询请求
|
|
||||||
virtual int ReqQryInvestorAccount(CUstpFtdcQryInvestorAccountField *pQryInvestorAccount, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///合约查询请求
|
|
||||||
virtual int ReqQryInstrument(CUstpFtdcQryInstrumentField *pQryInstrument, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///交易所查询请求
|
|
||||||
virtual int ReqQryExchange(CUstpFtdcQryExchangeField *pQryExchange, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///投资者持仓查询请求
|
|
||||||
virtual int ReqQryInvestorPosition(CUstpFtdcQryInvestorPositionField *pQryInvestorPosition, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///合规参数查询请求
|
|
||||||
virtual int ReqQryComplianceParam(CUstpFtdcQryComplianceParamField *pQryComplianceParam, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///投资者手续费率查询请求
|
|
||||||
virtual int ReqQryInvestorFee(CUstpFtdcQryInvestorFeeField *pQryInvestorFee, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///投资者保证金率查询请求
|
|
||||||
virtual int ReqQryInvestorMargin(CUstpFtdcQryInvestorMarginField *pQryInvestorMargin, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///交易编码组合持仓查询请求
|
|
||||||
virtual int ReqQryInvestorCombPosition(CUstpFtdcQryInvestorCombPositionField *pQryInvestorCombPosition, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///交易编码单腿持仓查询请求
|
|
||||||
virtual int ReqQryInvestorLegPosition(CUstpFtdcQryInvestorLegPositionField *pQryInvestorLegPosition, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///查询合约组信息
|
|
||||||
virtual int ReqQryInstrumentGroup(CUstpFtdcQryUstpInstrumentGroupField *pQryUstpInstrumentGroup, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///查询组合保证金类型
|
|
||||||
virtual int ReqQryClientMarginCombType(CUstpFtdcQryClientMarginCombTypeField *pQryClientMarginCombType, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///行权录入请求
|
|
||||||
virtual int ReqExecOrderInsert(CUstpFtdcInputExecOrderField *pInputExecOrder, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///行权操作请求
|
|
||||||
virtual int ReqExecOrderAction(CUstpFtdcInputExecOrderActionField *pInputExecOrderAction, int nRequestID) = 0;
|
|
||||||
|
|
||||||
///查询系统时间
|
|
||||||
virtual int ReqQrySystemTime(CUstpFtdcReqQrySystemTimeField *pReqQrySystemTime, int nRequestID) = 0;
|
|
||||||
protected:
|
|
||||||
~CUstpFtdcTraderApi(){};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,865 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///@system 风控前置系统
|
|
||||||
///@company CFFEX
|
|
||||||
///@file USTPFtdcUserApiDataType.h
|
|
||||||
///@brief 定义了客户端接口使用的业务数据类型
|
|
||||||
///@history
|
|
||||||
///
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef USTP_FTDCDATATYPE_H
|
|
||||||
#define USTP_FTDCDATATYPE_H
|
|
||||||
|
|
||||||
enum USTP_TE_RESUME_TYPE
|
|
||||||
{
|
|
||||||
USTP_TERT_RESTART = 0,
|
|
||||||
USTP_TERT_RESUME,
|
|
||||||
USTP_TERT_QUICK
|
|
||||||
};
|
|
||||||
|
|
||||||
const int USTP_TSS_DIALOG = 1; //对话流
|
|
||||||
const int USTP_TSS_PRIVATE = 2; //客户私有流
|
|
||||||
const int USTP_TSS_PUBLIC = 3; //公共流
|
|
||||||
const int USTP_TSS_QUERY = 4; //查询
|
|
||||||
const int USTP_TSS_USER = 5; //用户私有流
|
|
||||||
const int USTP_TSS_QUOTE = 6; //询价流
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpPriceTickType是一个最小变动价位类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef double TUstpFtdcPriceTickType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpPriceType是一个价格类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef double TUstpFtdcPriceType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpRatioType是一个比率类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef double TUstpFtdcRatioType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpMoneyType是一个资金类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef double TUstpFtdcMoneyType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpLargeVolumeType是一个大额数量类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef double TUstpFtdcLargeVolumeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpSequenceNoType是一个序列号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcSequenceNoType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpMillisecType是一个最后修改毫秒类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcMillisecType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpVolumeType是一个数量类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcVolumeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpUnderlyingMultipleType是一个合约乘数类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcUnderlyingMultipleType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpVolumeMultipleType是一个数量乘数类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcVolumeMultipleType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpSequenceSeriesType是一个序列系列号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcSequenceSeriesType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpErrorIDType是一个错误代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcErrorIDType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpDataCenterIDType是一个数据中心代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcDataCenterIDType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpSettlementIDType是一个结算编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcSettlementIDType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpBusinessLocalIDType是一个本地业务标识类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcBusinessLocalIDType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpMeasureSecType是一个度量秒数类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcMeasureSecType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpSeatNoType是一个席位序号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcSeatNoType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpFileSizeType是一个文件大小类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcFileSizeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpFemasLifeCycleType是一个飞马生命周期号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcFemasLifeCycleType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpMonthType是一个月份类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcMonthType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpBoolType是一个布尔型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcBoolType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpYearType是一个年类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcYearType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpPriorityType是一个优先权类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcPriorityType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpMemTableNameType是一个内存表名类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcMemTableNameType[61];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOrderSysIDType是一个报单编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcOrderSysIDType[31];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTradeIDType是一个成交编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTradeIDType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpUserIDType是一个用户代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcUserIDType[16];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpParticipantIDType是一个会员编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcParticipantIDType[11];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpIPAddressType是一个IP地址类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcIPAddressType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpMacAddressType是一个Mac地址类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcMacAddressType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpInstrumentNameType是一个合约名称类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcInstrumentNameType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpInstrumentIDType是一个合约编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcInstrumentIDType[31];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpExchangeNameType是一个交易所名称类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcExchangeNameType[31];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpExchangeIDType是一个交易所代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcExchangeIDType[11];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpDateType是一个日期类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcDateType[9];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTimeType是一个时间类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTimeType[9];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpClientIDType是一个客户编码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcClientIDType[19];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpAccountIDType是一个资金帐号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcAccountIDType[13];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpSeatIDType是一个席位号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcSeatIDType[13];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpProductNameType是一个品种名称类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcProductNameType[41];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpUserOrderLocalIDType是一个用户本地报单号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcUserOrderLocalIDType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOrderLocalIDType是一个本地报单编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcOrderLocalIDType[13];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpInvestorIDType是一个投资者编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcInvestorIDType[19];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpUserNameType是一个用户编码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcUserNameType[31];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpPasswordType是一个密码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcPasswordType[41];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpProductInfoType是一个产品信息类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcProductInfoType[41];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpProtocolInfoType是一个协议信息类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcProtocolInfoType[41];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpBusinessUnitType是一个业务单元类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcBusinessUnitType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTradingSystemNameType是一个交易系统名称类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTradingSystemNameType[61];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpBrokerIDType是一个经纪公司代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcBrokerIDType[11];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpCustomType是一个用户自定义域类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcCustomType[65];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTradingDayType是一个交易日类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTradingDayType[9];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpDepartmentType是一个营业部类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcDepartmentType[41];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpProductIDType是一个品种编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcProductIDType[13];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpAccountSeqNoType是一个资金流水号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcAccountSeqNoType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpSettlementGroupIDType是一个结算组代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcSettlementGroupIDType[9];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpFemasVersionType是一个飞马版本号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcFemasVersionType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpBankIDType是一个银行机构代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcBankIDType[11];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpBankPasswdType是一个银行转账密码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcBankPasswdType[36];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpAccountPasswdType是一个主席转账密码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcAccountPasswdType[36];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTransBankIDType是一个银行代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTransBankIDType[10];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTransSerialType是一个发起方流水号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTransSerialType[34];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTransBankAccountType是一个银行账号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTransBankAccountType[34];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTransTradeCodeType是一个银期业务功能码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTransTradeCodeType[10];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpErrorMsgType是一个错误信息类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcErrorMsgType[81];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpAuthenticate2PasswordType是一个客户认证密码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcAuthenticate2PasswordType[41];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTerminalCodeType是一个开发厂商终端编码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcTerminalCodeType[41];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpVolumeConditionType是一个成交量类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///任何数量
|
|
||||||
#define USTP_FTDC_VC_AV '1'
|
|
||||||
///最小数量
|
|
||||||
#define USTP_FTDC_VC_MV '2'
|
|
||||||
///全部数量
|
|
||||||
#define USTP_FTDC_VC_CV '3'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcVolumeConditionType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpForceCloseReasonType是一个强平原因类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///非强平
|
|
||||||
#define USTP_FTDC_FCR_NotForceClose '0'
|
|
||||||
///资金不足
|
|
||||||
#define USTP_FTDC_FCR_LackDeposit '1'
|
|
||||||
///客户超仓
|
|
||||||
#define USTP_FTDC_FCR_ClientOverPositionLimit '2'
|
|
||||||
///会员超仓
|
|
||||||
#define USTP_FTDC_FCR_MemberOverPositionLimit '3'
|
|
||||||
///持仓非整数倍
|
|
||||||
#define USTP_FTDC_FCR_NotMultiple '4'
|
|
||||||
///违规
|
|
||||||
#define USTP_FTDC_FCR_Violation '5'
|
|
||||||
///其他
|
|
||||||
#define USTP_FTDC_FCR_Other '6'
|
|
||||||
///自然人临近交割
|
|
||||||
#define USTP_FTDC_FCR_PersonDeliv '7'
|
|
||||||
///客户套保超仓
|
|
||||||
#define USTP_FTDC_FCR_HedgeOverPositionLimit '8'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcForceCloseReasonType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpInstrumentStatusType是一个合约交易状态类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///开盘前
|
|
||||||
#define USTP_FTDC_IS_BeforeTrading '0'
|
|
||||||
///非交易
|
|
||||||
#define USTP_FTDC_IS_NoTrading '1'
|
|
||||||
///连续交易
|
|
||||||
#define USTP_FTDC_IS_Continous '2'
|
|
||||||
///集合竞价报单
|
|
||||||
#define USTP_FTDC_IS_AuctionOrdering '3'
|
|
||||||
///集合竞价价格平衡
|
|
||||||
#define USTP_FTDC_IS_AuctionBalance '4'
|
|
||||||
///集合竞价撮合
|
|
||||||
#define USTP_FTDC_IS_AuctionMatch '5'
|
|
||||||
///收盘
|
|
||||||
#define USTP_FTDC_IS_Closed '6'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcInstrumentStatusType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOffsetFlagType是一个开平标志类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///开仓
|
|
||||||
#define USTP_FTDC_OF_Open '0'
|
|
||||||
///平仓
|
|
||||||
#define USTP_FTDC_OF_Close '1'
|
|
||||||
///强平
|
|
||||||
#define USTP_FTDC_OF_ForceClose '2'
|
|
||||||
///平今
|
|
||||||
#define USTP_FTDC_OF_CloseToday '3'
|
|
||||||
///平昨
|
|
||||||
#define USTP_FTDC_OF_CloseYesterday '4'
|
|
||||||
///ALL
|
|
||||||
#define USTP_FTDC_OF_ALL '9'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcOffsetFlagType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOrderPriceTypeType是一个报单价格条件类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///任意价
|
|
||||||
#define USTP_FTDC_OPT_AnyPrice '1'
|
|
||||||
///限价
|
|
||||||
#define USTP_FTDC_OPT_LimitPrice '2'
|
|
||||||
///最优价
|
|
||||||
#define USTP_FTDC_OPT_BestPrice '3'
|
|
||||||
///五档价
|
|
||||||
#define USTP_FTDC_OPT_FiveLevelPrice '4'
|
|
||||||
///止损定单
|
|
||||||
#define USTP_FTDC_OPT_StopLosPrice '5'
|
|
||||||
///止盈定单
|
|
||||||
#define USTP_FTDC_OPT_StopProfitPrice '6'
|
|
||||||
///限价止损定单
|
|
||||||
#define USTP_FTDC_OPT_LimitStopLosPrice '7'
|
|
||||||
///限价止盈定单
|
|
||||||
#define USTP_FTDC_OPT_LimitStopProfitPrice '8'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcOrderPriceTypeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOrderStatusType是一个报单状态类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///全部成交
|
|
||||||
#define USTP_FTDC_OS_AllTraded '0'
|
|
||||||
///部分成交还在队列中
|
|
||||||
#define USTP_FTDC_OS_PartTradedQueueing '1'
|
|
||||||
///部分成交不在队列中
|
|
||||||
#define USTP_FTDC_OS_PartTradedNotQueueing '2'
|
|
||||||
///未成交还在队列中
|
|
||||||
#define USTP_FTDC_OS_NoTradeQueueing '3'
|
|
||||||
///未成交不在队列中
|
|
||||||
#define USTP_FTDC_OS_NoTradeNotQueueing '4'
|
|
||||||
///撤单
|
|
||||||
#define USTP_FTDC_OS_Canceled '5'
|
|
||||||
///订单已报入交易所未应答
|
|
||||||
#define USTP_FTDC_OS_AcceptedNoReply '6'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcOrderStatusType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpUserTypeType是一个用户类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///自然人
|
|
||||||
#define USTP_FTDC_UT_Person '1'
|
|
||||||
///理财产品
|
|
||||||
#define USTP_FTDC_UT_Product '2'
|
|
||||||
///期货公司管理员
|
|
||||||
#define USTP_FTDC_UT_Manager '3'
|
|
||||||
///席位
|
|
||||||
#define USTP_FTDC_UT_Seat '4'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcUserTypeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTradingRightType是一个交易权限类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///可以交易
|
|
||||||
#define USTP_FTDC_TR_Allow '0'
|
|
||||||
///只能平仓
|
|
||||||
#define USTP_FTDC_TR_CloseOnly '1'
|
|
||||||
///不能交易
|
|
||||||
#define USTP_FTDC_TR_Forbidden '2'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcTradingRightType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTimeConditionType是一个有效期类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///立即完成,否则撤销
|
|
||||||
#define USTP_FTDC_TC_IOC '1'
|
|
||||||
///本节有效
|
|
||||||
#define USTP_FTDC_TC_GFS '2'
|
|
||||||
///当日有效
|
|
||||||
#define USTP_FTDC_TC_GFD '3'
|
|
||||||
///指定日期前有效
|
|
||||||
#define USTP_FTDC_TC_GTD '4'
|
|
||||||
///撤销前有效
|
|
||||||
#define USTP_FTDC_TC_GTC '5'
|
|
||||||
///集合竞价有效
|
|
||||||
#define USTP_FTDC_TC_GFA '6'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcTimeConditionType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOrderSourceType是一个报单来源类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///来自参与者
|
|
||||||
#define USTP_FTDC_OS_Participant '0'
|
|
||||||
///来自管理员
|
|
||||||
#define USTP_FTDC_OS_Administrator '1'
|
|
||||||
///报价单拆分出来的买单或卖单
|
|
||||||
#define USTP_FTDC_OS_QuoteSplit '2'
|
|
||||||
///强减单
|
|
||||||
#define USTP_FTDC_OS_ForceLower '3'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcOrderSourceType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpDirectionType是一个买卖方向类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///买
|
|
||||||
#define USTP_FTDC_D_Buy '0'
|
|
||||||
///卖
|
|
||||||
#define USTP_FTDC_D_Sell '1'
|
|
||||||
///ALL
|
|
||||||
#define USTP_FTDC_D_ALL '9'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcDirectionType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpCurrencyType是一个币种类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///人民币
|
|
||||||
#define USTP_FTDC_C_RMB '1'
|
|
||||||
///美元
|
|
||||||
#define USTP_FTDC_C_UDOLLAR '2'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcCurrencyType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpAccountDirectionType是一个出入金方向类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///入金
|
|
||||||
#define USTP_FTDC_AD_In '1'
|
|
||||||
///出金
|
|
||||||
#define USTP_FTDC_AD_Out '2'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcAccountDirectionType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpSyncDirectionType是一个出入金通知类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///入金通知
|
|
||||||
#define USTP_FTDC_AD_In '1'
|
|
||||||
///出金通知
|
|
||||||
#define USTP_FTDC_AD_Out '2'
|
|
||||||
///入金冲销通知
|
|
||||||
#define USTP_FTDC_AD_InReserval '3'
|
|
||||||
///出金冲销通知
|
|
||||||
#define USTP_FTDC_AD_OutReserval '4'
|
|
||||||
///预出金通知
|
|
||||||
#define USTP_FTDC_AD_PreOut '5'
|
|
||||||
///预出金成功通知
|
|
||||||
#define USTP_FTDC_AD_PreOutSuccess '6'
|
|
||||||
///预出金失败通知
|
|
||||||
#define USTP_FTDC_AD_PreOutFailed '7'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcSyncDirectionType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpTradeSyncSourceType是一个同步请求发起方类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///终端
|
|
||||||
#define USTP_FTDC_TSS_Terminal '1'
|
|
||||||
///次席终端
|
|
||||||
#define USTP_FTDC_TSS_Terminal_Second '2'
|
|
||||||
///银行
|
|
||||||
#define USTP_FTDC_TSS_Bank '3'
|
|
||||||
///结算
|
|
||||||
#define USTP_FTDC_TSS_Settle '4'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcTradeSyncSourceType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpHedgeFlagType是一个投机套保标志类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///交易/投机
|
|
||||||
#define USTP_FTDC_CHF_Speculation '1'
|
|
||||||
///套利
|
|
||||||
#define USTP_FTDC_CHF_Arbitrage '2'
|
|
||||||
///套保
|
|
||||||
#define USTP_FTDC_CHF_Hedge '3'
|
|
||||||
///做市商
|
|
||||||
#define USTP_FTDC_CHF_MarketMaker '4'
|
|
||||||
///投机-套保
|
|
||||||
#define USTP_FTDC_CHF_SpecHedge '5'
|
|
||||||
///套保-投机
|
|
||||||
#define USTP_FTDC_CHF_HedgeSpec '6'
|
|
||||||
///匹配所有的值
|
|
||||||
#define USTP_FTDC_CHF_AllValue '9'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcHedgeFlagType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpActionFlagType是一个操作标志类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///删除
|
|
||||||
#define USTP_FTDC_AF_Delete '0'
|
|
||||||
///挂起
|
|
||||||
#define USTP_FTDC_AF_Suspend '1'
|
|
||||||
///激活
|
|
||||||
#define USTP_FTDC_AF_Active '2'
|
|
||||||
///修改
|
|
||||||
#define USTP_FTDC_AF_Modify '3'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcActionFlagType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpPositionTypeType是一个持仓类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///净持仓
|
|
||||||
#define USTP_FTDC_PT_Net '1'
|
|
||||||
///综合持仓
|
|
||||||
#define USTP_FTDC_PT_Gross '2'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcPositionTypeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOptionsTypeType是一个期权类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///非期权
|
|
||||||
#define USTP_FTDC_OT_NotOptions '0'
|
|
||||||
///看涨
|
|
||||||
#define USTP_FTDC_OT_CallOptions '1'
|
|
||||||
///看跌
|
|
||||||
#define USTP_FTDC_OT_PutOptions '2'
|
|
||||||
///全部
|
|
||||||
#define USTP_FTDC_OT_ALL '9'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcOptionsTypeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpIsActiveType是一个是否活跃类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///不活跃
|
|
||||||
#define USTP_FTDC_UIA_NoActive '0'
|
|
||||||
///活跃
|
|
||||||
#define USTP_FTDC_UIA_Active '1'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcIsActiveType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpCurrencyIDType是一个币种代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcCurrencyIDType[5];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpClientMarginCombTypeType是一个组合保证金类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///单腿保证金组合
|
|
||||||
#define USTP_FTDC_MCT_SingleLeg '0'
|
|
||||||
///合约组大边保证金组合
|
|
||||||
#define USTP_FTDC_MCT_BigLeg '1'
|
|
||||||
///手动策略保证金组合
|
|
||||||
#define USTP_FTDC_MCT_StrategyManual '2'
|
|
||||||
///自动策略保证金组合
|
|
||||||
#define USTP_FTDC_MCT_StrategyAuto '3'
|
|
||||||
///手动策略大边保证金组合
|
|
||||||
#define USTP_FTDC_MCT_StrategyBigLegManual '4'
|
|
||||||
///自动策略大边保证金组合
|
|
||||||
#define USTP_FTDC_MCT_StrategyBigLegAuto '5'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcClientMarginCombTypeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpInstrumentGroupIDType是一个合约组代码类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcInstrumentGroupIDType[31];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpQuoteSysIDType是一个报价编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcQuoteSysIDType[31];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpUserQuoteLocalIDType是一个用户本地报价编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcUserQuoteLocalIDType[21];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpQuoteLocalIDType是一个飞马本地报价编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef char TUstpFtdcQuoteLocalIDType[13];
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpGrantFuncSetType是一个授权功能号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///正常交易
|
|
||||||
#define USTP_FTDC_FUNC_Trading '0'
|
|
||||||
///只能平仓
|
|
||||||
#define USTP_FTDC_FUNC_CloseOnly '1'
|
|
||||||
///禁止交易
|
|
||||||
#define USTP_FTDC_FUNC_CanotTrade '2'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcGrantFuncSetType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpQuoteStatusType是一个报价单状态类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///在飞马中还未进入交易系统
|
|
||||||
#define USTP_FTDC_QS_Inited_InFEMAS '0'
|
|
||||||
///已经报入交易系统中
|
|
||||||
#define USTP_FTDC_QS_Accepted_InTradingSystem '1'
|
|
||||||
///已经撤掉单腿
|
|
||||||
#define USTP_FTDC_QS_Canceled_SingleLeg '2'
|
|
||||||
///已经全部撤掉
|
|
||||||
#define USTP_FTDC_QS_Canceled_All '3'
|
|
||||||
///已经有单腿成交
|
|
||||||
#define USTP_FTDC_QS_Traded_SingleLeg '4'
|
|
||||||
///已经全部成交
|
|
||||||
#define USTP_FTDC_QS_Traded_All '5'
|
|
||||||
///错误的撤消报价请求
|
|
||||||
#define USTP_FTDC_QS_Error_QuoteAction '6'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcQuoteStatusType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpLegMultipleType是一个单腿乘数类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcLegMultipleType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpLegIDType是一个单腿编号类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef int TUstpFtdcLegIDType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpCombDirectionType是一个申请保证金组合指令方向类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///申请组合
|
|
||||||
#define USTP_FTDC_CA_Combine '0'
|
|
||||||
///申请拆分组合
|
|
||||||
#define USTP_FTDC_CA_UnCombine '1'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcCombDirectionType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpArbiTypeType是一个策略类别类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///基本
|
|
||||||
#define USTP_FTDC_AT_Basic '0'
|
|
||||||
///跨期套利
|
|
||||||
#define USTP_FTDC_AT_SP '1'
|
|
||||||
///两腿跨品种套利
|
|
||||||
#define USTP_FTDC_AT_SPC '2'
|
|
||||||
///压榨套利
|
|
||||||
#define USTP_FTDC_AT_SPX '3'
|
|
||||||
///组合
|
|
||||||
#define USTP_FTDC_AT_Combo '4'
|
|
||||||
///批量
|
|
||||||
#define USTP_FTDC_AT_Strip '5'
|
|
||||||
///期权执行申请
|
|
||||||
#define USTP_FTDC_AT_Exec '6'
|
|
||||||
///双边报价
|
|
||||||
#define USTP_FTDC_AT_Both '7'
|
|
||||||
///互换
|
|
||||||
#define USTP_FTDC_AT_Swap '8'
|
|
||||||
///其他策略
|
|
||||||
#define USTP_FTDC_AT_Other '9'
|
|
||||||
///看涨期权垂直价差
|
|
||||||
#define USTP_FTDC_AT_BUL 'a'
|
|
||||||
///看跌期权垂直价差
|
|
||||||
#define USTP_FTDC_AT_BER 'b'
|
|
||||||
///看涨期权水平价差
|
|
||||||
#define USTP_FTDC_AT_BLT 'c'
|
|
||||||
///看跌期权水平价差
|
|
||||||
#define USTP_FTDC_AT_BRT 'd'
|
|
||||||
///跨式
|
|
||||||
#define USTP_FTDC_AT_STD 'e'
|
|
||||||
///宽跨式
|
|
||||||
#define USTP_FTDC_AT_STG 'f'
|
|
||||||
///备兑
|
|
||||||
#define USTP_FTDC_AT_PRT 'g'
|
|
||||||
///对锁
|
|
||||||
#define USTP_FTDC_AT_LOC 'h'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcArbiTypeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpOrderTypeType是一个委托类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///普通委托
|
|
||||||
#define USTP_FTDC_OT_Common '0'
|
|
||||||
///期权执行
|
|
||||||
#define USTP_FTDC_OT_OptExec '1'
|
|
||||||
///放弃执行
|
|
||||||
#define USTP_FTDC_OT_OptAbandon '2'
|
|
||||||
///OTC衍生
|
|
||||||
#define USTP_FTDC_OT_OTCDerived '3'
|
|
||||||
///期转现衍生
|
|
||||||
#define USTP_FTDC_OT_EFPDerived '4'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcOrderTypeType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpDeliveryFlagType是一个执行类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///不对冲
|
|
||||||
#define USTP_FTDC_DF_ExecOpen '0'
|
|
||||||
///对冲(期货)
|
|
||||||
#define USTP_FTDC_DF_Delivery '1'
|
|
||||||
///对冲(期权)
|
|
||||||
#define USTP_FTDC_DF_OptDelivery '2'
|
|
||||||
///保留持仓
|
|
||||||
#define USTP_FTDC_DF_OptHold '3'
|
|
||||||
///履约后对冲
|
|
||||||
#define USTP_FTDC_DF_SellDelivery '4'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcDeliveryFlagType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpCombActionStatusType是一个组合操作状态类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///已提交
|
|
||||||
#define USTP_FTDC_CAS_Submitted '1'
|
|
||||||
///已接收
|
|
||||||
#define USTP_FTDC_CAS_Accepted '2'
|
|
||||||
///已拒绝
|
|
||||||
#define USTP_FTDC_CAS_Rejected '3'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcCombActionStatusType;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///TFtdcUstpAuthenticate2TypeType是一个客户认证类型类型
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
///初始值,空,表示未设口令。即不需要进行口令验证
|
|
||||||
#define USTP_FTDC_A2T_Blank '0'
|
|
||||||
///短信验证码
|
|
||||||
#define USTP_FTDC_A2T_ShortMessage '1'
|
|
||||||
///动态令牌
|
|
||||||
#define USTP_FTDC_A2T_DynamicToken '2'
|
|
||||||
///图形验证码
|
|
||||||
#define USTP_FTDC_A2T_GraphicVerificationCode '3'
|
|
||||||
|
|
||||||
typedef char TUstpFtdcAuthenticate2TypeType;
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
@ -336,8 +336,10 @@ class ApiGenerator:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
md_generator = ApiGenerator("USTPFtdcMduserApi.h", "femas", "md", "MdApi")
|
md_generator = ApiGenerator(
|
||||||
|
"../include/femas/USTPFtdcMduserApi.h", "femas", "md", "MdApi")
|
||||||
md_generator.run()
|
md_generator.run()
|
||||||
|
|
||||||
td_generator = ApiGenerator("USTPFtdcTraderApi.h", "femas", "td", "TdApi")
|
td_generator = ApiGenerator(
|
||||||
|
"../include/femas/USTPFtdcTraderApi.h", "femas", "td", "TdApi")
|
||||||
td_generator.run()
|
td_generator.run()
|
@ -72,5 +72,6 @@ class DataTypeGenerator:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
generator = DataTypeGenerator("USTPFtdcUserApiDataType.h", "femas")
|
generator = DataTypeGenerator(
|
||||||
|
"../include/femas/USTPFtdcUserApiDataType.h", "femas")
|
||||||
generator.run()
|
generator.run()
|
@ -80,5 +80,6 @@ class StructGenerator:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
generator = StructGenerator("USTPFtdcUserApiStruct.h", "femas")
|
generator = StructGenerator(
|
||||||
|
"../include/femas/USTPFtdcUserApiStruct.h", "femas")
|
||||||
generator.run()
|
generator.run()
|
@ -1,173 +0,0 @@
|
|||||||
# encoding: UTF-8
|
|
||||||
# flake8: noqa
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import sys
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
|
||||||
|
|
||||||
from vnfemasmd import *
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def print_dict(d):
|
|
||||||
"""按照键值打印一个字典"""
|
|
||||||
for key,value in d.items():
|
|
||||||
print(key + ':' + str(value))
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def simple_log(func):
|
|
||||||
"""简单装饰器用于输出函数名"""
|
|
||||||
def wrapper(*args, **kw):
|
|
||||||
print("")
|
|
||||||
print(str(func.__name__))
|
|
||||||
return func(*args, **kw)
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
class TestMdApi(MdApi):
|
|
||||||
"""测试用实例"""
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def __init__(self):
|
|
||||||
"""Constructor"""
|
|
||||||
super(TestMdApi, self).__init__()
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onFrontConnected(self):
|
|
||||||
"""服务器连接"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onFrontDisconnected(self, n):
|
|
||||||
"""服务器断开"""
|
|
||||||
print(n)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onHeartBeatWarning(self, n):
|
|
||||||
"""心跳报警"""
|
|
||||||
print(n)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspError(self, error, n, last):
|
|
||||||
"""错误"""
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
@simple_log
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def onRspUserLogin(self, data, error, n, last):
|
|
||||||
"""登陆回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspUserLogout(self, data, error, n, last):
|
|
||||||
"""登出回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspSubMarketData(self, data, error, n, last):
|
|
||||||
"""订阅合约回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspUnSubMarketData(self, data, error, n, last):
|
|
||||||
"""退订合约回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRtnDepthMarketData(self, data):
|
|
||||||
"""行情推送"""
|
|
||||||
print_dict(data)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspQryTopic(self, data, error, n, last):
|
|
||||||
"""订阅合约回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspSubscribeTopic(self, data, error, n, last):
|
|
||||||
"""退订合约回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def main():
|
|
||||||
"""主测试函数,出现堵塞时可以考虑使用sleep"""
|
|
||||||
reqid = 0
|
|
||||||
|
|
||||||
# 创建Qt应用对象,用于事件循环
|
|
||||||
app = QtGui.QApplication(sys.argv)
|
|
||||||
|
|
||||||
# 创建API对象
|
|
||||||
api = TestMdApi()
|
|
||||||
|
|
||||||
# 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址
|
|
||||||
api.createFtdcMdApi('')
|
|
||||||
|
|
||||||
# 注册前置机地址
|
|
||||||
api.registerFront("tcp://118.126.16.229:17101")
|
|
||||||
|
|
||||||
# 初始化api,连接前置机
|
|
||||||
api.init()
|
|
||||||
sleep(0.5)
|
|
||||||
|
|
||||||
# 登陆
|
|
||||||
loginReq = {} # 创建一个空字典
|
|
||||||
loginReq['UserID'] = '' # 参数作为字典键值的方式传入
|
|
||||||
loginReq['Password'] = '' # 键名和C++中的结构体成员名对应
|
|
||||||
loginReq['BrokerID'] = ''
|
|
||||||
reqid = reqid + 1 # 请求数必须保持唯一性
|
|
||||||
i = api.reqUserLogin(loginReq, 1)
|
|
||||||
sleep(0.5)
|
|
||||||
|
|
||||||
## 登出,测试出错(无此功能)
|
|
||||||
#reqid = reqid + 1
|
|
||||||
#i = api.reqUserLogout({}, 1)
|
|
||||||
#sleep(0.5)
|
|
||||||
|
|
||||||
## 安全退出,测试通过
|
|
||||||
#i = api.exit()
|
|
||||||
|
|
||||||
## 获取交易日,目前输出为空
|
|
||||||
#day = api.getTradingDay()
|
|
||||||
#print 'Trading Day is:' + str(day)
|
|
||||||
#sleep(0.5)
|
|
||||||
|
|
||||||
## 订阅合约,测试通过
|
|
||||||
#i = api.subscribeMarketData('IF1505')
|
|
||||||
|
|
||||||
## 退订合约,测试通过
|
|
||||||
#i = api.unSubscribeMarketData('IF1505')
|
|
||||||
|
|
||||||
# 订阅询价,测试通过
|
|
||||||
#i = api.subscribeForQuoteRsp('IO1504-C-3900')
|
|
||||||
|
|
||||||
# 退订询价,测试通过
|
|
||||||
#i = api.unSubscribeForQuoteRsp('IO1504-C-3900')
|
|
||||||
|
|
||||||
# 连续运行,用于输出行情
|
|
||||||
app.exec_()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
@ -1,166 +0,0 @@
|
|||||||
# encoding: UTF-8
|
|
||||||
# flake8: noqa
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import sys
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
|
||||||
|
|
||||||
from vnfemastd import *
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def print_dict(d):
|
|
||||||
"""按照键值打印一个字典"""
|
|
||||||
for key,value in d.items():
|
|
||||||
print(key + ':' + str(value))
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def simple_log(func):
|
|
||||||
"""简单装饰器用于输出函数名"""
|
|
||||||
def wrapper(*args, **kw):
|
|
||||||
print("")
|
|
||||||
print(str(func.__name__))
|
|
||||||
return func(*args, **kw)
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
class TestTdApi(TdApi):
|
|
||||||
"""测试用实例"""
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def __init__(self):
|
|
||||||
"""Constructor"""
|
|
||||||
super(TestTdApi, self).__init__()
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onFrontConnected(self):
|
|
||||||
"""服务器连接"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onFrontDisconnected(self, n):
|
|
||||||
"""服务器断开"""
|
|
||||||
print(n)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onHeartBeatWarning(self, n):
|
|
||||||
"""心跳报警"""
|
|
||||||
print(n)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspError(self, error, n, last):
|
|
||||||
"""错误"""
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspUserLogin(self, data, error, n, last):
|
|
||||||
"""登陆回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
self.brokerID = data['BrokerID']
|
|
||||||
self.userID = data['UserID']
|
|
||||||
self.frontID = data['FrontID']
|
|
||||||
self.sessionID = data['SessionID']
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspUserLogout(self, data, error, n, last):
|
|
||||||
"""登出回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspQrySettlementInfo(self, data, error, n, last):
|
|
||||||
"""查询结算信息回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspSettlementInfoConfirm(self, data, error, n, last):
|
|
||||||
"""确认结算信息回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
@simple_log
|
|
||||||
def onRspQryInstrument(self, data, error, n, last):
|
|
||||||
"""查询合约回报"""
|
|
||||||
print_dict(data)
|
|
||||||
print_dict(error)
|
|
||||||
print(n)
|
|
||||||
print(last)
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
|
||||||
def main():
|
|
||||||
"""主测试函数,出现堵塞时可以考虑使用sleep"""
|
|
||||||
reqid = 0
|
|
||||||
|
|
||||||
# 创建Qt应用对象,用于事件循环
|
|
||||||
app = QtGui.QApplication(sys.argv)
|
|
||||||
|
|
||||||
# 创建API对象,测试通过
|
|
||||||
api = TestTdApi()
|
|
||||||
|
|
||||||
# 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址,测试通过
|
|
||||||
api.createFtdcTraderApi('')
|
|
||||||
|
|
||||||
# 设置数据流重传方式,测试通过
|
|
||||||
api.subscribePrivateTopic(1)
|
|
||||||
api.subscribePublicTopic(1)
|
|
||||||
api.subscribeUserTopic(1)
|
|
||||||
|
|
||||||
# 注册前置机地址,测试通过
|
|
||||||
api.registerFront("tcp://118.126.16.229:17111")
|
|
||||||
|
|
||||||
# 初始化api,连接前置机,测试通过
|
|
||||||
api.init()
|
|
||||||
sleep(2)
|
|
||||||
|
|
||||||
# 登陆,测试通过
|
|
||||||
loginReq = {} # 创建一个空字典
|
|
||||||
loginReq['UserID'] = '' # 参数作为字典键值的方式传入
|
|
||||||
loginReq['Password'] = '' # 键名和C++中的结构体成员名对应
|
|
||||||
loginReq['BrokerID'] = ''
|
|
||||||
reqid = reqid + 1 # 请求数必须保持唯一性
|
|
||||||
i = api.reqUserLogin(loginReq, reqid)
|
|
||||||
sleep(0.5)
|
|
||||||
|
|
||||||
## 查询合约, 测试通过
|
|
||||||
#reqid = reqid + 1
|
|
||||||
#i = api.reqQryInstrument({}, reqid)
|
|
||||||
|
|
||||||
## 查询结算, 测试通过
|
|
||||||
#req = {}
|
|
||||||
#req['BrokerID'] = api.brokerID
|
|
||||||
#req['InvestorID'] = api.userID
|
|
||||||
#reqid = reqid + 1
|
|
||||||
#i = api.reqQrySettlementInfo(req, reqid)
|
|
||||||
#sleep(0.5)
|
|
||||||
|
|
||||||
## 确认结算, 测试通过
|
|
||||||
#req = {}
|
|
||||||
#req['BrokerID'] = api.brokerID
|
|
||||||
#req['InvestorID'] = api.userID
|
|
||||||
#reqid = reqid + 1
|
|
||||||
#i = api.reqSettlementInfoConfirm(req, reqid)
|
|
||||||
#sleep(0.5)
|
|
||||||
|
|
||||||
|
|
||||||
# 连续运行
|
|
||||||
app.exec_()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
@ -717,7 +717,7 @@ public:
|
|||||||
|
|
||||||
PYBIND11_MODULE(vnfemasmd, m)
|
PYBIND11_MODULE(vnfemasmd, m)
|
||||||
{
|
{
|
||||||
class_<MdApi, PyMdApi> mdapi(m, "MdApi");
|
class_<MdApi, PyMdApi> mdapi(m, "MdApi", module_local());
|
||||||
mdapi
|
mdapi
|
||||||
.def(init<>())
|
.def(init<>())
|
||||||
.def("createFtdcMdApi", &MdApi::createFtdcMdApi)
|
.def("createFtdcMdApi", &MdApi::createFtdcMdApi)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<ProjectGuid>{F00054FF-282F-4826-848E-D58BFB9E9D9F}</ProjectGuid>
|
<ProjectGuid>{F00054FF-282F-4826-848E-D58BFB9E9D9F}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>vnfemasmd</RootNamespace>
|
<RootNamespace>vnfemasmd</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||||
<ProjectName>vnfemasmd</ProjectName>
|
<ProjectName>vnfemasmd</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
@ -95,10 +95,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Miniconda3\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
||||||
<ReferencePath>$(ReferencePath)</ReferencePath>
|
<ReferencePath>$(ReferencePath)</ReferencePath>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Miniconda3\include\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
@ -181,7 +181,7 @@
|
|||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>C:\ProgramData\VNConda\libs;C:\Users\Administrator\Documents\GitHub\vnpy\vnpy\api\femasctp\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>C:\Miniconda3\libs;$(SolutionDir)..\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>USTPmduserapiAF.lib;USTPtraderapiAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>USTPmduserapiAF.lib;USTPtraderapiAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -2451,14 +2451,11 @@ void TdApi::processRspQryInvestorAccount(Task *task)
|
|||||||
data["Margin"] = task_data->Margin;
|
data["Margin"] = task_data->Margin;
|
||||||
data["Premium"] = task_data->Premium;
|
data["Premium"] = task_data->Premium;
|
||||||
data["Risk"] = task_data->Risk;
|
data["Risk"] = task_data->Risk;
|
||||||
print("processRspQryInvestorAccount");
|
|
||||||
print(data["AccountID"]);
|
|
||||||
delete task->task_data;
|
delete task->task_data;
|
||||||
}
|
}
|
||||||
dict error;
|
dict error;
|
||||||
if (task->task_error)
|
if (task->task_error)
|
||||||
{
|
{
|
||||||
print("task->task_error");
|
|
||||||
CUstpFtdcRspInfoField *task_error = (CUstpFtdcRspInfoField*)task->task_error;
|
CUstpFtdcRspInfoField *task_error = (CUstpFtdcRspInfoField*)task->task_error;
|
||||||
error["ErrorID"] = task_error->ErrorID;
|
error["ErrorID"] = task_error->ErrorID;
|
||||||
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
|
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
|
||||||
@ -4237,7 +4234,7 @@ public:
|
|||||||
|
|
||||||
PYBIND11_MODULE(vnfemastd, m)
|
PYBIND11_MODULE(vnfemastd, m)
|
||||||
{
|
{
|
||||||
class_<TdApi, PyTdApi> TdApi(m, "TdApi");
|
class_<TdApi, PyTdApi> TdApi(m, "TdApi", module_local());
|
||||||
TdApi
|
TdApi
|
||||||
.def(init<>())
|
.def(init<>())
|
||||||
.def("createFtdcTraderApi", &TdApi::createFtdcTraderApi)
|
.def("createFtdcTraderApi", &TdApi::createFtdcTraderApi)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<ProjectGuid>{016732E6-5789-4F7C-9A1C-C46A249080CF}</ProjectGuid>
|
<ProjectGuid>{016732E6-5789-4F7C-9A1C-C46A249080CF}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>vnfemastd</RootNamespace>
|
<RootNamespace>vnfemastd</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||||
<ProjectName>vnfemastd</ProjectName>
|
<ProjectName>vnfemastd</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
@ -95,8 +95,8 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetExt>.pyd</TargetExt>
|
<TargetExt>.pyd</TargetExt>
|
||||||
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Miniconda3\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\femas;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Miniconda3\include\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)..\</OutDir>
|
<OutDir>$(SolutionDir)..\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
@ -178,7 +178,7 @@
|
|||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>C:\ProgramData\VNConda\libs;C:\Users\Administrator\Documents\GitHub\vnpy\vnpy\api\femasctp\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>C:\Miniconda3\libs;$(SolutionDir)..\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>USTPmduserapiAF.lib;USTPtraderapiAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>USTPmduserapiAF.lib;USTPtraderapiAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -30,7 +30,7 @@ from vnpy.api.femas import (
|
|||||||
USTP_FTDC_TC_GFD,
|
USTP_FTDC_TC_GFD,
|
||||||
USTP_FTDC_TC_IOC,
|
USTP_FTDC_TC_IOC,
|
||||||
USTP_FTDC_VC_AV,
|
USTP_FTDC_VC_AV,
|
||||||
USTP_FTDC_VC_CV,
|
USTP_FTDC_VC_CV
|
||||||
)
|
)
|
||||||
from vnpy.trader.constant import (
|
from vnpy.trader.constant import (
|
||||||
Direction,
|
Direction,
|
||||||
@ -39,6 +39,7 @@ from vnpy.trader.constant import (
|
|||||||
OptionType,
|
OptionType,
|
||||||
OrderType,
|
OrderType,
|
||||||
Status,
|
Status,
|
||||||
|
Product
|
||||||
)
|
)
|
||||||
from vnpy.trader.event import EVENT_TIMER
|
from vnpy.trader.event import EVENT_TIMER
|
||||||
from vnpy.trader.gateway import BaseGateway
|
from vnpy.trader.gateway import BaseGateway
|
||||||
@ -86,6 +87,12 @@ OFFSET_VT2FEMAS = {
|
|||||||
}
|
}
|
||||||
OFFSET_FEMAS2VT = {v: k for k, v in OFFSET_VT2FEMAS.items()}
|
OFFSET_FEMAS2VT = {v: k for k, v in OFFSET_VT2FEMAS.items()}
|
||||||
|
|
||||||
|
# PRODUCT_CTP2VT = {
|
||||||
|
# THOST_FTDC_PC_Futures: Product.FUTURES,
|
||||||
|
# THOST_FTDC_PC_Options: Product.OPTION,
|
||||||
|
# THOST_FTDC_PC_Combination: Product.SPREAD
|
||||||
|
# }
|
||||||
|
|
||||||
DIRECTION_FEMAS2VT = {v: k for k, v in DIRECTION_VT2FEMAS.items()}
|
DIRECTION_FEMAS2VT = {v: k for k, v in DIRECTION_VT2FEMAS.items()}
|
||||||
DIRECTION_FEMAS2VT[USTP_FTDC_PD_Long] = Direction.LONG
|
DIRECTION_FEMAS2VT[USTP_FTDC_PD_Long] = Direction.LONG
|
||||||
DIRECTION_FEMAS2VT[USTP_FTDC_PD_Short] = Direction.SHORT
|
DIRECTION_FEMAS2VT[USTP_FTDC_PD_Short] = Direction.SHORT
|
||||||
@ -237,16 +244,15 @@ class FemasMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
self.connect_status = False
|
self.connect_status = False
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"行情连接断开,原因{reason}")
|
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
"""
|
"""
|
||||||
Callback when user is logged in.
|
Callback when user is logged in.
|
||||||
"""
|
"""
|
||||||
if self.gateway.if_error_write_error("行情登录失败", error):
|
if self.gateway.if_error_write_error("行情服务器登录失败", error):
|
||||||
return
|
return
|
||||||
self.login_status = True
|
self.login_status = True
|
||||||
self.gateway.write_log("onRspUserLogin行情服务器登录成功")
|
|
||||||
self.gateway.write_log("行情服务器登录成功")
|
self.gateway.write_log("行情服务器登录成功")
|
||||||
|
|
||||||
for symbol in self.subscribed:
|
for symbol in self.subscribed:
|
||||||
@ -354,8 +360,8 @@ class FemasTdApi(TdApi):
|
|||||||
self.gateway = gateway
|
self.gateway = gateway
|
||||||
self.gateway_name = gateway.gateway_name
|
self.gateway_name = gateway.gateway_name
|
||||||
|
|
||||||
self.reqid = int(10e5)
|
self.reqid = 0
|
||||||
self.localID = int(10e5 + 8888)
|
self.localid = int(10e5 + 8888)
|
||||||
|
|
||||||
self.connect_status = False
|
self.connect_status = False
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
@ -373,7 +379,7 @@ class FemasTdApi(TdApi):
|
|||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = True
|
self.connect_status = True
|
||||||
self.gateway.write_log("onFrontConnected交易连接成功")
|
self.gateway.write_log("交易服务器连接成功")
|
||||||
|
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
@ -381,23 +387,23 @@ class FemasTdApi(TdApi):
|
|||||||
""""""
|
""""""
|
||||||
self.connect_status = False
|
self.connect_status = False
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"交易连接断开,原因{reason}")
|
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
if not error["ErrorID"]:
|
if not error["ErrorID"]:
|
||||||
if data["MaxOrderLocalID"]:
|
if data["MaxOrderLocalID"]:
|
||||||
self.localID = max(
|
self.localid = int(data["MaxOrderLocalID"])
|
||||||
self.localID, int(data["MaxOrderLocalID"])
|
|
||||||
) # 目前最大本地报单号
|
|
||||||
self.login_status = True
|
self.login_status = True
|
||||||
self.gateway.write_log("onRspUserLogin交易登录成功")
|
self.gateway.write_log("交易服务器登录成功")
|
||||||
|
|
||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqQryInstrument({}, self.reqid)
|
self.reqQryInstrument({}, self.reqid)
|
||||||
else:
|
else:
|
||||||
self.login_failed = True
|
self.login_failed = True
|
||||||
|
|
||||||
self.gateway.if_error_write_error("交易登录失败", error)
|
self.gateway.if_error_write_error("交易服务器登录失败", error)
|
||||||
|
|
||||||
def onRspOrderInsert(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspOrderInsert(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
""""""
|
""""""
|
||||||
@ -486,28 +492,41 @@ class FemasTdApi(TdApi):
|
|||||||
balance=data["PreBalance"],
|
balance=data["PreBalance"],
|
||||||
gateway_name=self.gateway_name,
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
# todo: check for error
|
|
||||||
self.gateway.on_account(account)
|
self.gateway.on_account(account)
|
||||||
|
|
||||||
def onRspQryInstrument(self, data: dict, error: dict, reqid: int, last: bool):
|
def onRspQryInstrument(self, data: dict, error: dict, reqid: int, last: bool):
|
||||||
"""
|
"""
|
||||||
Callback of instrument query.
|
Callback of instrument query.
|
||||||
"""
|
"""
|
||||||
|
# Femas gateway provides no ProductClass data, so need to determine
|
||||||
|
# product type using other logic.
|
||||||
|
option_type = OPTIONTYPE_FEMAS2VT.get(data["OptionsType"], None)
|
||||||
|
if option_type:
|
||||||
|
product = Product.OPTION
|
||||||
|
elif data["InstrumentID_2"]:
|
||||||
|
product = Product.SPREAD
|
||||||
|
else:
|
||||||
|
product = Product.FUTURES
|
||||||
|
|
||||||
contract = ContractData(
|
contract = ContractData(
|
||||||
product=data["ProductID"],
|
|
||||||
symbol=data["InstrumentID"],
|
symbol=data["InstrumentID"],
|
||||||
exchange=EXCHANGE_FEMAS2VT[data["ExchangeID"]],
|
exchange=EXCHANGE_FEMAS2VT[data["ExchangeID"]],
|
||||||
name=data["InstrumentName"],
|
name=data["InstrumentName"],
|
||||||
size=data["VolumeMultiple"],
|
size=data["VolumeMultiple"],
|
||||||
pricetick=data["PriceTick"],
|
pricetick=data["PriceTick"],
|
||||||
option_underlying=data["UnderlyingInstrID"],
|
product=product,
|
||||||
option_type=OPTIONTYPE_FEMAS2VT.get(data["OptionsType"], None),
|
gateway_name=self.gateway_name
|
||||||
option_strike=data["StrikePrice"],
|
|
||||||
option_expiry=datetime.strptime(data["ExpireDate"], "%Y%m%d"),
|
|
||||||
gateway_name=self.gateway_name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if product == Product.OPTION:
|
||||||
|
contract.option_underlying = data["UnderlyingInstrID"]
|
||||||
|
contract.option_type = OPTIONTYPE_FEMAS2VT.get(
|
||||||
|
data["OptionsType"], None)
|
||||||
|
contract.option_strike = data["StrikePrice"]
|
||||||
|
contract.option_expiry = datetime.strptime(
|
||||||
|
data["ExpireDate"], "%Y%m%d")
|
||||||
|
|
||||||
self.gateway.on_contract(contract)
|
self.gateway.on_contract(contract)
|
||||||
|
|
||||||
symbol_exchange_map[contract.symbol] = contract.exchange
|
symbol_exchange_map[contract.symbol] = contract.exchange
|
||||||
@ -522,7 +541,8 @@ class FemasTdApi(TdApi):
|
|||||||
Callback of order status update.
|
Callback of order status update.
|
||||||
"""
|
"""
|
||||||
# 更新最大报单编号
|
# 更新最大报单编号
|
||||||
self.localID = max(self.localID, int(data["UserOrderLocalID"])) # 检查并增加本地报单编号
|
self.localid = max(self.localid, int(
|
||||||
|
data["UserOrderLocalID"])) # 检查并增加本地报单编号
|
||||||
|
|
||||||
symbol = data["InstrumentID"]
|
symbol = data["InstrumentID"]
|
||||||
exchange = symbol_exchange_map.get(symbol, "")
|
exchange = symbol_exchange_map.get(symbol, "")
|
||||||
@ -617,8 +637,9 @@ class FemasTdApi(TdApi):
|
|||||||
"""
|
"""
|
||||||
Send new order.
|
Send new order.
|
||||||
"""
|
"""
|
||||||
self.localID += 1
|
self.localid += 1
|
||||||
strLocalID = str(self.localID).rjust(12, "0")
|
orderid = str(self.localid).rjust(12, "0")
|
||||||
|
|
||||||
femas_req = {
|
femas_req = {
|
||||||
"InstrumentID": req.symbol,
|
"InstrumentID": req.symbol,
|
||||||
"ExchangeID": str(req.exchange).split(".")[1],
|
"ExchangeID": str(req.exchange).split(".")[1],
|
||||||
@ -630,7 +651,7 @@ class FemasTdApi(TdApi):
|
|||||||
"OrderPriceType": ORDERTYPE_VT2FEMAS.get(req.type, ""),
|
"OrderPriceType": ORDERTYPE_VT2FEMAS.get(req.type, ""),
|
||||||
"Direction": DIRECTION_VT2FEMAS.get(req.direction, ""),
|
"Direction": DIRECTION_VT2FEMAS.get(req.direction, ""),
|
||||||
"OffsetFlag": OFFSET_VT2FEMAS.get(req.offset, ""),
|
"OffsetFlag": OFFSET_VT2FEMAS.get(req.offset, ""),
|
||||||
"UserOrderLocalID": strLocalID,
|
"UserOrderLocalID": orderid,
|
||||||
"HedgeFlag": USTP_FTDC_CHF_Speculation,
|
"HedgeFlag": USTP_FTDC_CHF_Speculation,
|
||||||
"ForceCloseReason": USTP_FTDC_FCR_NotForceClose,
|
"ForceCloseReason": USTP_FTDC_FCR_NotForceClose,
|
||||||
"IsAutoSuspend": 0,
|
"IsAutoSuspend": 0,
|
||||||
@ -651,8 +672,6 @@ class FemasTdApi(TdApi):
|
|||||||
self.reqid += 1
|
self.reqid += 1
|
||||||
self.reqOrderInsert(femas_req, self.reqid)
|
self.reqOrderInsert(femas_req, self.reqid)
|
||||||
|
|
||||||
orderid = femas_req["UserOrderLocalID"]
|
|
||||||
req.volume = femas_req["Volume"]
|
|
||||||
order = req.create_order_data(orderid, self.gateway_name)
|
order = req.create_order_data(orderid, self.gateway_name)
|
||||||
self.gateway.on_order(order)
|
self.gateway.on_order(order)
|
||||||
|
|
||||||
@ -662,13 +681,14 @@ class FemasTdApi(TdApi):
|
|||||||
"""
|
"""
|
||||||
Cancel existing order.
|
Cancel existing order.
|
||||||
"""
|
"""
|
||||||
self.localID += 1
|
self.localid += 1
|
||||||
strLocalID = str(self.localID)
|
orderid = str(self.localid).rjust(12, "0")
|
||||||
|
|
||||||
femas_req = {
|
femas_req = {
|
||||||
"InstrumentID": req.symbol,
|
"InstrumentID": req.symbol,
|
||||||
"ExchangeID": str(req.exchange).split(".")[1],
|
"ExchangeID": str(req.exchange).split(".")[1],
|
||||||
"UserOrderLocalID": req.orderid,
|
"UserOrderLocalID": req.orderid,
|
||||||
"UserOrderActionLocalID": strLocalID,
|
"UserOrderActionLocalID": orderid,
|
||||||
"ActionFlag": USTP_FTDC_AF_Delete,
|
"ActionFlag": USTP_FTDC_AF_Delete,
|
||||||
"BrokerID": self.brokerid,
|
"BrokerID": self.brokerid,
|
||||||
"InvestorID": self.userid,
|
"InvestorID": self.userid,
|
||||||
|
Loading…
Reference in New Issue
Block a user