Beispiel #1
0
        private void OnInfo(int nInfoType, int nInfo)
        {
            //throw new NotImplementedException();
            string luserkey;

            switch (nInfoType)
            {
            case  INFO_TYPE_ACCOUNTS:
                String AccountInfo = "";
                for (int i = 0; i < nInfo; i++)
                {
                    AccountInfo = "Account:" + tc.GetInfoString(nInfoType, i, 0) + "\n";
                    AccountInfo = AccountInfo + "Name:" + tc.GetInfoString(nInfoType, i, 1) + "\n";
                    AccountInfo = AccountInfo + "Type:" + tc.GetInfoString(nInfoType, i, 2) + "\n";
                    AccountInfo = AccountInfo + "Broker:" + tc.GetInfoString(nInfoType, i, 3) + "\n";
                    AccountInfo = AccountInfo + "LoginID:" + tc.GetInfoString(nInfoType, i, 4) + "\n";
                    AccountInfo = AccountInfo + "Session:" + tc.GetInfoString(nInfoType, i, 5) + "\n";
                    logger.Info(AccountInfo);
                }
                break;

            case INFO_TYPE_STK_MARGINS:
                logger.Info("Function is not support");
                break;

            case INFO_TYPE_FUT_MARGINS:    //FutMargins

                for (int i = 0; i < nInfo; i++)
                {
                    MarginReport aMargineReport = new MarginReport();

                    aMargineReport.time           = tc.GetInfoString(nInfoType, i, 0);
                    aMargineReport.broker         = tc.GetInfoString(nInfoType, i, 1);
                    aMargineReport.account        = tc.GetInfoString(nInfoType, i, 2);
                    aMargineReport.preBalance     = tc.GetInfoString(nInfoType, i, 4);
                    aMargineReport.depositWithraw = tc.GetInfoString(nInfoType, i, 5);
                    aMargineReport.commission     = tc.GetInfoString(nInfoType, i, 6);
                    aMargineReport.closeProfit    = tc.GetInfoString(nInfoType, i, 10);
                    aMargineReport.balance        = tc.GetInfoString(nInfoType, i, 11);
                    aMargineReport.positionProfit = tc.GetInfoString(nInfoType, i, 12);
                    aMargineReport.currMargin     = tc.GetInfoString(nInfoType, i, 14);
                    aMargineReport.Available      = tc.GetInfoString(nInfoType, i, 18);
                    aMargineReport.FrozenMargin   = tc.GetInfoString(nInfoType, i, 50);
                    logger.Info("On Margin Status: " + aMargineReport.info());
                    onMargin(aMargineReport);
                }
                break;

            case INFO_TYPE_STK_POSITIONS:    //StkPositions
                logger.Info("Function is not support");
                break;

            case INFO_TYPE_FUT_POSITIONS:    //FutPositions
                for (int i = 0; i < nInfo; i++)
                {
                    PositionReport aPosReport = new PositionReport();
                    aPosReport.broker     = tc.GetInfoString(nInfoType, i, 0);
                    aPosReport.account    = tc.GetInfoString(nInfoType, i, 1);
                    aPosReport.symbolid   = tc.GetInfoString(nInfoType, i, 2);
                    aPosReport.symbolname = tc.GetInfoString(nInfoType, i, 3);
                    aPosReport.month      = tc.GetInfoString(nInfoType, i, 4);
                    aPosReport.buysell    = tc.GetInfoString(nInfoType, i, 5);
                    aPosReport.qty        = tc.GetInfoString(nInfoType, i, 6);
                    aPosReport.price      = tc.GetInfoString(nInfoType, i, 7);
                    aPosReport.exchange   = tc.GetInfoString(nInfoType, i, 8);
                    aPosReport.billtype   = tc.GetInfoString(nInfoType, i, 9);
                    aPosReport.time       = tc.GetInfoString(nInfoType, i, 10);
                    aPosReport.symbol     = tc.GetInfoString(nInfoType, i, 11);
                    logger.Info("On Position Status: " + aPosReport.info());
                    onPosition(aPosReport);
                }
                break;

            case INFO_TYPE_OPT_POSITIONS:    //OptPositions
                logger.Info("Function is not support");
                break;

            case INFO_TYPE_ORDER_STATUS:    //OrderStatus

                OrderStatusReport aStatusReport = new OrderStatusReport();
                aStatusReport.account      = tc.GetInfoString(nInfoType, nInfo, 0);
                aStatusReport.orderNumber  = tc.GetInfoString(nInfoType, nInfo, 1);
                aStatusReport.status       = tc.GetInfoString(nInfoType, nInfo, 11);
                aStatusReport.iceid        = tc.GetInfoString(nInfoType, nInfo, 25);
                aStatusReport.abbrname     = utility.getAbbrnameFromICEID(aStatusReport.iceid);
                aStatusReport.buySellStr   = tc.GetInfoString(nInfoType, nInfo, 6);
                aStatusReport.price        = tc.GetInfoValue(nInfoType, nInfo, 7);
                aStatusReport.lots         = tc.GetInfoValue(nInfoType, nInfo, 6);
                aStatusReport.filledNumber = tc.GetInfoValue(nInfoType, nInfo, 9);
                aStatusReport.memo         = tc.GetInfoString(nInfoType, nInfo, 24);
                aStatusReport.cancealable  = tc.GetInfoString(nInfoType, nInfo, 23);
                aStatusReport.time         = tc.GetInfoString(nInfoType, nInfo, 12);
                luserkey = tc.GetInfoString(nInfoType, nInfo, 14);

                logger.Info("userkey before replace..." + luserkey);

                if (String.Compare(aStatusReport.account, "8070-880937") == 0)
                {
                    int aIdx = luserkey.IndexOf("]");
                    int bIdx = luserkey.IndexOf("[!@6]");
                    luserkey = luserkey.Substring(aIdx + 1, bIdx - aIdx - 1);
                }

                logger.Info("userkey after replace..." + luserkey);

                aStatusReport.userkey = luserkey;


                logger.Info("On Order Status: " + aStatusReport.info());
                onOrder(aStatusReport);
                break;

            case INFO_TYPE_FILLED_ORDERS:    //FilledOrders
                FilledOrderReport aFilledReport = new FilledOrderReport();

                aFilledReport.account      = tc.GetInfoString(nInfoType, nInfo, 0);
                aFilledReport.orderNumber  = tc.GetInfoString(nInfoType, nInfo, 1);
                aFilledReport.iceid        = tc.GetInfoString(nInfoType, nInfo, 25);
                aFilledReport.abbrname     = utility.getAbbrnameFromICEID(aFilledReport.iceid);
                aFilledReport.buySellStr   = tc.GetInfoString(nInfoType, nInfo, 6);;
                aFilledReport.filledNumber = tc.GetInfoValue(nInfoType, nInfo, 9);
                aFilledReport.avgPrice     = tc.GetInfoValue(nInfoType, nInfo, 10);
                aFilledReport.memo         = tc.GetInfoString(nInfoType, nInfo, 24);
                aFilledReport.status       = tc.GetInfoString(nInfoType, nInfo, 11);
                luserkey = tc.GetInfoString(nInfoType, nInfo, 14);

                logger.Info("userkey before replace..." + luserkey);

                if (String.Compare(aFilledReport.account, "8070-880937") == 0)
                {
                    int aIdx = luserkey.IndexOf("]");
                    int bIdx = luserkey.IndexOf("[!@6]");
                    luserkey = luserkey.Substring(aIdx + 1, bIdx - aIdx - 1);
                }

                logger.Info("userkey after replace..." + luserkey);

                aFilledReport.userkey = luserkey;

                aFilledReport.time = tc.GetInfoString(nInfoType, nInfo, 12);
                logger.Info("On Filled Order Status: " + aFilledReport.info());
                onFilled(aFilledReport);
                break;
            }
        }
