Ejemplo n.º 1
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.º 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
            {
                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);
        }