예제 #1
0
        public void ExecuteStrategyFourParameters()
        {
            LoadAssembly(@"StockTraderStrategy\StockTrader.Common.dll");

            if (_strategyType != null)
            {
                // Initialize executor
                _strategyExecutor = new StrategyExecutor(_strategyType, _ctorArguments);

                // Initialize required Optimization parameters
                InitializeOptimizationParameters();

                for (int i = 0; i < 30; i++)
                {
                    _population.RunEpoch();

                    Logger.Info("Iteration Count: " + i, "Optimization", "PopulationIterations");
                }

                Console.WriteLine(_fitnessFunction.Translate(_population.BestChromosome)[0].ToString("F3"));
                Console.WriteLine(_fitnessFunction.Translate(_population.BestChromosome)[1].ToString("F3"));
                Console.WriteLine(_fitnessFunction.Translate(_population.BestChromosome)[2].ToString("F3"));
                Console.WriteLine(_fitnessFunction.Translate(_population.BestChromosome)[3].ToString("F3"));

                Logger.Info(_fitnessFunction.Translate(_population.BestChromosome)[0].ToString("F3"), "Optimization", "BestChromosome");
                Logger.Info(_fitnessFunction.Translate(_population.BestChromosome)[1].ToString("F3"), "Optimization", "BestChromosome");
                Logger.Info(_fitnessFunction.Translate(_population.BestChromosome)[2].ToString("F3"), "Optimization", "BestChromosome");
                Logger.Info(_fitnessFunction.Translate(_population.BestChromosome)[3].ToString("F3"), "Optimization", "BestChromosome");
            }
        }
예제 #2
0
        public void ExecuteStrategySingleIteration()
        {
            LoadAssembly(@"StockTraderStrategy\StockTrader.Common.dll");

            if (_strategyType != null)
            {
                // Initialize executor
                _strategyExecutor = new StrategyExecutor(_strategyType, _ctorArguments);

                // Execute single iteration of the strategy
                _strategyExecutor.ExecuteStrategy(1.5, 0.006, 0.2, 0.005);
            }
        }
예제 #3
0
        public void ExecuteStrategy()
        {
            LoadAssembly(@"C:\Users\Muhammad Bilal\Desktop\StockTrader - Copy\StockTrader.Common.dll");
            List <string> data = new List <string>();

            _strategyExecutor = new StrategyExecutor(_strategyType, _ctorArguments);
            string[] file = File.ReadAllLines(@"C:\Users\Muhammad Bilal\Downloads\matlab_singlepoint_data.csv");
            for (int i = 0; i < file.Length; i++)
            {
                string[] param = file[i].Split(',');

                double alpha   = double.Parse(param[0]);
                double beta    = double.Parse(param[1]);
                double gamma   = double.Parse(param[2]);
                double espilon = double.Parse(param[3]);
                //_ctorArguments = new object[]
                //{
                //    // Chelen Len,   ALPHA    , Shares   , Symbol,   EMA ,GAMMA, EPSILON
                //    (Int32) 100, alpha, (uint) 40, "ERX", (decimal) 45, gamma, espilon,

                //    // Profit Take,  Tolerance,  StartTime, EndTime, HTB Thresh, OPG Thresh   , OPG Venue,   BETA
                //    (float) 0.005, (decimal) 0.005, "9:30", "9:30", (decimal) 10, (decimal) 0.04, "SDOT", beta,

                //    // Entry Slippage, Exit Slippage
                //    (decimal) 0.01, (decimal) 0.01,
                //    "SimulatedExchange", "SimulatedExchange"
                //};
                if (_strategyType != null)
                {
                    // Initialize executor
                    // Execute single iteration of the strategy
                    double   risk  = _strategyExecutor.ExecuteStrategy(alpha, beta, gamma, espilon);
                    string[] lines = new string[1];
                    lines[0] = string.Format("{0},{1},{2},{3},{4},{5}", param[0], param[1], param[2], param[3], param[4],
                                             risk);
                    data.Add(lines[0]);
                    Console.WriteLine(i);
                }
            }
            File.WriteAllLines(@"D:\matlabvsSr.csv", data);
        }
예제 #4
0
 /// <summary>
 /// Argument Constructor
 /// </summary>
 /// <param name="strategyExecutor">Contains strategy reference to be executed</param>
 /// <param name="rangeW">Specifies W variable's range.</param>
 /// <param name="rangeX">Specifies X variable's range.</param>
 /// <param name="rangeY">Specifies Y variable's range.</param>
 /// <param name="rangeZ">Specifies Z variable's range.</param>
 public CustomFitnessFunction(StrategyExecutor strategyExecutor,
                              Range rangeW, Range rangeX, Range rangeY, Range rangeZ)
     : base(rangeW, rangeX, rangeY, rangeZ)
 {
     _strategyExecutor = strategyExecutor;
 }