private void StartAutoMarketLoaderThread() { // Declare the MarketLoader class to be threaded var marketLoader = new AutoMarketLoader( betfairAPI.GetSessionToken(), settings.GetAllMarketsConfiguration, settings.StrategyLoadPaterns); // Create the thread and start it var marketLoaderThread = new Thread(marketLoader.Start); marketLoaderThread.Start(); // Now lets store the thread so that we can access it later LigniteEngineThreads.Add("MARKET_LOADER", marketLoaderThread); // Notify the user SendMessage(String.Format("MARKET_LOADER: Auto Market Loader Thread Started. {0}", LigniteEngineThreads.Count)); }
private void StartMarketProcessorThread(int exchangeId, int marketId, StrategyLoadPatern strategy) { // Create the ID to use for this item var processId = String.Format("MARKET_PROCESSOR:{0}:{1}", exchangeId, marketId); if (LigniteEngineThreads.ContainsKey(processId)) { return; } var market = new Market { exchangeId = exchangeId, marketId = marketId }; // Make sure the requested strategy is complete, if not replace empty elements with the default config var defaultPatern = settings.GetDefaultStrategyLoadPatern(); if (strategy.OnMarketLoadActions == null) { strategy.OnMarketLoadActions = defaultPatern.OnMarketLoadActions; } if (strategy.DataLoadPaterns.Default == null) { strategy.DataLoadPaterns.Default = defaultPatern.DataLoadPaterns.Default; } if (strategy.DataLoadPaterns.HasBets == null) { strategy.DataLoadPaterns.HasBets = defaultPatern.DataLoadPaterns.HasBets; } if (strategy.DataLoadPaterns.HasUnmatchedBets == null) { strategy.DataLoadPaterns.HasUnmatchedBets = defaultPatern.DataLoadPaterns.HasUnmatchedBets; } if (strategy.DataLoadPaterns.Inactive == null) { strategy.DataLoadPaterns.Inactive = defaultPatern.DataLoadPaterns.Inactive; } if (strategy.DataLoadPaterns.InPlay == null) { strategy.DataLoadPaterns.InPlay = defaultPatern.DataLoadPaterns.InPlay; } if (strategy.DataLoadPaterns.Suspended == null) { strategy.DataLoadPaterns.Suspended = defaultPatern.DataLoadPaterns.Suspended; } // Declare the MarketLoader class to be threaded var marketProcessor = new MarketProcessor(processId, market, strategy); // Create the thread and start it var marketProcessorThread = new Thread(marketProcessor.Start); marketProcessorThread.Start(); // Now lets store the thread so that we can access it later LigniteEngineThreads.Add(processId, marketProcessorThread); // Notify the user SendMessage(String.Format("New market submitted for processing. ID = {0}", processId)); }