Beispiel #1
0
        public static List <IStrategy> GetConfigurations()
        {
            List <IStrategy> strategyList          = new List <IStrategy>();
            IFactory         xChangeObjectFactory  = null;
            IFactory         strategyObjectFactory = null;
            IStrategy        stratObj = null;

            //  IExchange xChangeObj = null;

            using (StreamReader file = File.OpenText(configFile))
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    jsonObject = (JObject)JToken.ReadFrom(reader);
                }


            var rootObject = JsonConvert.DeserializeObject <ConfigRoot>(jsonObject.ToString());

            GlobalConfig.SetRootConfig(rootObject);

            //Do Validations here.....  ************************************ NEED CONFIG VALIDATIONS HERE  *********************

            //NEED CONFIG VALIDATIONS HERE

            //******************************************************************************************************************

            foreach (ExchangeConfig xChng in rootObject.Exchanges)
            {
                if (xChng.ActiveStatus)
                {
                    xChangeObjectFactory = new ExchangeFactory();
                    //xChangeObj = xChangeObjectFactory.GetObject<IExchange>(xChng);
                    foreach (StrategyConfig strgyItem in xChng.Strategies)
                    {
                        strategyObjectFactory = new StrategyFactory();
                        if (strgyItem.ActiveStatus)
                        {
                            stratObj = strategyObjectFactory.GetObject <IStrategy>(strgyItem);
                            //xChng.UniqueStrategyId = stratObj.GetStrategyId();
                            stratObj.SetExchangeDetails(xChangeObjectFactory.GetObject <IExchange>(xChng));
                            stratObj.SetConfigPath(configFile);
                            //stratObj.SetStrategyId();
                            strategyList.Add(stratObj);
                        }
                    }
                }
            }
            return(strategyList);
        }