コード例 #1
0
ファイル: ManagerForm.cs プロジェクト: pipseq/csFxModel
        private void runExpert(List<string> pairs,string timeFrame)
        {
            try
            {
                priceProcessor = new PriceProcessor(this, this, fxManager, fxUpdates);
                expertFactory = new ExpertFactory(priceProcessor);
                if (isJournalRead() || isJournalWrite())
                {
                    accumulatorMgr.Snapshot = getProperty("journalFile", "testdata");
                    expertFactory.setJournal(
                        pairs,
                        getProperty("journalFile", "testdata"));
                }
                if (isJournalRead())
                {
                    accumulatorMgr.read();  // load history
                    log.debug("PriceHistory done");
                }

                foreach (string p in pairs)
                {
                    TimeFrame tf = ExpertFactory.TimeFrameInverseMap[timeFrame];
                    ExpertScript es = new ExpertScript(pyfile, p, tf, true);
                    expertFactory.subscribe(es);
                    expertFactory.subscribePrice(es);
                }

                expertFactory.startExperts();
                runStatus(true);

                if (isJournalRead())
                    expertFactory.readJournal();
                else
                {
                    priceProcessor.start(pairs);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error running expert: " + ex.Message);
                return;
            }
        }
コード例 #2
0
ファイル: ManagerForm.cs プロジェクト: pipseq/csFxModel
        private void runCsExpert(List<string> pairs, string timeFrame)
        {
            try
            {
                priceProcessor = new PriceProcessor(this, this, fxManager, fxUpdates);
                expertFactory = new ExpertFactory(priceProcessor);
                if (isJournalRead() || isJournalWrite())
                {
                    accumulatorMgr.Snapshot = getProperty("journalFile", "testdata");
                    expertFactory.setJournal(
                        pairs,
                        getProperty("journalFile", "testdata"));
                }
                if (isJournalRead())
                {
                    accumulatorMgr.read();  // load history
                    log.debug("PriceHistory done");
                }

                ConstructorInfo ci = null;
                string exp = this.comboBoxExpertAttribs.Text;
                string[] ea = exp.Split(';');
                if (ea.Length > 0)
                {
                    string expert = ea[0];
                    Type type = Type.GetType(expert);
                    ci = type.GetConstructor(new Type[] { typeof(string), typeof(TimeFrame) });
                    if (ci == null)
                    {
                        log.error("Invalid or no constructor for selected csExpert " + expert);
                        return;
                    }
                }
                if (simulated)
                foreach (string p in pairs)
                {
                    //TimeFrame tf = ExpertFactory.TimeFrameInverseMap[timeFrame];
                    ExpertBase es = new PriceSimulator(p, TimeFrame.m1);
                    //expertFactory.subscribe(es);
                    expertFactory.subscribePrice(es);
                }
                foreach (string p in pairs)
                {
                    TimeFrame tf = ExpertFactory.TimeFrameInverseMap[timeFrame];
                    ExpertBase es = (ExpertBase)ci.Invoke(new object[] { p, tf });
                    expertFactory.subscribe(es);
                    expertFactory.subscribePrice(es);
                }

                expertFactory.startExperts();
                runStatus(true);

                if (isJournalRead())
                    expertFactory.readJournal();
                else
                {
                    priceProcessor.start(pairs);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error running expert: " + ex.Message);
                return;
            }
        }