public override bool Equals(object other)
        {
            bool            l_bRetVal  = false;
            ExecutionFilter l_theOther = other as ExecutionFilter;

            if (l_theOther == null)
            {
                l_bRetVal = false;
            }
            else if (this == other)
            {
                l_bRetVal = true;
            }
            else
            {
                l_bRetVal = (ClientId == l_theOther.ClientId &&
                             string.Compare(AcctCode, l_theOther.AcctCode, true) == 0 &&
                             string.Compare(Time, l_theOther.Time, true) == 0 &&
                             string.Compare(Symbol, l_theOther.Symbol, true) == 0 &&
                             string.Compare(SecType, l_theOther.SecType, true) == 0 &&
                             string.Compare(Exchange, l_theOther.Exchange, true) == 0 &&
                             string.Compare(Side, l_theOther.Side, true) == 0);
            }
            return(l_bRetVal);
        }
        public override bool Equals(Object other)
        {
            bool l_bRetVal = false;

            if (other == null)
            {
                l_bRetVal = false;
            }
            else if (this == other)
            {
                l_bRetVal = true;
            }
            else
            {
                ExecutionFilter l_theOther = (ExecutionFilter)other;
                l_bRetVal = (clientId == l_theOther.clientId &&
                             String.Compare(AcctCode, l_theOther.acctCode, true) == 0 &&
                             String.Compare(time, l_theOther.Time, true) == 0 &&
                             String.Compare(symbol, l_theOther.Symbol, true) == 0 &&
                             String.Compare(secType, l_theOther.SecType, true) == 0 &&
                             String.Compare(exchange, l_theOther.Exchange, true) == 0 &&
                             String.Compare(side, l_theOther.Side, true) == 0);
            }
            return(l_bRetVal);
        }
        /**
         * @brief Requests all the day's executions matching the filter.
         * Only the current day's executions can be retrieved. Along with the executions, the CommissionReport will also be returned. The execution details will arrive at EWrapper:execDetails
         * @param reqId the request's unique identifier.
         * @param filter the filter criteria used to determine which execution reports are returned.
         * @sa EWrapper::execDetails, EWrapper::commissionReport, ExecutionFilter
         */
        public void reqExecutions(int reqId, ExecutionFilter filter)
        {
            if (!CheckConnection())
                return;

            int VERSION = 3;

            List<byte> paramsList = new List<byte>();
            paramsList.AddParameter(OutgoingMessages.RequestExecutions);
            paramsList.AddParameter(VERSION);//version
            
            if (serverVersion >= MinServerVer.EXECUTION_DATA_CHAIN)
            {
            	paramsList.AddParameter( reqId);
            }

            //Send the execution rpt filter data
            if (serverVersion >= 9)
            {
                paramsList.AddParameter(filter.ClientId);
                paramsList.AddParameter(filter.AcctCode);

                // Note that the valid format for time is "yyyymmdd-hh:mm:ss"
                paramsList.AddParameter(filter.Time);
                paramsList.AddParameter(filter.Symbol);
                paramsList.AddParameter(filter.SecType);
                paramsList.AddParameter(filter.Exchange);
                paramsList.AddParameter(filter.Side);
            }
            Send(reqId, paramsList, EClientErrors.FAIL_SEND_EXEC);
        }
Exemple #4
0
        /**
         * @brief Requests all the day's executions matching the filter.
         * Only the current day's executions can be retrieved. Along with the executions, the CommissionReport will also be returned. The execution details will arrive at EWrapper:execDetails
         * @param reqId the request's unique identifier.
         * @param filter the filter criteria used to determine which execution reports are returned.
         * @sa EWrapper::execDetails, EWrapper::commissionReport, ExecutionFilter
         */
        public void reqExecutions(int reqId, ExecutionFilter filter)
        {
            if (!CheckConnection())
                return;

            int VERSION = 3;

            var paramsList = new BinaryWriter(new MemoryStream());
            var lengthPos = prepareBuffer(paramsList);

            paramsList.AddParameter(OutgoingMessages.RequestExecutions);
            paramsList.AddParameter(VERSION);//version

            if (serverVersion >= MinServerVer.EXECUTION_DATA_CHAIN)
            {
                paramsList.AddParameter(reqId);
            }

            //Send the execution rpt filter data
            if (serverVersion >= 9)
            {
                paramsList.AddParameter(filter.ClientId);
                paramsList.AddParameter(filter.AcctCode);

                // Note that the valid format for time is "yyyymmdd-hh:mm:ss"
                paramsList.AddParameter(filter.Time);
                paramsList.AddParameter(filter.Symbol);
                paramsList.AddParameter(filter.SecType);
                paramsList.AddParameter(filter.Exchange);
                paramsList.AddParameter(filter.Side);
            }
            CloseAndSend(reqId, paramsList, lengthPos, EClientErrors.FAIL_SEND_EXEC);
        }
        public void RequestExecutions()
        {
            ExecutionFilter ef = new ExecutionFilter();
            ibClient.ClientSocket.reqExecutions(10, ef);            

        }
        private void btnReqExecution_Click(object sender, EventArgs e)
        {
            ExecutionFilter filter = new ExecutionFilter();

            requestId = Int32.Parse(orderDlg.tbRequestId.Text, CultureInfo.InvariantCulture);
            ibClient.reqExecutions(requestId, filter);
        }
        /// <summary>
        /// Gets the execution details matching the filter
        /// </summary>
        /// <returns>A list of executions matching the filter</returns>
        public List<IB.ExecutionDetailsEventArgs> GetExecutions(string symbol, string type, string exchange, DateTime? timeSince, string side)
        {
            var filter = new ExecutionFilter
            {
                AcctCode = _account,
                ClientId = _clientId,
                Exchange = exchange,
                SecType = type ?? IB.SecurityType.Undefined,
                Symbol = symbol,
                Time = (timeSince ?? DateTime.MinValue).ToString("yyyyMMdd HH:mm:ss"),
                Side = side ?? IB.ActionSide.Undefined
            };

            var details = new List<IB.ExecutionDetailsEventArgs>();

            var manualResetEvent = new ManualResetEvent(false);

            var requestId = GetNextRequestId();

            // define our event handlers
            EventHandler<IB.RequestEndEventArgs> clientOnExecutionDataEnd = (sender, args) =>
            {
                if (args.RequestId == requestId) manualResetEvent.Set();
            };
            EventHandler<IB.ExecutionDetailsEventArgs> clientOnExecDetails = (sender, args) =>
            {
                if (args.RequestId == requestId) details.Add(args);
            };

            _client.ExecutionDetails += clientOnExecDetails;
            _client.ExecutionDetailsEnd += clientOnExecutionDataEnd;

            // no need to be fancy with request id since that's all this client does is 1 request
            _client.ClientSocket.reqExecutions(requestId, filter);

            if (!manualResetEvent.WaitOne(5000))
            {
                throw new TimeoutException("InteractiveBrokersBrokerage.GetExecutions(): Operation took longer than 5 seconds.");
            }

            // remove our event handlers
            _client.ExecutionDetails -= clientOnExecDetails;
            _client.ExecutionDetailsEnd -= clientOnExecutionDataEnd;

            return details;
        }