562 lines
18 KiB
C
562 lines
18 KiB
C
|
//˵<><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
//ϵͳ
|
|||
|
#include "stdafx.h"
|
|||
|
#include <string>
|
|||
|
#include <queue>
|
|||
|
|
|||
|
//Boost
|
|||
|
#define BOOST_PYTHON_STATIC_LIB
|
|||
|
#include <boost/python/module.hpp> //python<6F><6E>װ
|
|||
|
#include <boost/python/def.hpp> //python<6F><6E>װ
|
|||
|
#include <boost/python/dict.hpp> //python<6F><6E>װ
|
|||
|
#include <boost/python/object.hpp> //python<6F><6E>װ
|
|||
|
#include <boost/python.hpp> //python<6F><6E>װ
|
|||
|
#include <boost/thread.hpp> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>̹߳<DFB3><CCB9><EFBFBD>
|
|||
|
#include <boost/bind.hpp> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>̹߳<DFB3><CCB9><EFBFBD>
|
|||
|
#include <boost/any.hpp> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
|||
|
|
|||
|
//API
|
|||
|
#include "SecurityFtdcTraderApi.h"
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
|
|||
|
using namespace std;
|
|||
|
using namespace boost::python;
|
|||
|
using namespace boost;
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
#define ONFRONTCONNECTED 1
|
|||
|
#define ONFRONTDISCONNECTED 2
|
|||
|
#define ONHEARTBEATWARNING 3
|
|||
|
#define ONRSPERROR 4
|
|||
|
#define ONRSPUSERLOGIN 5
|
|||
|
#define ONRSPUSERLOGOUT 6
|
|||
|
#define ONRSPORDERINSERT 7
|
|||
|
#define ONRSPORDERACTION 8
|
|||
|
#define ONRSPUSERPASSWORDUPDATE 9
|
|||
|
#define ONRSPTRADINGACCOUNTPASSWORDUPDATE 10
|
|||
|
#define ONRSPQRYEXCHANGE 11
|
|||
|
#define ONRSPQRYINSTRUMENT 12
|
|||
|
#define ONRSPQRYINVESTOR 13
|
|||
|
#define ONRSPQRYTRADINGCODE 14
|
|||
|
#define ONRSPQRYTRADINGACCOUNT 15
|
|||
|
#define ONRSPQRYDEPTHMARKETDATA 16
|
|||
|
#define ONRSPQRYBONDINTEREST 17
|
|||
|
#define ONRSPQRYMARKETRATIONINFO 18
|
|||
|
#define ONRSPQRYINSTRUMENTCOMMISSIONRATE 19
|
|||
|
#define ONRSPQRYETFINSTRUMENT 20
|
|||
|
#define ONRSPQRYETFBASKET 21
|
|||
|
#define ONRSPQRYOFINSTRUMENT 22
|
|||
|
#define ONRSPQRYSFINSTRUMENT 23
|
|||
|
#define ONRSPQRYORDER 24
|
|||
|
#define ONRSPQRYTRADE 25
|
|||
|
#define ONRSPQRYINVESTORPOSITION 26
|
|||
|
#define ONRTNORDER 27
|
|||
|
#define ONRTNTRADE 28
|
|||
|
#define ONERRRTNORDERINSERT 29
|
|||
|
#define ONERRRTNORDERACTION 30
|
|||
|
#define ONRSPFUNDOUTBYLIBER 31
|
|||
|
#define ONRTNFUNDOUTBYLIBER 32
|
|||
|
#define ONERRRTNFUNDOUTBYLIBER 33
|
|||
|
#define ONRTNFUNDINBYBANK 34
|
|||
|
#define ONRSPQRYFUNDTRANSFERSERIAL 35
|
|||
|
#define ONRSPFUNDINTERTRANSFER 36
|
|||
|
#define ONRSPQRYFUNDINTERTRANSFERSERIAL 37
|
|||
|
#define ONRTNFUNDINTERTRANSFERSERIAL 38
|
|||
|
#define ONERRRTNFUNDINTERTRANSFER 39
|
|||
|
|
|||
|
|
|||
|
///-------------------------------------------------------------------------------------
|
|||
|
///API<50>еIJ<D0B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
///-------------------------------------------------------------------------------------
|
|||
|
|
|||
|
//GILȫ<4C><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ã<EFBFBD>
|
|||
|
//<2F><><EFBFBD>ڰ<EFBFBD><DAB0><EFBFBD>C++<2B>̻߳<DFB3><CCBB><EFBFBD>GIL<49><4C><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ֹpython<6F><6E><EFBFBD><EFBFBD>
|
|||
|
class PyLock
|
|||
|
{
|
|||
|
private:
|
|||
|
PyGILState_STATE gil_state;
|
|||
|
|
|||
|
public:
|
|||
|
//<2F><>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GIL<49><4C>
|
|||
|
PyLock()
|
|||
|
{
|
|||
|
gil_state = PyGILState_Ensure();
|
|||
|
}
|
|||
|
|
|||
|
//<2F><>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD>ٸö<D9B8><C3B6><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GIL<49><4C>
|
|||
|
~PyLock()
|
|||
|
{
|
|||
|
PyGILState_Release(gil_state);
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|||
|
struct Task
|
|||
|
{
|
|||
|
int task_name; //<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>Ӧ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
|||
|
any task_data; //<2F><><EFBFBD>ݽṹ<DDBD><E1B9B9>
|
|||
|
any task_error; //<2F><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|||
|
int task_id; //<2F><><EFBFBD><EFBFBD>id
|
|||
|
bool task_last; //<2F>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
///<2F>̰߳<DFB3>ȫ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
template<typename Data>
|
|||
|
|
|||
|
class ConcurrentQueue
|
|||
|
{
|
|||
|
private:
|
|||
|
queue<Data> the_queue; //<2F><><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
mutable mutex the_mutex; //boost<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
condition_variable the_condition_variable; //boost<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
public:
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void push(Data const& data)
|
|||
|
{
|
|||
|
mutex::scoped_lock lock(the_mutex); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
the_queue.push(data); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
lock.unlock(); //<2F>ͷ<EFBFBD><CDB7><EFBFBD>
|
|||
|
the_condition_variable.notify_one(); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>߳<EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>
|
|||
|
bool empty() const
|
|||
|
{
|
|||
|
mutex::scoped_lock lock(the_mutex);
|
|||
|
return the_queue.empty();
|
|||
|
}
|
|||
|
|
|||
|
//ȡ<><C8A1>
|
|||
|
Data wait_and_pop()
|
|||
|
{
|
|||
|
mutex::scoped_lock lock(the_mutex);
|
|||
|
|
|||
|
while (the_queue.empty()) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʱ
|
|||
|
{
|
|||
|
the_condition_variable.wait(lock); //<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ
|
|||
|
}
|
|||
|
|
|||
|
Data popped_value = the_queue.front(); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
the_queue.pop(); //ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
return popped_value; //<2F><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD>ֵ<EFBFBD><D6B5>л<EFBFBD>ȡij<C8A1><C4B3><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
|||
|
void getInt(dict d, string key, int* value);
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD>ֵ<EFBFBD><D6B5>л<EFBFBD>ȡij<C8A1><C4B3><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ӧ<EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
|||
|
void getDouble(dict d, string key, double* value);
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD>ֵ<EFBFBD><D6B5>л<EFBFBD>ȡij<C8A1><C4B3><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ӧ<EFBFBD><D3A6><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
|||
|
void getChar(dict d, string key, char* value);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
///-------------------------------------------------------------------------------------
|
|||
|
///C++ SPI<50>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
|||
|
///-------------------------------------------------------------------------------------
|
|||
|
|
|||
|
//API<50>ļ̳<C4BC>ʵ<EFBFBD><CAB5>
|
|||
|
class TdApi : public CSecurityFtdcTraderSpi
|
|||
|
{
|
|||
|
private:
|
|||
|
CSecurityFtdcTraderApi* api; //API<50><49><EFBFBD><EFBFBD>
|
|||
|
thread *task_thread; //<2F><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>ָ<EFBFBD>루<EFBFBD><EBA3A8>python<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>
|
|||
|
ConcurrentQueue<Task> task_queue; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
public:
|
|||
|
TdApi()
|
|||
|
{
|
|||
|
function0<void> f = boost::bind(&TdApi::processTask, this);
|
|||
|
thread t(f);
|
|||
|
this->task_thread = &t;
|
|||
|
};
|
|||
|
|
|||
|
~TdApi()
|
|||
|
{
|
|||
|
};
|
|||
|
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
//API<50>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
|
|||
|
///<2F><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>뽻<EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>¼ǰ<C2BC><C7B0><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
virtual void OnFrontConnected();
|
|||
|
|
|||
|
///<2F><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>뽻<EFBFBD><EFBFBD>̨ͨ<CCA8><CDA8><EFBFBD><EFBFBD><EFBFBD>ӶϿ<D3B6>ʱ<EFBFBD><CAB1><EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD><C3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>API<50><49><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3>ͻ<EFBFBD><CDBB>˿ɲ<CBBF><C9B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
///@param nReason <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|||
|
/// 0x1001 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
|||
|
/// 0x1002 <20><><EFBFBD><EFBFBD>дʧ<D0B4><CAA7>
|
|||
|
/// 0x2001 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|||
|
/// 0x2002 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
|||
|
/// 0x2003 <20>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
virtual void OnFrontDisconnected(int nReason);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>档<EFBFBD><E6A1A3><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>δ<EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
///@param nTimeLapse <20><><EFBFBD><EFBFBD><EFBFBD>ϴν<CFB4><CEBD>ձ<EFBFBD><D5B1>ĵ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
virtual void OnHeartBeatWarning(int nTimeLapse);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
|
|||
|
virtual void OnRspError(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspUserLogin(CSecurityFtdcRspUserLoginField *pRspUserLogin, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F>dz<EFBFBD><C7B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspOrderInsert(CSecurityFtdcInputOrderField *pInputOrder, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspOrderAction(CSecurityFtdcInputOrderActionField *pInputOrderAction, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspUserPasswordUpdate(CSecurityFtdcUserPasswordUpdateField *pUserPasswordUpdate, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F>ʽ<EFBFBD><CABD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspTradingAccountPasswordUpdate(CSecurityFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryExchange(CSecurityFtdcExchangeField *pExchange, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Լ<EFBFBD><D4BC>Ӧ
|
|||
|
virtual void OnRspQryInstrument(CSecurityFtdcInstrumentField *pInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯͶ<D1AF><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryInvestor(CSecurityFtdcInvestorField *pInvestor, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD>ױ<EFBFBD><D7B1><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryTradingCode(CSecurityFtdcTradingCodeField *pTradingCode, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>ʽ<EFBFBD><CABD>˻<EFBFBD><CBBB><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryTradingAccount(CSecurityFtdcTradingAccountField *pTradingAccount, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryDepthMarketData(CSecurityFtdcDepthMarketDataField *pDepthMarketData, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯծȯ<D5AE><C8AF>Ϣ<EFBFBD><CFA2>Ӧ
|
|||
|
virtual void OnRspQryBondInterest(CSecurityFtdcBondInterestField *pBondInterest, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>Ӧ
|
|||
|
virtual void OnRspQryMarketRationInfo(CSecurityFtdcMarketRationInfoField *pMarketRationInfo, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryInstrumentCommissionRate(CSecurityFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯETF<54><46>Լ<EFBFBD><D4BC>Ӧ
|
|||
|
virtual void OnRspQryETFInstrument(CSecurityFtdcETFInstrumentField *pETFInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯETF<54><46>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryETFBasket(CSecurityFtdcETFBasketField *pETFBasket, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯOF<4F><46>Լ<EFBFBD><D4BC>Ӧ
|
|||
|
virtual void OnRspQryOFInstrument(CSecurityFtdcOFInstrumentField *pOFInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯSF<53><46>Լ<EFBFBD><D4BC>Ӧ
|
|||
|
virtual void OnRspQrySFInstrument(CSecurityFtdcSFInstrumentField *pSFInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryOrder(CSecurityFtdcOrderField *pOrder, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryTrade(CSecurityFtdcTradeField *pTrade, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯͶ<D1AF><CDB6><EFBFBD>ֲ߳<DFB3><D6B2><EFBFBD>Ӧ
|
|||
|
virtual void OnRspQryInvestorPosition(CSecurityFtdcInvestorPositionField *pInvestorPosition, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD>֪ͨ
|
|||
|
virtual void OnRtnOrder(CSecurityFtdcOrderField *pOrder);
|
|||
|
|
|||
|
///<2F>ɽ<EFBFBD>֪ͨ
|
|||
|
virtual void OnRtnTrade(CSecurityFtdcTradeField *pTrade);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
|||
|
virtual void OnErrRtnOrderInsert(CSecurityFtdcInputOrderField *pInputOrder, CSecurityFtdcRspInfoField *pRspInfo);
|
|||
|
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
|||
|
virtual void OnErrRtnOrderAction(CSecurityFtdcOrderActionField *pOrderAction, CSecurityFtdcRspInfoField *pRspInfo);
|
|||
|
|
|||
|
///Liber<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
|
|||
|
virtual void OnRspFundOutByLiber(CSecurityFtdcInputFundTransferField *pInputFundTransfer, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///Liber<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ
|
|||
|
virtual void OnRtnFundOutByLiber(CSecurityFtdcFundTransferField *pFundTransfer);
|
|||
|
|
|||
|
///Liber<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
|||
|
virtual void OnErrRtnFundOutByLiber(CSecurityFtdcInputFundTransferField *pInputFundTransfer, CSecurityFtdcRspInfoField *pRspInfo);
|
|||
|
|
|||
|
///<2F><><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ
|
|||
|
virtual void OnRtnFundInByBank(CSecurityFtdcFundTransferField *pFundTransfer);
|
|||
|
|
|||
|
///<2F>ʽ<EFBFBD>ת<EFBFBD>˲<EFBFBD>ѯӦ<D1AF><D3A6>
|
|||
|
virtual void OnRspQryFundTransferSerial(CSecurityFtdcFundTransferField *pFundTransfer, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F>ʽ<EFBFBD><CABD><EFBFBD>תӦ<D7AA><D3A6>
|
|||
|
virtual void OnRspFundInterTransfer(CSecurityFtdcFundInterTransferField *pFundInterTransfer, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F>ʽ<EFBFBD><CABD><EFBFBD>ת<EFBFBD><D7AA>ˮ<EFBFBD><CBAE>ѯӦ<D1AF><D3A6>
|
|||
|
virtual void OnRspQryFundInterTransferSerial(CSecurityFtdcFundInterTransferSerialField *pFundInterTransferSerial, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
|
|||
|
|
|||
|
///<2F>ʽ<EFBFBD><CABD><EFBFBD>ת<EFBFBD><D7AA>ˮ֪ͨ
|
|||
|
virtual void OnRtnFundInterTransferSerial(CSecurityFtdcFundInterTransferSerialField *pFundInterTransferSerial);
|
|||
|
|
|||
|
///<2F>ʽ<EFBFBD><CABD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
|||
|
virtual void OnErrRtnFundInterTransfer(CSecurityFtdcFundInterTransferField *pFundInterTransfer, CSecurityFtdcRspInfoField *pRspInfo);
|
|||
|
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
//task<73><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
|
|||
|
void processTask();
|
|||
|
|
|||
|
void processFrontConnected(Task task);
|
|||
|
|
|||
|
void processFrontDisconnected(Task task);
|
|||
|
|
|||
|
void processHeartBeatWarning(Task task);
|
|||
|
|
|||
|
void processRspError(Task task);
|
|||
|
|
|||
|
void processRspUserLogin(Task task);
|
|||
|
|
|||
|
void processRspUserLogout(Task task);
|
|||
|
|
|||
|
void processRspOrderInsert(Task task);
|
|||
|
|
|||
|
void processRspOrderAction(Task task);
|
|||
|
|
|||
|
void processRspUserPasswordUpdate(Task task);
|
|||
|
|
|||
|
void processRspTradingAccountPasswordUpdate(Task task);
|
|||
|
|
|||
|
void processRspQryExchange(Task task);
|
|||
|
|
|||
|
void processRspQryInstrument(Task task);
|
|||
|
|
|||
|
void processRspQryInvestor(Task task);
|
|||
|
|
|||
|
void processRspQryTradingCode(Task task);
|
|||
|
|
|||
|
void processRspQryTradingAccount(Task task);
|
|||
|
|
|||
|
void processRspQryDepthMarketData(Task task);
|
|||
|
|
|||
|
void processRspQryBondInterest(Task task);
|
|||
|
|
|||
|
void processRspQryMarketRationInfo(Task task);
|
|||
|
|
|||
|
void processRspQryInstrumentCommissionRate(Task task);
|
|||
|
|
|||
|
void processRspQryETFInstrument(Task task);
|
|||
|
|
|||
|
void processRspQryETFBasket(Task task);
|
|||
|
|
|||
|
void processRspQryOFInstrument(Task task);
|
|||
|
|
|||
|
void processRspQrySFInstrument(Task task);
|
|||
|
|
|||
|
void processRspQryOrder(Task task);
|
|||
|
|
|||
|
void processRspQryTrade(Task task);
|
|||
|
|
|||
|
void processRspQryInvestorPosition(Task task);
|
|||
|
|
|||
|
void processRtnOrder(Task task);
|
|||
|
|
|||
|
void processRtnTrade(Task task);
|
|||
|
|
|||
|
void processErrRtnOrderInsert(Task task);
|
|||
|
|
|||
|
void processErrRtnOrderAction(Task task);
|
|||
|
|
|||
|
void processRspFundOutByLiber(Task task);
|
|||
|
|
|||
|
void processRtnFundOutByLiber(Task task);
|
|||
|
|
|||
|
void processErrRtnFundOutByLiber(Task task);
|
|||
|
|
|||
|
void processRtnFundInByBank(Task task);
|
|||
|
|
|||
|
void processRspQryFundTransferSerial(Task task);
|
|||
|
|
|||
|
void processRspFundInterTransfer(Task task);
|
|||
|
|
|||
|
void processRspQryFundInterTransferSerial(Task task);
|
|||
|
|
|||
|
void processRtnFundInterTransferSerial(Task task);
|
|||
|
|
|||
|
void processErrRtnFundInterTransfer(Task task);
|
|||
|
|
|||
|
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
//data<74><61><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>
|
|||
|
//error<6F><72><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ֵ<EFBFBD>
|
|||
|
//id<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id
|
|||
|
//last<73><74><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|||
|
//i<><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
|
|||
|
virtual void onFrontConnected(){};
|
|||
|
|
|||
|
virtual void onFrontDisconnected(int i){};
|
|||
|
|
|||
|
virtual void onHeartBeatWarning(int i){};
|
|||
|
|
|||
|
virtual void onRspError(dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspUserLogin(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspUserLogout(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspOrderInsert(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspOrderAction(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspUserPasswordUpdate(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspTradingAccountPasswordUpdate(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryExchange(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryInstrument(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryInvestor(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryTradingCode(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryTradingAccount(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryDepthMarketData(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryBondInterest(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryMarketRationInfo(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryInstrumentCommissionRate(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryETFInstrument(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryETFBasket(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryOFInstrument(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQrySFInstrument(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryOrder(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryTrade(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryInvestorPosition(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRtnOrder(dict data) {};
|
|||
|
|
|||
|
virtual void onRtnTrade(dict data) {};
|
|||
|
|
|||
|
virtual void onErrRtnOrderInsert(dict data, dict error) {};
|
|||
|
|
|||
|
virtual void onErrRtnOrderAction(dict data, dict error) {};
|
|||
|
|
|||
|
virtual void onRspFundOutByLiber(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRtnFundOutByLiber(dict data) {};
|
|||
|
|
|||
|
virtual void onErrRtnFundOutByLiber(dict data, dict error) {};
|
|||
|
|
|||
|
virtual void onRtnFundInByBank(dict data) {};
|
|||
|
|
|||
|
virtual void onRspQryFundTransferSerial(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspFundInterTransfer(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRspQryFundInterTransferSerial(dict data, dict error, int id, bool last) {};
|
|||
|
|
|||
|
virtual void onRtnFundInterTransferSerial(dict data) {};
|
|||
|
|
|||
|
virtual void onErrRtnFundInterTransfer(dict data, dict error) {};
|
|||
|
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
//req:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>
|
|||
|
//-------------------------------------------------------------------------------------
|
|||
|
|
|||
|
void createFtdcTraderApi(string pszFlowPath = "");
|
|||
|
|
|||
|
void release();
|
|||
|
|
|||
|
void init();
|
|||
|
|
|||
|
int join();
|
|||
|
|
|||
|
int exit();
|
|||
|
|
|||
|
string getTradingDay();
|
|||
|
|
|||
|
void registerFront(string pszFrontAddress);
|
|||
|
|
|||
|
void subscribePrivateTopic(int nType);
|
|||
|
|
|||
|
void subscribePublicTopic(int nType);
|
|||
|
|
|||
|
int reqUserLogin(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqUserLogout(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqOrderInsert(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqOrderAction(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqUserPasswordUpdate(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqTradingAccountPasswordUpdate(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryExchange(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryInstrument(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryInvestor(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryTradingCode(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryTradingAccount(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryDepthMarketData(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryBondInterest(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryMarketRationInfo(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryInstrumentCommissionRate(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryETFInstrument(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryETFBasket(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryOFInstrument(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQrySFInstrument(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryOrder(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryTrade(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryInvestorPosition(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqFundOutByLiber(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryFundTransferSerial(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqFundInterTransfer(dict req, int nRequestID);
|
|||
|
|
|||
|
int reqQryFundInterTransferSerial(dict req, int nRequestID);
|
|||
|
};
|