Ejemplo n.º 1
0
        /// <summary>
        /// Write Client Order and Exchange Slices to database.
        /// </summary>
        public void writeOrderToDb()
        {
            foreach (string day in paras.getTradingDays())
            {
                fileMgr.setTradingDay(day);
                fileMgr.parseClientOrderFileAddress();
                ReportSenderMgr.SENDER.getExecReportSender().addDateToMail(day);

                foreach (string instanceId in fileMgr.getIntanceIds())
                {
                    Console.Out.Write("Handling Instance " + instanceId + " ");
                    logger.Info("Handling Instance " + instanceId + " of date " + day);
                    List <Order> instanceOrders = fileMgr.getInstanceOrders(instanceId);
                    foreach (Order order in instanceOrders)
                    {
                        order.computeMarketVariables();
                        order.validateOrderParas();
                    }

                    UpdatedCount updatedCount = StoredProcMgr.MANAGER.insUpdTrades(instanceOrders, instanceId);
                    ReportSenderMgr.SENDER.getExecReportSender().addInstanceToMail(
                        instanceId, updatedCount.getClientOrderCount(), updatedCount.getExchangeOrderCount());
                    Console.Out.WriteLine(updatedCount.getClientOrderCount() + " " + updatedCount.getExchangeOrderCount());
                }
                fileMgr.clear();
                Console.Out.WriteLine();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Validate file and command input paras since so many combinations are so confusing.
        /// Rule 1. Saver mode, no file account is allowed.(All accounts must be covered)
        /// Rule 2. Regular mode, no file account is allowed. TradingDay must be one.
        /// Rule 3. Reporter mode, no file account is allowed. Report all account or nothing.
        /// Rule 4. CLIENT_REPORT, must input tradingDays and accounts from file.
        /// Rule 5. Manager report, must contains some valid input days.
        /// </summary>
        /// <param name="paras_">Input Runtime Paras</param>
        /// <returns></returns>
        public static bool isParaValid(RunnerParas paras_)
        {
            Mode   mode = paras_.parseMode();
            string msg  = null;

            if (mode.Equals(Mode.SAVER))
            {
                if (paras_.getAccounts().Count != 0)
                {
                    msg = "Account input is not valid for this mode " + mode.ToString();
                    addErrorMessage(msg);
                    return(false);
                }
            }
            else if (mode.Equals(Mode.REGULAR))
            {
                if (paras_.getAccounts().Count != 0)
                {
                    msg = "Account input is not valid for this mode " + mode.ToString();
                    addErrorMessage(msg);
                    return(false);
                }
                if (paras_.getTradingDays().Count != 1)
                {
                    msg = "More than 1 tradingDay is not valid for this mode " + mode.ToString();
                    addErrorMessage(msg);
                    return(false);
                }
            }
            else if (mode.Equals(Mode.REPORTER))
            {
                //if (paras_.getAccounts().Count != 0)
                if (paras_.getAccounts().Count == 0)
                {
                    msg = "Account input is not valid for this mode " + mode.ToString();
                    addErrorMessage(msg);
                    return(false);
                }
                if (paras_.getTradingDays().Count != 1)
                {
                    msg = "More than 1 tradingDay is not valid for this mode " + mode.ToString();
                    addErrorMessage(msg);
                    return(false);
                }
            }
            else if (mode.Equals(Mode.CLIENT_REPORT))
            {
                if (paras_.getTradingDays().Count == 0)
                {
                    msg = "Please specify days by file for this mode " + mode.ToString();
                    addErrorMessage(msg);
                    return(false);
                }
            }
            else if (mode.Equals(Mode.MANAGER_REPORT))
            {
                if (paras_.getTradingDays().Count == 0)
                {
                    msg = "Please at least specify some tradingDays for mode " + mode.ToString();
                    addErrorMessage(msg);
                    return(false);
                }
            }
            else
            {
                throw new InvalidOperationException("Input Mode " + mode.ToString() + " Not Supported.");
            }
            logger.Info("Para Validation Passed.");
            return(true);
        }