private void ProcessCancelOrder(string localId)
        {
            if (_cancelPendings.Contains(localId))
            {
                return;
            }

            if (!_orders.TryGetByLocalId(localId, out var order))
            {
                return;
            }

            if (string.IsNullOrEmpty(order.OrderID))
            {
                _cancelPendings.Add(localId);
                return;
            }

            var action = new CtpInputOrderAction();

            (action.FrontID, action.SessionID, action.OrderRef)         = GetFrontSessionItems(order.ID);
            (action.ExchangeID, action.InstrumentID, action.OrderSysID) = GetOrderSysItems(order.OrderID);
            action.ActionFlag     = CtpActionFlagType.Delete;
            action.OrderActionRef = _client.GetNextRequestId();
            action.InvestorID     = _client.CtpLoginInfo.UserID;
            action.BrokerID       = _client.CtpLoginInfo.BrokerID;
            _client.Api.ReqOrderAction(action, _client.GetNextRequestId());
        }
        private void ProcessCancelOrder(string id)
        {
            if (_cancelPending.Contains(id))
            {
                return;
            }

            if (!_orders.TryGetById(id, out var order))
            {
                return;
            }

            if (string.IsNullOrEmpty(order.OrderID))
            {
                _cancelPending.Add(id);
                return;
            }

            var action = new CtpInputOrderAction();

            action.OrderSysID     = order.OrderID;
            action.ExchangeID     = order.ExchangeID.ToUpper();
            action.InstrumentID   = order.InstrumentID;
            action.ActionFlag     = CtpActionFlagType.Delete;
            action.OrderActionRef = _client.GetNextRequestId();
            action.InvestorID     = _client.ctpLoginInfo.UserID;
            action.BrokerID       = _client.ctpLoginInfo.BrokerID;
            _client.api.ReqOrderAction(action, _client.GetNextRequestId());
        }
        private void ProcessQuery(QueryEvent e)
        {
            var ret = 0;

            switch (e.Type)
            {
            case QueryType.ReqQryInstrument:
                ret = _client.Api.ReqQryInstrument(new CtpQryInstrument(), _client.GetNextRequestId());
                break;

            case QueryType.ReqQryInvestorPosition:
                ret = QryInvestorPosition();
                break;

            case QueryType.ReqQryTradingAccount:
                ret = QryTradingAccount();
                break;
            }
            if (ret == 0)
            {
                _sleeps = 1;
            }
            else
            {
                _sleeps *= 4;
                _sleeps %= 1023;
                _action.Post(e);
            }
            Thread.Sleep(_sleeps);
        }
Esempio n. 4
0
        protected override int QryTradingAccount(ReqQueryField field)
        {
            var account = new CtpQryTradingAccount();

            account.BrokerID   = _client.CtpLoginInfo.BrokerID;
            account.InvestorID = _client.CtpLoginInfo.UserID;
            return(_client.Api.ReqQryTradingAccount(account, _client.GetNextRequestId()));
        }
Esempio n. 5
0
 private int SendRequest(byte id, object arg)
 {
     return(SendRequest(new CtpRequest(id, arg, _client.GetNextRequestId())));
 }