Esempio n. 1
0
        public static TradingStrategyComponentSettings GenerateExampleSettings(
            ITradingStrategyComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException();
            }

            var settings = new TradingStrategyComponentSettings
            {
                Enabled     = false,
                ClassType   = component.GetType().AssemblyQualifiedName,
                Name        = component.Name,
                Description = component.Description
            };

            var interfaces = component.GetType().GetInterfaces()
                             .Where(i => typeof(ITradingStrategyComponent).IsAssignableFrom(i))
                             .Select(i => i.Name);

            settings.ImplementedInterfaces = string.Join(";", interfaces);

            settings.ComponentParameterSettings = ParameterHelper.GetParameterAttributes(component)
                                                  .Select(ParameterSettings.GenerateExampleSettings)
                                                  .ToArray();

            return(settings);
        }
Esempio n. 2
0
        public static CombinedStrategySettings GenerateExampleSettings()
        {
            CombinedStrategy.ForceLoad();

            var settings = new CombinedStrategySettings();

            var allComponents = AppDomain.CurrentDomain.GetAssemblies()
                                .SelectMany(a => a.GetTypes()
                                            .Where(type => type.IsClass &&
                                                   !type.IsAbstract &&
                                                   typeof(ITradingStrategyComponent).IsAssignableFrom(type) &&
                                                   !typeof(ITradingStrategy).IsAssignableFrom(type) &&
                                                   !type.IsInterface &&
                                                   !Attribute.IsDefined(type, typeof(DeprecatedStrategyAttribute))));


            settings.ComponentSettings = allComponents
                                         .OrderBy(t => t, new TradingStrategyComponentComparer())
                                         .Select(c => TradingStrategyComponentSettings.GenerateExampleSettings(
                                                     (ITradingStrategyComponent)Activator.CreateInstance(c)))
                                         .ToArray();

            return(settings);
        }