/// <summary> /// 使用指定的股票历史信息初始化 /// </summary> /// <param name="histories">指定的股票历史信息</param> public void Init(StocksHistory histories) { foreach (IStockHistory hist in histories.GetAllHistories()) { StockMappings_.Add(StringMapping_.GetCharMapping(hist)); } }
void AnalyseHistory() { // Load from DB IEnumerable<int> allStockId = new List<int> { 600238, 600239, 600240, 600007, 600008, 600009, 600010,600019,600020,600021,600022}; StocksHistory histories = new StocksHistory(); histories.Load(allStockId); StockCharMappingAnalyzer analyzer = new StockCharMappingAnalyzer(); analyzer.Init(histories); int firstId = 0; foreach (int stockId in allStockId) { firstId = stockId; break; } IStockHistory history = histories.GetHistory(firstId); if (history == null) { return; } IStockHistory oneWeekHistory = history.GetPartStockHistory(history.MaxDate.AddDays(-7), history.MaxDate); if (oneWeekHistory == null) { return; } analyzer.FindMatches(oneWeekHistory); }
private void RunStrategyOnMultiStocks() { // Load from DB IEnumerable<int> allStockId = new List<int> { 600238, 600239, 600240, 600007, 600008, 600009, 600010,600019,600020,600021,600022}; StocksHistory histories = new StocksHistory(); histories.Load(allStockId); IStrategyFactory factory = StrategyFactoryCreater.Instance().CreateFactory(StrategyFactoryType.Normal); ScoresCalculator calc = new ScoresCalculator(); foreach (IStockHistory hist in histories.GetAllHistories()) { calc.Calc(hist, factory, null); } calc.ShowResult(); }