public void toAdmin(QuickFix.Message message, SessionID sessionID)
        {
            #region Documentation
            // provides you with a peak at the administrative messages that are being sent from your FIX engine to the
            // counter party. This is normally not useful for an application however it is provided for any logging you may
            // wish to do. Notice that the FIX::Message is not const. This allows you to add fields before an adminstrative
            // message before it is sent out.
            #endregion

            bool print = true;
            if (message.getHeader().isSetField(35))
            {
                MsgType msgtype = new MsgType();
                message.getHeader().getField(msgtype);
                if (msgtype.getValue() == "0")
                {
                    print = false;
                }
                else if (msgtype.getValue() == MsgType.LOGON)
                {
                    message.getHeader().setField(Username.FIELD, "wbaychidrop");
                    message.getHeader().setField(Password.FIELD, "W3aychi!");
                    //message.setField(RawData.FIELD, "W3aychi!");
                    //message.setField(RawDataLength.FIELD, "W3aychi!".Length.ToString());
                }

                //    SenderCompID sender = new SenderCompID();
                //    message.getHeader().getField(sender);

                //    if (sender.getValue().Equals("DHIRACH"))
                //    {
                //        message.getHeader().setField(SenderSubID.FIELD, "DHIRACH");
                //        message.getHeader().setField(TargetSubID.FIELD, "ITGD");
                //    }
                //    else
                //    {
                //        message.getHeader().setField(TargetSubID.FIELD, "DHIRACH");
                //        message.getHeader().setField(SenderSubID.FIELD, "ITGD");
                //    }
            }

            if (print)
            {
                Console.WriteLine("Logon Message: " + message.ToString());
            }
        }
Beispiel #2
0
        public void toAdmin(Message message, SessionID sessionID)
        {
            // This is only for the TT dev environment.  The production FIX Adapter does not require a password
            MsgType msgType = new MsgType();
            message.getHeader().getField(msgType);

            TargetCompID targetCompID = new TargetCompID();
            message.getHeader().getField(targetCompID);

            if (msgType.ToString() == MsgType.Logon &&
                (targetCompID.ToString() == "TTDEV9P" || targetCompID.ToString() == "TTDEV9O"))
            {
                const string password = "******";
                RawData rawData = new RawData(password);
                message.getHeader().setField(rawData);
            }
            // End TT Dev environment case
        }
Beispiel #3
0
 public void fromAdmin(Message message, SessionID sessionID)
 {
     if (!isTimerAdjusted)
     {
         SendingTime sendingTime = new SendingTime();
         message.getHeader().getField(sendingTime);
         Utils.AdjustTime(sendingTime.getValue());
         isTimerAdjusted = true;
     }
 }
        public void fromAdmin(QuickFix.Message message, SessionID sessionID)
        {
            #region Documentation
            // notifies you when an administrative message is sent from a counterparty to your FIX engine. This can be
            // useful for doing extra validation on logon messages such as for checking passwords. Throwing a RejectLogon
            // exception will disconnect the counterparty.
            #endregion
            bool print = true;
            if (message.getHeader().isSetField(35))
            {
                MsgType msgtype = new MsgType();
                message.getHeader().getField(msgtype);
                if (msgtype.getValue() == "0")
                {
                    print = false;
                }
            }

            if (print)
            {
                Console.WriteLine("fromAdmin: " + message.ToString());
            }
        }
Beispiel #5
0
        /**
         * Callback chamado logo antes do envio da mensagem FIX de controle de sessão.
         *
         */
        public void toAdmin(QuickFix.Message message, SessionID sessionId)
        {
            try
            {
                // Se for mensagem de Logon, inclui o RawData e RawDataLength na mensagem
                if (message.getHeader().getString(MsgType.FIELD).Equals("A"))
                {
                    message.setBoolean(ResetSeqNumFlag.FIELD, true);
                    message.setInt(NextExpectedMsgSeqNum.FIELD,
                                   (new NextExpectedMsgSeqNum(ConstantesMDS.BMF_SEQNUM_INICIAL)).getValue());

                    message.setField(RawData.FIELD, new RawData(senha).ToString());
                    message.setField(RawDataLength.FIELD, new RawDataLength(senha.Length).ToString());

                    if (novaSenha != null && novaSenha.Length > 0)
                    {
                        message.setField(NewPassword.FIELD, new NewPassword(novaSenha).ToString());
                        logger.Info("Enviada nova senha para alteracao!");
                    }
                }
                else if (message.getHeader().getString(MsgType.FIELD).Equals("5"))
                {
                    if (assinados)
                    {
                        cancelaInstrumentos();
                    }
                }

                logger.Debug("SEND(SES) --> " + message.ToString());
            }

            catch (FieldNotFound e)
            {
                logger.Error("Campo nao encontrado: " + e.Message, e);
            }
        }
 long ServerQuickFix_newSendOrderRequest(Order o)
 {
     QuickFix.Message        message = new QuickFix.Message();
     QuickFix.Message.Header header  = message.getHeader();
     header.setField(new BeginString(FIXID));
     header.setField(new SenderCompID(SenderCompId));
     header.setField(new TargetCompID(TargetCompId));
     header.setField(new MsgType(CANCEL));
     message.setField(new OrigClOrdID(o.id.ToString()));
     message.setField(new ClOrdID(o.id.ToString()));
     message.setField(new Symbol(o.symbol));
     message.setField(new Side(o.side ? Side.BUY : Side.SELL));
     //message.setField(new Text("Cancel My Order!"));
     Session.sendToTarget(message);
     return(0);
 }
