Ejemplo n.º 1
0
        void runopt()
        {
            isRunning = true;
            while (isNextAvail)
            {
                gauntletArgs ga = new gauntletArgs(DLL, RNAME, SIM);
                ga.value = NextParam;
                ga.id    = id;
                Response r = ResponseLoader.FromDLL(ga.response, ga.dll);
                if (changeVars(ref r, ga.value))
                {
                    //GauntletEngine ge = new GauntletEngine(r, ga.hsim);
                    //Thread.SpinWait(1000);
                    //debugControl1.GotDebug("Starting a Gauntlet instance");
                    debug("Started Gauntlet Engine: " + ga.id);
                    Go();

                    List <Trade> trades  = SimBroker.GetTradeList();
                    Results      results = Results.ResultsFromTradeList(trades, 0, .01m, new DebugDelegate(debug));

                    GauntletOptimizationResults gor = new GauntletOptimizationResults();
                    gor.parameter         = ga.value;
                    gor.results           = results;
                    gor.resultsCalculated = true;
                    allResults.Add(gor);
                    decimal rv = 0;
                    getresult(results, out rv);
                    debug("optimize " + ga.id + " finished.  Used: " + gor.parameter + " -> " + OptimizeDecisionsName + ": " + rv + " trades: " + gor.results.Trades + " SimsRemaining: " + OptimizeRemain);
                    progress(id, OptimizeCount);
                }
                else
                {
                    debug("Unable to start gauntlet engine: " + ga.id + " with: " + ga.value);
                }
            }
            debug("All optimization runs complete, computing optimum...");
            var sorted = calculateBest(allResults);

            // unbind
            UnbindEvents();
            if (SendOptimizationCompleteEvent != null)
            {
                SendOptimizationCompleteEvent(sorted);
            }
            isRunning = false;
        }
Ejemplo n.º 2
0
        void runopt()
        {
            isRunning = true;
            while (isNextAvail)
            {
                gauntletArgs ga = new gauntletArgs(DLL, RNAME, SIM);
                ga.value = NextParam;
                ga.id = id;
                Response r = ResponseLoader.FromDLL(ga.response, ga.dll);
                if (changeVars(ref r, ga.value))
                {
                    //GauntletEngine ge = new GauntletEngine(r, ga.hsim);
                    //Thread.SpinWait(1000);
                    //debugControl1.GotDebug("Starting a Gauntlet instance");
                    debug("Started Gauntlet Engine: " + ga.id);
                    Go();

                    List<Trade> trades = SimBroker.GetTradeList();
                    Results results = Results.ResultsFromTradeList(trades, 0, .01m, new DebugDelegate(debug));

                    GauntletOptimizationResults gor = new GauntletOptimizationResults();
                    gor.parameter = ga.value;
                    gor.results = results;
                    gor.resultsCalculated = true;
                    allResults.Add(gor);
                    decimal rv = 0;
                    getresult(results, out rv);
                    debug("optimize "+ga.id+" finished.  Used: "+gor.parameter+" -> "+OptimizeDecisionsName+": "+rv+" trades: " + gor.results.Trades + " SimsRemaining: " + OptimizeRemain);
                    progress(id, OptimizeCount);
                }
                else
                    debug("Unable to start gauntlet engine: " + ga.id + " with: " + ga.value);

            }
            debug("All optimization runs complete, computing optimum...");
            var sorted = calculateBest(allResults);
            // unbind
            UnbindEvents();
            if (SendOptimizationCompleteEvent != null)
                SendOptimizationCompleteEvent(sorted);
            isRunning = false;

        }