Esempio n. 1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            ERUN_MODE nRunMode = ERUN_MODE.BACKTEST;

            if (cmbMode.Text == "MODE_BACKTEST")
            {
                nRunMode = ERUN_MODE.BACKTEST;
            }
            if (cmbMode.Text == "MODE_OPTIMIZE")
            {
                nRunMode = ERUN_MODE.OPTIMIZE;
            }
            if (cmbMode.Text == "MODE_REAL")
            {
                nRunMode = ERUN_MODE.REALTIME;
            }
            if (cmbMode.Text == "MODE_SIMULATION")
            {
                nRunMode = ERUN_MODE.SIMULATION;
            }

            if (MessageBox.Show(string.Format("Do you want to run {0} ?", cmbMode.Text), "Confirm", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            fatMng = new CFATManager(nRunMode, cmbMode.Text);

            if (!fatMng.init())
            {
                return;
            }

            this.Text = CFATManager.getSystemName();

            btnStart.Enabled = false;
            btnStop.Enabled  = true;

            cmbMode.Enabled = false;
            fatMng.doProcess();
        }
Esempio n. 2
0
        private bool isWorkTime()
        {
            if (!CFATManager.isOnlineMode())
            {
                return(true);
            }

            if (m_configWorkTimes.Count == 0)
            {
                return(true);
            }
            int nMinsToday = DateTime.Now.Hour * 60 + DateTime.Now.Minute;

            foreach (TWorkTimeInterval workItemInterval in m_configWorkTimes)
            {
                if (nMinsToday >= workItemInterval.m_nStart && nMinsToday <= workItemInterval.m_nEnd)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 3
0
        public bool OnTick()
        {
            EERROR nRet = CSiteMng.Ontick();

            if (nRet == EERROR.RATE_INVALID)
            {
                if (CFATManager.isOnlineMode())
                {
                    CFATLogger.output_proc("Invalid price!");
                }
                m_nInvalidTicks++;
                return(false);
            }
            if (nRet == EERROR.RATE_END)
            {
                CFATLogger.output_proc("Rates End!");
                m_nInvalidTicks = 10000;
                return(false); // For backtest mode, update tick data , if return false rates is end.
            }
            m_nInvalidTicks = 0;
            if (nRet != EERROR.NONE)
            {
                CFATLogger.output_proc("CSiteMng.Ontick() : Unknown Error!");
                return(false);
            }

            foreach (CLogic objLogic in m_lstLogics)
            {
                if (objLogic.OnTick() == (int)ETRADE_RET.NEWORDER)
                {
                    break;
                }
            }

            CSiteMng.process_ReqOrders();
            CSiteMng.process_ReqPosMatch();
            return(true);
        }