コード例 #1
0
        public void Initialize()
        {
            _api             = new TradeApi(_brokerID, _frontAddr);
            _api.OnRspError += new TradeApi.RspError((ref CThostFtdcRspInfoField pRspInfo, int nRequestID, byte bIsLast) =>
            {
                Console.WriteLine("ErrorID: {0}, ErrorMsg: {1}", pRspInfo.ErrorID, pRspInfo.ErrorMsg);
            });
            _api.OnFrontConnect += new TradeApi.FrontConnect(() =>
            {
                _isConnected = true;
                _api.UserLogin(-3, _investorID, _password);
            });
            _api.OnRspUserLogin += new TradeApi.RspUserLogin((ref CThostFtdcRspUserLoginField pRspUserLogin,
                                                              ref CThostFtdcRspInfoField pRspInfo, int nRequestID, byte bIsLast) =>
            {
                _isLogin = true;
                _api.SettlementInfoConfirm(-4);
            });
            _api.OnDisconnected += new TradeApi.Disconnected((int nReasion) =>
            {
                _isConnected = false;
            });
            _api.OnRspUserLogout += new TradeApi.RspUserLogout((ref CThostFtdcUserLogoutField pUserLogout,
                                                                ref CThostFtdcRspInfoField pRspInfo, int nRequestID, byte bIsLast) =>
            {
                _isLogin = false;
                _api.Disconnect();
            });

            _api.Connect();
            Thread.Sleep(200);
        }
コード例 #2
0
ファイル: TraderApiWrapper.cs プロジェクト: zhuzhenping/CTPZQ
        //建立行情
        private void Connect_TD()
        {
            m_Api.OnConnect    = OnConnect_callback;
            m_Api.OnDisconnect = OnDisconnect_callback;
            m_Api.OnRspError   = OnRspError_callback;

            m_Api.OnErrRtnOrderAction              = OnErrRtnOrderAction_callback;
            m_Api.OnErrRtnOrderInsert              = OnErrRtnOrderInsert_callback;
            m_Api.OnRspOrderAction                 = OnRspOrderAction_callback;
            m_Api.OnRspOrderInsert                 = OnRspOrderInsert_callback;
            m_Api.OnRspQryDepthMarketData          = OnRspQryDepthMarketData_callback;
            m_Api.OnRspQryInstrument               = OnRspQryInstrument_callback;
            m_Api.OnRspQryInstrumentCommissionRate = OnRspQryInstrumentCommissionRate_callback;
            //m_Api.OnRspQryInstrumentMarginRate = OnRspQryInstrumentMarginRate_callback;
            m_Api.OnRspQryInvestorPosition       = OnRspQryInvestorPosition_callback;
            m_Api.OnRspQryInvestorPositionDetail = OnRspQryInvestorPositionDetail_callback;
            m_Api.OnRspQryOrder          = OnRspQryOrder_callback;
            m_Api.OnRspQryTrade          = OnRspQryTrade_callback;
            m_Api.OnRspQryTradingAccount = OnRspQryTradingAccount_callback;
            m_Api.OnRtnInstrumentStatus  = OnRtnInstrumentStatus_callback;
            m_Api.OnRtnOrder             = OnRtnOrder_callback;
            m_Api.OnRtnTrade             = OnRtnTrade_callback;

            m_Api.Connect();
        }
コード例 #3
0
 public void Connect()
 {
     m_Api.Connect();
 }