Example #1
0
        /**
         * Monta e envia requisição para assinatura de um instrumento.
         *
         */
        private void requisitaInstrumento(
            char tipoAssinatura,
            string instrumento,
            string codigo,
            string identificacao)
        {
            try
            {
                string            mdReqID;
                MarketDataRequest mensagemFIX = new MarketDataRequest();

                if (codigo != null && codigo.Length > 0)
                {
                    mdReqID = codigo;
                }
                else
                {
                    mdReqID = FIX_MDREQID_PADRAO;
                }

                mensagemFIX.setField(new MDReqID(mdReqID));
                mensagemFIX.setField(new SubscriptionRequestType(tipoAssinatura));
                mensagemFIX.setField(new MarketDepth(0));
                mensagemFIX.setField(new MDUpdateType(MDUpdateType.INCREMENTAL_REFRESH));

                MarketDataRequest.NoMDEntryTypes grupoTipo = new MarketDataRequest.NoMDEntryTypes();
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.BID));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.OFFER));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.TRADE));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.OPENING_PRICE));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.CLOSING_PRICE));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.TRADING_SESSION_HIGH_PRICE));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.TRADING_SESSION_LOW_PRICE));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.TRADING_SESSION_VWAP_PRICE));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType(MDEntryType.TRADE_VOLUME));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType('a'));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType('b'));
                mensagemFIX.addGroup(grupoTipo);
                grupoTipo.set(new QuickFix.MDEntryType('c'));
                mensagemFIX.addGroup(grupoTipo);

                MarketDataRequest.NoRelatedSym grupo = new MarketDataRequest.NoRelatedSym();

                grupo.set(new Symbol(instrumento));

                if (codigo != null && codigo.Length > 0)
                {
                    grupo.set(new SecurityID(codigo));
                }

                if (identificacao != null && identificacao.Length > 0)
                {
                    grupo.set(new SecurityIDSource(identificacao));
                }

                mensagemFIX.addGroup(grupo);

                mensagemFIX.getHeader().setField(
                    new SenderCompID(sessao.getSenderCompID()));
                mensagemFIX.getHeader().setField(
                    new TargetCompID(sessao.getTargetCompID()));

                try
                {
                    Session.sendToTarget(mensagemFIX, sessao);
                }
                catch (SessionNotFound e)
                {
                    logger.Error("Sessao invalida: " + e.Message, e);
                }
            }
            catch (Exception ex)
            {
                logger.Error("requisitaMensagem: " + ex.Message, ex);
            }
        }
Example #2
0
		public virtual void Send(FIXMarketDataRequest Request)
		{
			Console.WriteLine(BeAEwTZGlZaeOmY5cm.J00weU3cM6(992));
			MarketDataRequest marketDataRequest = new MarketDataRequest(new MDReqID(Request.MDReqID), new SubscriptionRequestType(Request.SubscriptionRequestType), new MarketDepth(Request.MarketDepth));
			if (Request.ContainsField(265))
				marketDataRequest.set(new MDUpdateType(Request.MDUpdateType));
			MarketDataRequest.NoMDEntryTypes noMdEntryTypes = new MarketDataRequest.NoMDEntryTypes();
			for (int i = 0; i < Request.NoMDEntryTypes; ++i)
			{
				noMdEntryTypes.set(new MDEntryType(Request.GetMDEntryTypesGroup(i).MDEntryType));
				marketDataRequest.addGroup((Group)noMdEntryTypes);
			}
			noMdEntryTypes.Dispose();
			MarketDataRequest.NoRelatedSym noRelatedSym = new MarketDataRequest.NoRelatedSym();
			for (int i = 0; i < Request.NoRelatedSym; ++i)
			{
				FIXRelatedSymGroup relatedSymGroup = Request.GetRelatedSymGroup(i);
				noRelatedSym.set(new Symbol(relatedSymGroup.Symbol));
				if (relatedSymGroup.ContainsField(65))
					noRelatedSym.set(new SymbolSfx(relatedSymGroup.SymbolSfx));
				if (relatedSymGroup.ContainsField(48))
					noRelatedSym.set(new SecurityID(relatedSymGroup.SecurityID));
				if (relatedSymGroup.ContainsField(22))
					noRelatedSym.set(new IDSource(relatedSymGroup.SecurityIDSource));
				if (relatedSymGroup.ContainsField(167))
					noRelatedSym.set(new QuickFix.SecurityType(relatedSymGroup.SecurityType));
				if (relatedSymGroup.ContainsField(200))
					noRelatedSym.set(new MaturityMonthYear(relatedSymGroup.MaturityMonthYear));
				if (relatedSymGroup.ContainsField(202))
					noRelatedSym.set(new StrikePrice(relatedSymGroup.StrikePrice));
				if (relatedSymGroup.ContainsField(206))
					noRelatedSym.set(new OptAttribute(relatedSymGroup.OptAttribute));
				if (relatedSymGroup.ContainsField(231))
					noRelatedSym.set(new ContractMultiplier(relatedSymGroup.ContractMultiplier));
				if (relatedSymGroup.ContainsField(223))
					noRelatedSym.set(new CouponRate(relatedSymGroup.CouponRate));
				if (relatedSymGroup.ContainsField(207))
					noRelatedSym.set(new SecurityExchange(relatedSymGroup.SecurityExchange));
				if (relatedSymGroup.ContainsField(106))
					noRelatedSym.set(new Issuer(relatedSymGroup.Issuer));
				if (relatedSymGroup.ContainsField(348))
					noRelatedSym.set(new EncodedIssuerLen(relatedSymGroup.EncodedIssuerLen));
				if (relatedSymGroup.ContainsField(349))
					noRelatedSym.set(new EncodedIssuer(relatedSymGroup.EncodedIssuer));
				if (relatedSymGroup.ContainsField(107))
					noRelatedSym.set(new SecurityDesc(relatedSymGroup.SecurityDesc));
				if (relatedSymGroup.ContainsField(350))
					noRelatedSym.set(new EncodedSecurityDescLen(relatedSymGroup.EncodedSecurityDescLen));
				if (relatedSymGroup.ContainsField(351))
					noRelatedSym.set(new EncodedSecurityDesc(relatedSymGroup.EncodedSecurityDesc));
				marketDataRequest.addGroup((Group)noRelatedSym);
			}
			noRelatedSym.Dispose();
			try
			{
				Session.sendToTarget((QuickFix.Message)marketDataRequest, this.fSessionID);
			}
			catch (Exception ex)
			{
				Console.WriteLine(BeAEwTZGlZaeOmY5cm.J00weU3cM6(1096) + ex.Message);
			}
		}