Exemplo n.º 1
0
    /// <summary>
    /// Requests the executions.
    /// </summary>
    /// <param name="filter">A filter to help narrow down the list of executions</param>
    /// <returns>the request id associated with this request to TWS, to be used later with the <see cref="ExecutionDetails"/> event</returns>
    /// <exception cref="Daemaged.IBNet.Client.NotConnectedException"></exception>
    public virtual int RequestExecutions(IBExecutionFilter filter)
    {
      lock (_socketLock) {
        // not connected?
        if (!IsConnected)
          throw new NotConnectedException();

        const int reqVersion = 3;

        // send cancel order msg
        try {
          _enc.Encode(ServerMessage.RequestExecutions);
          _enc.Encode(reqVersion);

          var requestId = NextValidId;

          if (ServerInfo.Version >= TWSServerInfo.MIN_SERVER_VER_EXECUTION_DATA_CHAIN)
            _enc.Encode(requestId);

          // Send the execution rpt filter data
          if (ServerInfo.Version >= 9) {
            _enc.Encode(filter.ClientId);
            _enc.Encode(filter.AcctCode);

            // Note that the valid format for m_time is "yyyymmdd-hh:mm:ss"
            _enc.Encode(filter.DateTime.ToString(IB_DATE_FORMAT));
            _enc.Encode(filter.Symbol);
            _enc.Encode(filter.SecurityType);
            _enc.Encode(filter.Exchange);
            _enc.Encode(filter.Side);
          }
          return requestId;
        } catch (Exception) {
          Disconnect();
          throw;
        }
      }
    }
Exemplo n.º 2
0
        public virtual void RequestExecutions(IBExecutionFilter filter)
        {
            // not connected?
            if(!IsConnected) {
                OnError(TWSErrors.NOT_CONNECTED);
                return;
            }

            int reqVersion = 2;

            // send cancel order msg
            try {
                _enc.Encode(Messages.Server.REQ_EXECUTIONS);
                _enc.Encode(reqVersion);

                // Send the execution rpt filter data
                if (ServerInfo.Version >= 9)
                {
                    _enc.Encode(filter.ClientId);
                    _enc.Encode(filter.AcctCode);

                    // Note that the valid format for m_time is "yyyymmdd-hh:mm:ss"
                    _enc.Encode(filter.Time.ToString(IB_DATE_FORMAT));
                    _enc.Encode(filter.Symbol);
                    _enc.Encode(filter.SecType);
                    _enc.Encode(filter.Exchange);
                    _enc.Encode(filter.Side);
                }
            }
            catch (Exception e) {
                OnError(TWSErrors.FAIL_SEND_EXEC);
                OnError(e.Message);
                Disconnect();
            }
        }