Beispiel #7
0
        public virtual void toAdmin(QuickFix.Message message, QuickFix.SessionID session)
        {
            // Faz o processamento
            try
            {
                logger.Debug("toAdmin(). Session id : " + session.ToString() + " Msg: " + message.GetType().ToString());

                if (message.getHeader().getField(MsgType.FIELD) != QuickFix.MsgType.Heartbeat)
                {
                    this.crack(message, session);
                }
            }
            catch (Exception ex)
            {
                logger.Error("toAdmin() Erro: " + ex.Message, ex);
            }
        }
Beispiel #8
0
        public void fromAdmin(Message message, SessionID sessionID)
        {
            if(!isTimerAdjusted)
            {
                SendingTime sendingTime = new SendingTime();
                message.getHeader().getField(sendingTime);
                Utils.AdjustTime(sendingTime.getValue());
                isTimerAdjusted = true;
            }

            //AddText("fromAdmin " + message + Environment.NewLine);
        }
Beispiel #9
0
 long ServerQuickFix_newSendOrderRequest(Order o)
 {
     QuickFix.Message message = new QuickFix.Message();
     QuickFix.Message.Header header = message.getHeader();
     header.setField(new BeginString(FIXID));
     header.setField(new SenderCompID(SenderCompId));
     header.setField(new TargetCompID(TargetCompId));
     header.setField(new MsgType(CANCEL));
     message.setField(new OrigClOrdID(o.id.ToString()));
     message.setField(new ClOrdID(o.id.ToString()));
     message.setField(new Symbol(o.symbol));
     message.setField(new Side(o.side ? Side.BUY : Side.SELL));
     //message.setField(new Text("Cancel My Order!"));
     Session.sendToTarget(message);
     return 0;
     
 }
Beispiel #10
0
        void Application.fromApp(QuickFix.Message message, SessionID sessionID)
        {
            //Console.WriteLine("from app:"+message.ToString());
            // 查询股份和资产不是FIX4.2的标准功能,需要特殊处理
            if (message.getHeader().getString(35) == "UAP")
            {
                PosType     posType     = new PosType();
                LongQty     longQty     = new LongQty();
                ShortQty    shortQty    = new ShortQty();
                NoPositions noPositions = new NoPositions();
                Group       group       = new Group(noPositions.getField(), posType.getField());

                if ((message.getField(724) == "9") && (FundStatusReport != null))// 资产
                {
                    //string currency = message.getField(15);
                    double balance          = 0.0;
                    double availableBalance = 0.0;
                    double totalAsserts     = 0.0;
                    double capitalAsserts   = 0.0;
                    double marketValue      = 0.0;
                    double buyFreezed       = 0.0;

                    for (uint i = 1; i <= int.Parse(message.getField(noPositions.getField())); i++)
                    {
                        message.getGroup(i, group);
                        switch (group.getField(posType.getField()))
                        {
                        case "FB":
                            balance = double.Parse(group.getField(longQty.getField()));
                            break;

                        case "FAV":
                            availableBalance = double.Parse(group.getField(longQty.getField()));
                            break;

                        case "MV":
                            totalAsserts = double.Parse(group.getField(longQty.getField()));
                            break;

                        case "F":
                            capitalAsserts = double.Parse(group.getField(longQty.getField()));
                            break;

                        case "SV":
                            marketValue = double.Parse(group.getField(longQty.getField()));
                            break;

                        case "FBF":
                            buyFreezed = double.Parse(group.getField(shortQty.getField()));
                            break;
                        }
                    }
                    FundStatusReport(this, new FundStatusReportEventArgs(balance, availableBalance, totalAsserts,
                                                                         capitalAsserts, marketValue, buyFreezed));
                }
                else if ((message.getField(724) == "0") && (PositionStatusReport != null)) // 股份
                {
                    string accountID        = message.getString(1);;
                    string securityExchange = message.getString(207);
                    switch (securityExchange)
                    {
                    case "XSHG":
                        securityExchange = "SH";
                        break;

                    case "XSHE":
                        securityExchange = "SZ";
                        break;
                    }

                    string securityID       = message.getString(55);
                    double balance          = 0.0;
                    double availableBalance = 0.0;
                    double quantity         = 0.0;

                    for (uint i = 1; i <= int.Parse(message.getField(noPositions.getField())); i++)
                    {
                        message.getGroup(i, group);
                        switch (group.getField(posType.getField()))
                        {
                        case "SB": balance = double.Parse(group.getField(longQty.getField())); break;

                        case "SAV": availableBalance = double.Parse(group.getField(longQty.getField())); break;

                        case "SQ": quantity = double.Parse(group.getField(longQty.getField())); break;
                        }
                    }
                    PositionStatusReport(this, new PositionStatusReportEventArgs(accountID, securityExchange, securityID,
                                                                                 balance, availableBalance, quantity));
                }
            }
            else
            {
                base.crack(message, sessionID); // 调用默认处理方法
            }
            message.Dispose();
        }