Exemplo n.º 1
0
 public void AddInstrument(string instrument, SymbolInfo symb = null)
 {
     try
     {
         if (!_dicTrading.ContainsKey(instrument))
         {
             logger.Info("Assinando instrumento: " + instrument);
             MdsAssinatura mdsSign = new MdsAssinatura();
             mdsSign.Instrumento = instrument.ToUpper().Trim();
             mdsSign.Sinal       = TipoSinal.CotacaoRapida;
             MdsNegociosEventArgs _mensagemNegocio = (MdsBayeuxClient.MdsNegociosEventArgs)MdsBayeuxClient.MdsHttpClient.Instance.Assina(mdsSign);
             MdsTradingInfo       mdsInstrument    = new MdsTradingInfo();
             if (null != symb)
             {
                 mdsInstrument.Trading = symb.Trading;
             }
             if (null != _mensagemNegocio)
             {
                 mdsInstrument.Quotes = _mensagemNegocio;
             }
             _dicTrading.Add(instrument, mdsInstrument); // primeira assinatura
             mdsSign = null;
         }
     }
     catch (Exception ex)
     {
         logger.Error("Problemas na assinatura do ativo: " + ex.Message, ex);
     }
 }
Exemplo n.º 2
0
 private void ProcessMdsNegocios()
 {
     while (_running)
     {
         try
         {
             MdsNegociosEventArgs e = null;
             lock (_queueMsgs)
             {
                 if (_queueMsgs.Count > 0)
                 {
                     e = _queueMsgs.Dequeue();
                 }
                 else
                 {
                     Monitor.Wait(_queueMsgs, 100);
                 }
             }
             if (null != e)
             {
                 if (_dicTrading.ContainsKey(e.negocios.cb.i))
                 {
                     _dicTrading[e.negocios.cb.i].Quotes = e;
                 }
             }
             e = null;
         }
         catch (Exception ex)
         {
             logger.Error("Problemas no processamento da mensagem de negocio: " + ex.Message, ex);
         }
     }
 }
Exemplo n.º 3
0
        private void gMdsHttpClient_OnNegociosEvent(object sender, MdsNegociosEventArgs e)
        {
            string lInstrumento = e.negocios.cabecalho.instrumento.ToUpper();

            if (gNegocios.ContainsKey(lInstrumento))
            {
                gNegociosDados[lInstrumento] = e.negocios.negocio;
            }
        }
Exemplo n.º 4
0
 private void OnNegocios(object sender, MdsNegociosEventArgs e)
 {
     try
     {
         lock (_queueMsgs)
         {
             _queueMsgs.Enqueue(e);
             Monitor.Pulse(_queueMsgs);
         }
     }
     catch (Exception ex)
     {
         logger.Error("Erro no enfileiramento do evento de negocios: " + ex.Message, ex);
     }
 }