Ejemplo n.º 1
0
        /// <inheritdoc/>
        public void contractDetails(int reqId, ContractDetails contractDetails)
        {
            // Raise an event here which can be listened throughout the application
            var eventArgs = new ContractDetailsEventArgs(reqId, contractDetails);

            this.ContractDetailsEvent.Invoke(this, eventArgs);
        }
Ejemplo n.º 2
0
        private Instrument ContractToInstrument(ContractDetailsEventArgs e)
        {
            var instrument = TWSUtils.ContractDetailsToInstrument(e.ContractDetails);

            instrument.Datasource   = _thisDS;
            instrument.DatasourceID = _thisDS.ID;
            if (e.ContractDetails.Summary.Exchange != null && _exchanges.ContainsKey(e.ContractDetails.Summary.Exchange))
            {
                instrument.Exchange   = _exchanges[e.ContractDetails.Summary.Exchange];
                instrument.ExchangeID = instrument.Exchange.ID;
            }
            else
            {
                _logger.Error("Could not find exchange in database: " + e.ContractDetails.Summary.Exchange);
                return(null);
            }

            if (e.ContractDetails.Summary.PrimaryExchange != null &&
                _exchanges.ContainsKey(e.ContractDetails.Summary.PrimaryExchange))
            {
                instrument.PrimaryExchange   = _exchanges[e.ContractDetails.Summary.PrimaryExchange];
                instrument.PrimaryExchangeID = instrument.PrimaryExchange.ID;
            }
            else if (!string.IsNullOrEmpty(e.ContractDetails.Summary.PrimaryExchange))
            {
                _logger.Error("Could not find exchange in database: " + e.ContractDetails.Summary.PrimaryExchange);
                return(null);
            }
            return(instrument);
        }
Ejemplo n.º 3
0
        private Instrument ContractToInstrument(ContractDetailsEventArgs e)
        {
            var instrument = TWSUtils.ContractDetailsToInstrument(e.ContractDetails);

            instrument.Datasource   = _thisDS;
            instrument.DatasourceID = _thisDS.ID;
            if (e.ContractDetails.Summary.Exchange != null && _exchanges.ContainsKey(e.ContractDetails.Summary.Exchange))
            {
                instrument.Exchange   = _exchanges[e.ContractDetails.Summary.Exchange];
                instrument.ExchangeID = instrument.Exchange.ID;
            }
            else
            {
                Application.Current.Dispatcher.Invoke(() =>
                                                      _logger.Log(NLog.LogLevel.Error,
                                                                  "Could not find exchange in database: " + e.ContractDetails.Summary.Exchange));
                return(null);
            }

            if (e.ContractDetails.Summary.PrimaryExchange != null &&
                _exchanges.ContainsKey(e.ContractDetails.Summary.PrimaryExchange))
            {
                instrument.PrimaryExchange   = _exchanges[e.ContractDetails.Summary.PrimaryExchange];
                instrument.PrimaryExchangeID = instrument.PrimaryExchange.ID;
            }
            else if (!string.IsNullOrEmpty(e.ContractDetails.Summary.PrimaryExchange))
            {
                Application.Current.Dispatcher.Invoke(() =>
                                                      _logger.Log(NLog.LogLevel.Error,
                                                                  "Could not find exchange in database: " + e.ContractDetails.Summary.PrimaryExchange));
                return(null);
            }
            return(instrument);
        }
        private void _client_ContractDetails(object sender, ContractDetailsEventArgs e)
        {
            var instrument = TWSUtils.ContractDetailsToInstrument(e.ContractDetails);

            instrument.Datasource   = _thisDS;
            instrument.DatasourceID = _thisDS.ID;
            if (e.ContractDetails.Summary.Exchange != null && _exchanges.ContainsKey(e.ContractDetails.Summary.Exchange))
            {
                instrument.Exchange   = _exchanges[e.ContractDetails.Summary.Exchange];
                instrument.ExchangeID = instrument.Exchange.ID;
            }
            else
            {
                Dispatcher.Invoke(() => _logger.Log(NLog.LogLevel.Error, "Could not find exchange in database: " + e.ContractDetails.Summary.Exchange));
                return;
            }

            if (e.ContractDetails.Summary.PrimaryExchange != null && _exchanges.ContainsKey(e.ContractDetails.Summary.PrimaryExchange))
            {
                instrument.PrimaryExchange   = _exchanges[e.ContractDetails.Summary.PrimaryExchange];
                instrument.PrimaryExchangeID = instrument.PrimaryExchange.ID;
            }
            else if (!string.IsNullOrEmpty(e.ContractDetails.Summary.PrimaryExchange))
            {
                Dispatcher.Invoke(() => _logger.Log(NLog.LogLevel.Error, "Could not find exchange in database: " + e.ContractDetails.Summary.PrimaryExchange));
                return;
            }

            Dispatcher.Invoke(() => Instruments.Add(instrument));
        }
Ejemplo n.º 5
0
        private void _client_ContractDetails(object sender, ContractDetailsEventArgs e)
        {
            Instrument instrument = ContractToInstrument(e);

            if (instrument == null)
            {
                return;
            }

            Application.Current.Dispatcher.Invoke(() => Instruments.Add(instrument));
        }
Ejemplo n.º 6
0
        void tws_ContractDetails(object sender, ContractDetailsEventArgs e)
        {
            // get contact object
            if (!cont_list.ContainsKey(e.RequestId))
            {
                return;
            }
            ContData c = cont_list[e.RequestId];

            c.contracts.Add(e);
        }
Ejemplo n.º 7
0
        private Instrument ContractToInstrument(ContractDetailsEventArgs e)
        {
            Instrument instrument = TwsUtils.ContractDetailsToInstrument(e.ContractDetails);

            instrument.Datasource   = thisDs;
            instrument.DatasourceID = thisDs.ID;
            if (e.ContractDetails.Summary.Exchange != null &&
                exchanges.ContainsKey(e.ContractDetails.Summary.Exchange))
            {
                instrument.Exchange   = exchanges[e.ContractDetails.Summary.Exchange];
                instrument.ExchangeID = instrument.Exchange.ID;
            }
            else
            {
                Logger.Error("Could not find exchange in database: " +
                             e.ContractDetails.Summary.Exchange);
                return(null);
            }

            return(instrument);
        }
Ejemplo n.º 8
0
 private void _client_BatchContractDetail(object sender, ContractDetailsEventArgs e)
 {
     Status = string.Format("{0}/{1} symbols received", _totalSymbols - _queuedSymbols.Count, _totalSymbols);
     _tmpContractDetails.Add(e);
 }