Пример #1
0
        /// <summary>
        /// This is executed at the start of the application.
        /// It getts all Strategies in AlgoTraderStrategies namespace.
        /// It will hash the code and store it in the DB and return the usable strategies that can be used in trading
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> RefreshStrategyNamesAndIds()
        {
            Dictionary <string, string> result = new Dictionary <string, string>();

            Type[] types = UC.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "AT.AlgoTraderStrategies");


            string baseStrategyText = UC.NormalizeSourceCode(File.ReadAllText(Global.Constants.BaseStrategyPath));
            string baseStrategyMD5  = UC.MD5Hash(baseStrategyText);
            string baseStrategyId   = baseStrategyMD5.Substring(baseStrategyMD5.Length - 6);

            for (int n = 0; n < types.Length; n++)
            {
                string strategyText = UC.NormalizeSourceCode(File.ReadAllText(Global.Constants.StrategiesFolder + types[n].Name + ".cs"));
                string strategyMD5  = UC.MD5Hash(strategyText);
                string strategyId   = strategyMD5.Substring(strategyMD5.Length - 6) + baseStrategyId;
                result.Add(strategyId, types[n].Name);

                DBMethods.InsertStrategyName(strategyId, types[n].Name, UCDT.GetCurrentNanoUnix());
            }



            return(result);
        }