Beispiel #2
0
        private void OnInfo(int nInfoType, int nInfo)
        {
            //throw new NotImplementedException();
            string luserkey;


            //logger.Info("OnInfo:" + nInfoType + "..." + nInfo);

            switch (nInfoType)
            {
            case INFO_TYPE_ACCOUNTS:
                // function seems not support
                // use margin report, that contain account info
                logger.Info("Function is not support, use margin report");
                break;

            case INFO_TYPE_STK_MARGINS:
                logger.Info("Function is not support");
                break;

            case INFO_TYPE_FUT_MARGINS:    //FutMargins
                for (int i = 0; i < nInfo; i++)
                {
                    Account account = new Account();

                    account.time           = tc.GetInfoString(nInfoType, i, 0);
                    account.broker         = tc.GetInfoString(nInfoType, i, 1);
                    account.account        = tc.GetInfoString(nInfoType, i, 2);
                    account.preBalance     = tc.GetInfoString(nInfoType, i, 4);
                    account.depositWithraw = tc.GetInfoString(nInfoType, i, 5);
                    account.commission     = tc.GetInfoString(nInfoType, i, 6);
                    account.closeProfit    = tc.GetInfoString(nInfoType, i, 10);
                    account.balance        = tc.GetInfoString(nInfoType, i, 11);
                    account.positionProfit = tc.GetInfoString(nInfoType, i, 12);
                    account.currMargin     = tc.GetInfoString(nInfoType, i, 14);
                    account.Available      = tc.GetInfoString(nInfoType, i, 18);
                    account.FrozenMargin   = tc.GetInfoString(nInfoType, i, 50);
                    logger.Info("On Margin Status: " + account.getInfo());
                    if (onMargin != null)
                    {
                        onMargin(account);
                    }
                }

                break;

            case INFO_TYPE_STK_POSITIONS:    //StkPositions
                logger.Info("Function is not support");
                break;

            case INFO_TYPE_FUT_POSITIONS:    //FutPositions

                //logger.Info("On FutPositions " + nInfo);

                for (int i = 0; i < nInfo; i++)
                {
                    Position aPosition = new Position();
                    aPosition.broker     = tc.GetInfoString(nInfoType, i, 0);
                    aPosition.account    = tc.GetInfoString(nInfoType, i, 1);
                    aPosition.symbolid   = tc.GetInfoString(nInfoType, i, 2);
                    aPosition.symbolname = tc.GetInfoString(nInfoType, i, 3);
                    aPosition.month      = tc.GetInfoString(nInfoType, i, 4);
                    aPosition.buysell    = tc.GetInfoString(nInfoType, i, 5);
                    aPosition.qty        = tc.GetInfoString(nInfoType, i, 6);
                    aPosition.price      = tc.GetInfoString(nInfoType, i, 7);
                    aPosition.exchange   = tc.GetInfoString(nInfoType, i, 8);
                    aPosition.billtype   = tc.GetInfoString(nInfoType, i, 9);
                    aPosition.time       = tc.GetInfoString(nInfoType, i, 10);
                    aPosition.symbol     = tc.GetInfoString(nInfoType, i, 11);
                    logger.Info("On Position Status: " + aPosition.info());
                    if (onPosition != null)
                    {
                        onPosition(aPosition);
                    }
                }

                break;

            case INFO_TYPE_OPT_POSITIONS:    //OptPositions
                logger.Info("Function is not support");
                break;

            case INFO_TYPE_ORDER_STATUS:    //OrderStatus

                #region OrderStatus
                OrderStatusReport aStatusReport = new OrderStatusReport();
                aStatusReport.account     = tc.GetInfoString(nInfoType, nInfo, 0);
                aStatusReport.orderNumber = tc.GetInfoString(nInfoType, nInfo, 1);
                aStatusReport.status      = tc.GetInfoString(nInfoType, nInfo, 11);
                aStatusReport.iceid       = tc.GetInfoString(nInfoType, nInfo, 25);
                logger.Info("OrderStatusReport account " + aStatusReport.account);
                aStatusReport.abbrname = SymbolManager.Instance.getAbbrname(aStatusReport.iceid);

                aStatusReport.buySellStr   = tc.GetInfoString(nInfoType, nInfo, 6);
                aStatusReport.price        = tc.GetInfoValue(nInfoType, nInfo, 7);
                aStatusReport.lots         = tc.GetInfoValue(nInfoType, nInfo, 6);
                aStatusReport.filledNumber = tc.GetInfoValue(nInfoType, nInfo, 9);
                aStatusReport.memo         = tc.GetInfoString(nInfoType, nInfo, 24);
                aStatusReport.cancealable  = tc.GetInfoString(nInfoType, nInfo, 23);
                aStatusReport.time         = tc.GetInfoString(nInfoType, nInfo, 12);
                luserkey = tc.GetInfoString(nInfoType, nInfo, 14);

                //logger.Info("userkey before replace..." + luserkey);

                if (String.Compare(aStatusReport.account, "8070-880937") == 0)
                {
                    int aIdx = luserkey.IndexOf("]");
                    int bIdx = luserkey.IndexOf("[!@6]");
                    luserkey = luserkey.Substring(aIdx + 1, bIdx - aIdx - 1);
                }

                //logger.Info("userkey after replace..." + luserkey);

                aStatusReport.userkey = luserkey;


                logger.Info("On Order Status: " + aStatusReport.info());
                if (onOrder != null)
                {
                    onOrder(aStatusReport);
                }
                #endregion
                break;

            case INFO_TYPE_FILLED_ORDERS:    //FilledOrders

                #region FilledOrderStatus
                FilledOrderReport aFilledReport = new FilledOrderReport();

                aFilledReport.account     = tc.GetInfoString(nInfoType, nInfo, 0);
                aFilledReport.orderNumber = tc.GetInfoString(nInfoType, nInfo, 1);
                aFilledReport.iceid       = tc.GetInfoString(nInfoType, nInfo, 25);
                aFilledReport.abbrname    = SymbolManager.Instance.getAbbrname(aFilledReport.iceid);
                //if (AccountManager.isRealAccount(aFilledReport.account))
                //{
                //    aFilledReport.abbrname = utility.getAbbrnameFromCTPID(aFilledReport.iceid);
                //}
                //else
                //{
                //    aFilledReport.abbrname = utility.getAbbrnameFromGQuoteID(aFilledReport.iceid);
                //}

                aFilledReport.buySellStr   = tc.GetInfoString(nInfoType, nInfo, 6);;
                aFilledReport.filledNumber = tc.GetInfoValue(nInfoType, nInfo, 9);
                aFilledReport.avgPrice     = tc.GetInfoValue(nInfoType, nInfo, 10);
                aFilledReport.memo         = tc.GetInfoString(nInfoType, nInfo, 24);
                aFilledReport.status       = tc.GetInfoString(nInfoType, nInfo, 11);
                luserkey = tc.GetInfoString(nInfoType, nInfo, 14);

                //logger.Info("userkey before replace..." + luserkey);

                if (String.Compare(aFilledReport.account, "8070-880937") == 0)
                {
                    int aIdx = luserkey.IndexOf("]");
                    int bIdx = luserkey.IndexOf("[!@6]");
                    luserkey = luserkey.Substring(aIdx + 1, bIdx - aIdx - 1);
                }

                //logger.Info("userkey after replace..." + luserkey);

                aFilledReport.userkey = luserkey;

                aFilledReport.time = tc.GetInfoString(nInfoType, nInfo, 12);
                logger.Info("On Filled Order Status: " + aFilledReport.info());
                if (onFilled != null)
                {
                    onFilled(aFilledReport);
                }
                #endregion
                break;
            }
        }