Ejemplo n.º 1
0
        static void Main( string[] args )
        {
            try
            {
            Message message = new Message("jh");
            message.Dispose();
            }
            catch( InvalidMessage e )
            {
            Console.WriteLine( e.Message );
            }

            GC.Collect();
            return;

            if ( args.Length != 1 )
            {
              Console.WriteLine( "usage: executor_csharp FILE." );
              return ;
            }

            try
            {
              SessionSettings settings = new SessionSettings( args[ 0 ] );
              Application application = new Application();
              FileStoreFactory storeFactory = new FileStoreFactory( settings );
              ScreenLogFactory logFactory = new ScreenLogFactory( settings );
              MessageFactory messageFactory = new DefaultMessageFactory();
              SocketAcceptor acceptor
            = new SocketAcceptor( application, storeFactory, settings, logFactory, messageFactory );

              acceptor.start();
              Console.WriteLine("press <enter> to quit");
              Console.Read();
              acceptor.stop();
            }
            catch ( Exception e )
            {
              Console.WriteLine( e );
            }
        }
 public override void fromApp(QuickFix.Message message, SessionID sessionID)
 {
     this.crack(message, sessionID);
     message.Dispose();
 }
Ejemplo n.º 3
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();
        }