Example #1
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);
            }
        }
Example #2
0
        /// <summary>
        /// Function to optimize.
        /// </summary>
        /// <param name="w">Function W input value.</param>
        /// <param name="x">Function X input value.</param>
        /// <param name="y">Function Y input value.</param>
        /// <param name="z">Function Z input value.</param>
        /// <returns>Returns function output value.</returns>
        /// <remarks>The method should be overloaded by inherited class to
        /// specify the optimization function.</remarks>
        public override double OptimizationFunction(double w, double x, double y, double z)
        {
            double result = 0;

            // Calculate result
            result = _strategyExecutor.ExecuteStrategy(w, x, y, z);

            Logger.Info("ALPHA:   " + w, "Optimization", "FitnessFunction");
            Logger.Info("BETA:    " + x, "Optimization", "FitnessFunction");
            Logger.Info("GAMMA:   " + y, "Optimization", "FitnessFunction");
            Logger.Info("EPSILON: " + z, "Optimization", "FitnessFunction");
            Logger.Info("PNL:     " + result, "Optimization", "FitnessFunction");

            // Return result
            return(result);
        }
Example #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);
        }