Ejemplo n.º 1
0
 public static IStockStrategy CreateStrategy(string name, StockSerie stockSerie, StockOrder lastBuyOrder, bool supportShortSelling)
 {
     IStockStrategy strategy = null;
      try
      {
     if (name.StartsWith("@"))
        return CreateFilteredStrategy(name, stockSerie, lastBuyOrder, supportShortSelling);
     if (strategyList == null)
     {
        GetStrategyList();
     }
     if (strategyList.Contains(name))
     {
        StrategyManager sm = new StrategyManager();
        strategy =
                    (IStockStrategy)
                        sm.GetType().Assembly.CreateInstance("StockAnalyzer.StockStrategyClasses." + name);
        strategy.Initialise(stockSerie, lastBuyOrder, supportShortSelling);
     }
      }
      catch (Exception ex)
      {
     throw new StockAnalyzerException("Failed to create strategy " + name, ex);
      }
      return strategy;
 }
Ejemplo n.º 2
0
        public static List<string> GetStrategyList()
        {
            if (strategyList == null)
             {
            strategyList = new List<string>();
            StrategyManager sm = new StrategyManager();
            foreach (Type t in sm.GetType().Assembly.GetTypes().Where(t => t.GetInterface("IStockStrategy") != null && !t.IsInterface && !t.IsAbstract))
            {
               strategyList.Add(t.Name);
            }
            strategyList.AddRange(GetFilteredStrategyList(true));
             }

             strategyList.Sort();
             return strategyList;
        }