protected override void OnStart(string[] args) { var logger = new Logger("RuleEngine"); Name = "RuleEngine"; Config.LoadConfiguration(logger); Repository = new DataRepository(); Repository.Klines = new Queue <Kline>(); Rabbit = new RabbitClient(logger, Name, Config.RabbitExchanges, Repository); var runner = new PatternRunner(logger, Repository); var dbHandler = new DataHandler(logger); if (Config.UseSql) { dbHandler.SavePatterns(runner.PatternRepository); } Rabbit.KlineReceived += runner.OnKlineReceived; Model = Rabbit.Connect(); Rabbit.InitializeConsumer(Name, Model, Repository); logger.Info("*********************************"); logger.Info("Rule Engine Started Successfully"); logger.Info("*********************************"); System.Timers.Timer timer = new System.Timers.Timer(100); timer.AutoReset = true; timer.Enabled = true; timer.Elapsed += Timer_Elapsed; }
private void PublishKlines(List <Kline> klineList, PatternRunner runner) { foreach (var kline in klineList) { runner.RunMultiplePatterns(kline); } runner.PublishResults(); foreach (var pattern in runner.PatternRepository) { logger.Info(string.Format("TOTAL PROFIT OF ALL TRADES for {0} : {1}%", pattern.Value.Engine.Name, pattern.Value.Engine.TradeResults.Sum())); } }
public void RunTest(ILogger logger, Dictionary <string, IPattern> patterns, string path) { KlineList = fileAnalyzer.GenerateKlinesFromCsv(logger, path); DataRepository dataRepository = new DataRepository(); //InitializePatternConfiguration(settings); var runner = new PatternRunner(logger, dataRepository); logger.InitializeStatsReport(); runner.PatternRepository = patterns; new Thread(() => { int i = 0; while (!Stop && i < 1) { PublishKlines(KlineList, runner); i++; } }).Start(); }