/// <summary> /// Default Constructor /// </summary> public StrategyController() { //_asyncClassLogger = ContextRegistry.GetContext()["OEEClientLogger"] as AsyncClassLogger; _asyncClassLogger = new AsyncClassLogger("StrategyController"); if (_asyncClassLogger != null) { _asyncClassLogger.SetLoggingLevel(); //set logging path string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\TradeHub Logs\\Client"; _asyncClassLogger.LogDirectory(path); } _strategiesCollection = new ConcurrentDictionary <string, StrategyExecutor>(); _disruptor = new Disruptor <Execution>(() => new Execution(new Fill(new Security(), "", ""), new Order("")), _ringSize, TaskScheduler.Default); _disruptor.HandleEventsWith(this); _ringBuffer = _disruptor.Start(); #region Event Aggregator EventSystem.Subscribe <LoadStrategy>(LoadUserStrategy); EventSystem.Subscribe <InitializeStrategy>(InitializeUserStrategy); EventSystem.Subscribe <RunStrategy>(RunUserStrategy); EventSystem.Subscribe <StopStrategy>(StopUserStrategy); EventSystem.Subscribe <string>(ManageUserCommands); #endregion }
/// <summary> /// Argument Constructor /// </summary> /// <param name="session"></param> /// <param name="logger"></param> public SessionStatusListener(O2GSession session, AsyncClassLogger logger) { _session = session; _logger = logger; Reset(); _syncSessionEvent = new EventWaitHandle(false, EventResetMode.AutoReset); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="eventHandler">Event handler which will receive requested data</param> /// <param name="localPersistance">Indicates whether the data to be saved locally on initial request</param> public DataHandler(IEventHandler <MarketDataObject>[] eventHandler, bool localPersistance = false) { try { _classLogger = new AsyncClassLogger("SimulatedDataHandler"); // Set logging level _classLogger.SetLoggingLevel(); //set logging path _classLogger.LogDirectory(DirectoryStructure.CLIENT_LOGS_LOCATION); _persistanceDataCount = 0; _localPersistance = localPersistance; _localPersistanceData = new SortedDictionary <int, MarketDataObject>(); _tasksCollection = new ConcurrentBag <Task>(); _fetchMarketData = new FetchData(new ReadMarketData(_classLogger), _classLogger); // Initialize Lists BarSubscriptionList = new List <string>(); TickSubscriptionList = new List <string>(); _fetchMarketData.InitializeDisruptor(eventHandler); _fetchMarketData.HistoricalDataFired += HistoricDataArrived; } catch (Exception exception) { _classLogger.Error(exception, _type.FullName, "DataHandler"); } }
/// <summary> /// Argument Constructor /// </summary> /// <param name="strategyType"></param> /// <param name="ctorArguments"></param> public TestStrategyExecutor(Type strategyType, object[] ctorArguments) { // Initialize parameters //TestStrategyInitializeParameters(strategyType,ctorArguments); _manualReset = new ManualResetEvent(false); _asyncClassLogger = new AsyncClassLogger("TestStrategyExecutor"); // Save Strategy Type _strategyType = strategyType; //Save Arguments _ctorArguments = ctorArguments; // Set Logging levels _asyncClassLogger.SetLoggingLevel(); // Get new strategy instance var strategyInstance = StrategyHelper.CreateStrategyInstance(_strategyType, _ctorArguments); if (strategyInstance != null) { // Cast to TradeHubStrategy Instance TradeHubStrategy = strategyInstance as TradeHubStrategy; InitializeStrategyListeners(); OverrideMarketRequestCalls(); OverrideOrderRequestCalls(); } }
/// <summary> /// Default Constructor /// </summary> public DataHandler() { try { _classLogger = new AsyncClassLogger("DataHandler"); _classLogger.SetLoggingLevel(); //set logging path string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\TradeHub Logs\\Client"; _classLogger.LogDirectory(path); _fetchMarketData = new FetchData(new ReadMarketData(_classLogger), _classLogger); // Initialize Lists BarSubscriptionList = new List <string>(); TickSubscriptionList = new List <string>(); _fetchMarketData.InitializeDisruptor(new IEventHandler <MarketDataObject>[] { this }); _fetchMarketData.HistoricalDataFired += HistoricDataArrived; } catch (Exception exception) { _classLogger.Error(exception, _type.FullName, "DataHandler"); } }
/// <summary> /// Initializes necessary fields and parameters /// </summary> /// <param name="strategyType">User Strategy Type</param> /// <param name="ctorArguments">Constructor arguments to initialize strategy</param> private void Initialize(Type strategyType, object[] ctorArguments) { _manualReset = new ManualResetEvent(false); _logger = new AsyncClassLogger("StrategyExecutorGeneticAlgo"); _logger.SetLoggingLevel(); // Save Strategy Type _strategyType = strategyType; //Save Arguments _ctorArguments = ctorArguments; // Set Logging levels _logger.SetLoggingLevel(); // Get new strategy instance var strategyInstance = StrategyHelper.CreateStrategyInstance(_strategyType, _ctorArguments); if (strategyInstance != null) { // Cast to TradeHubStrategy Instance _tradeHubStrategy = strategyInstance as TradeHubStrategy; InitializeStrategyListeners(); OverrideMarketRequestCalls(); OverrideOrderRequestCalls(); } }
/// <summary> /// Argument Constructor /// </summary> /// <param name="orderExecutionEngineClient">OEE-Client for communication with the OEE-Server</param> public OrderExecutionService(OrderExecutionEngineClient orderExecutionEngineClient) { _asyncClassLogger = new AsyncClassLogger("OrderExecutionService"); // Set logging level _asyncClassLogger.SetLoggingLevel(); // Set logging path _asyncClassLogger.LogDirectory(TradeHubConstants.DirectoryStructure.CLIENT_LOGS_LOCATION); InitializeDistuptor(new IEventHandler <RabbitMqRequestMessage>[] { this }); // save order execution client _executionEngineClient = orderExecutionEngineClient; // Initialize local map _ordersMap = new ConcurrentDictionary <string, Order>(); // Register Local Event _sendMarketOrderRequest += SendMarketOrderRequest; _sendLimitOrderRequest += SendLimitOrderRequest; _sendCancelOrderRequest += SendCancelOrderRequest; _sendOrderRequests += SendOrderRequests; // Register required OEE-Client Events RegisterExecutionEngineClientEvents(); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="logger">logger instance of the calling class</param> public BarData(AsyncClassLogger logger) { // Save instance _logger = logger; // Set provider name to be used in all calls _marketDataProviderName = Constants.MarketDataProvider.IqFeed; }
/// <summary> /// Argument Constructor /// </summary> public PriceListener(O2GTableManager tableManager, AsyncClassLogger logger) { // Save reference _logger = logger; _tableManager = tableManager; // Initialize _subscriptionList = new List <string>(); }
/// <summary> /// Constructor: /// Loads Setting From Xml File /// </summary> /// <param name="readMarketData"></param> /// <param name="classLogger"> </param> public FetchData(ReadMarketData readMarketData, AsyncClassLogger classLogger) { try { _classLogger = classLogger; _readMarketData = readMarketData; //Reading Settings From Xml File string path = "MarketDataConfiguration\\MarketDataController.xml"; XDocument doc; if (File.Exists(path)) { _classLogger.Info("1st", _type.FullName, "FetchData"); doc = XDocument.Load("MarketDataConfiguration\\MarketDataController.xml"); } else { _classLogger.Info("2nd", _type.FullName, "FetchData"); doc = XDocument.Load("..\\Strategy Runner\\MarketDataConfiguration\\MarketDataController.xml"); } var startDate = doc.Descendants("StartDate"); foreach (var xElement in startDate) { string[] start = xElement.Value.Split(','); _startDate = new DateTime(Convert.ToInt32(start[0]), Convert.ToInt32(start[1]), Convert.ToInt32(start[2])); if (_classLogger.IsInfoEnabled) { _classLogger.Info("StartDate:" + _startDate.ToString(CultureInfo.InvariantCulture), _type.FullName, "FetchData"); } } var endDate = doc.Descendants("EndDate"); foreach (var xElement in endDate) { string[] end = xElement.Value.Split(','); _endDate = new DateTime(Convert.ToInt32(end[0]), Convert.ToInt32(end[1]), Convert.ToInt32(end[2])); if (_classLogger.IsInfoEnabled) { _classLogger.Info("EndDate:" + _endDate.ToString(CultureInfo.InvariantCulture), _type.FullName, "FetchData"); } } var provider = doc.Descendants("Provider"); foreach (var xElement in provider) { _providerName = xElement.Value; if (_classLogger.IsInfoEnabled) { _classLogger.Info("ProviderName:" + _providerName.ToString(CultureInfo.InvariantCulture), _type.FullName, "FetchData"); } } } catch (Exception exception) { _classLogger.Error(exception, _type.FullName, "FetchData"); } }
/// <summary> /// Default Constructor /// </summary> public RediMarketDataProvider() { // Set provider name to be used in all calls _marketDataProviderName = Constants.MarketDataProvider.Redi; // Create object for logging details _logger = new AsyncClassLogger("RediDataProvider"); _logger.SetLoggingLevel(); _logger.LogDirectory(Constants.DirectoryStructure.MDE_LOGS_LOCATION); }
/// <summary> /// Default Constructor /// </summary> public FxcmMarketDataProvider() { // Create object for logging details _logger = new AsyncClassLogger("FxcmDataProvider"); _logger.SetLoggingLevel(); _logger.LogDirectory(Constants.DirectoryStructure.MDE_LOGS_LOCATION); // Set provider name _marketDataProviderName = Constants.MarketDataProvider.Fxcm; }
/// <summary> /// Argument Constructor /// </summary> public ConfigurationReader(string oeeServerConfig, string clientConfig, AsyncClassLogger asyncClassLogger) { _asyncClassLogger = asyncClassLogger; _oeeServerConfig = oeeServerConfig; _clientConfig = clientConfig; // Initialize values _clientMqParameters = new Dictionary <string, string>(); _oeeMqServerparameters = new Dictionary <string, string>(); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="positionEngineClient">Client to communicates with Position Engine</param> public PositionEngineService(PositionEngineClient positionEngineClient) { _positionEngineClient = positionEngineClient; _asyncClassLogger = new AsyncClassLogger("PEServiceLogger"); _asyncClassLogger.SetLoggingLevel(); // Subscribe Client Events RegisterClientEvents(); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="session"></param> /// <param name="logger"></param> public HistoricalDataListener(O2GSession session, AsyncClassLogger logger) { _session = session; _logger = logger; _requestId = string.Empty; _response = null; _syncResponseEvent = new EventWaitHandle(false, EventResetMode.AutoReset); _barCollection = new List <Bar>(); }
/// <summary> /// Default Constructor /// </summary> public FxcmOrderExecutionProvider() { // Create object for logging details _logger = new AsyncClassLogger("FxcmDataProvider"); _logger.SetLoggingLevel(); _logger.LogDirectory(Constants.DirectoryStructure.MDE_LOGS_LOCATION); // Set provider name _provider = Constants.OrderExecutionProvider.Fxcm; _fixSettingsFile = AppDomain.CurrentDomain.BaseDirectory + @"\Config\" + "FxcmFIXSettings.txt"; }
/// <summary> /// Argument Constructor /// </summary> /// <param name="queue"></param> /// <param name="user"> </param> /// <param name="password"> </param> /// <param name="ipAddress"> </param> /// <param name="port"> </param> /// <param name="asyncClassLogger"></param> public SocketCommunication(Queue queue, string user, string password, string ipAddress, int port, AsyncClassLogger asyncClassLogger) { _queue = queue; _user = user; _password = password; _apiPort = port; _asyncClassLogger = asyncClassLogger; _apiHost = ipAddress; _client = null; _heartbeatTimer.Interval = 1000; _reconnectTimer.Interval = 900000; }
/// <summary> /// Argument Constructor /// </summary> /// <param name="logger">logger instance of the calling class</param> public HistoricalData(AsyncClassLogger logger) { // Save instance _logger = logger; // Set provider name to be used in all calls _marketDataProviderName = Constants.MarketDataProvider.IqFeed; // Initialize _barCollection = new List <Bar>(); _requestIdToSymbolsMap = new Dictionary <string, string>(); }
/// <summary> /// Default Argument /// </summary> public OptimizationManagerBruteForce() { //_asyncClassLogger = ContextRegistry.GetContext()["StrategyRunnerLogger"] as AsyncClassLogger; _asyncClassLogger = new AsyncClassLogger("OptimizationManagerBruteForce"); // Initialize _ctorArguments = new List <object[]>(); _strategiesCollection = new ConcurrentDictionary <string, StrategyExecutor>(); // Subscribe to event aggregator EventSystem.Subscribe <OptimizeStrategyBruteForce>(StartOptimization); }
/// <summary> /// Default Constructor /// </summary> public TradierMarketDataProvider() { // Set provider name to be used in all calls _marketDataProviderName = Constants.MarketDataProvider.Tradier; // Create object for logging details _logger = new AsyncClassLogger("TradierDataProvider"); _logger.SetLoggingLevel(); _logger.LogDirectory(Constants.DirectoryStructure.MDE_LOGS_LOCATION); // Initialize local list/queue for subscriptions _subscribedSymbols = new List <string>(); }
/// <summary> /// Default Argument /// </summary> public OptimizationManagerBruteForce() { _currentDispatcher = Dispatcher.CurrentDispatcher; _asyncClassLogger = new AsyncClassLogger("OptimizationManagerBruteForce"); _asyncClassLogger.SetLoggingLevel(); _asyncClassLogger.LogDirectory(DirectoryStructure.CLIENT_LOGS_LOCATION); // Initialize _ctorArguments = new List <object[]>(); _strategiesCollection = new ConcurrentDictionary <string, StrategyExecutor>(); // Subscribe to event aggregator EventSystem.Subscribe <BruteForceParameters>(StartOptimization); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="server">OEE Server Config file</param> /// <param name="client">OEE Client MQ Config File</param> public OrderExecutionEngineClient(string server = "OEEServer.xml", string client = "OEEClientMqConfig.xml") { _asyncClassLogger = new AsyncClassLogger("OrderExecutionClient"); // Set logging level // Set logging path _asyncClassLogger.LogDirectory(TradeHubConstants.DirectoryStructure.CLIENT_LOGS_LOCATION); _asyncClassLogger.SetLoggingLevel(); // Get Configuration details _configurationReader = new ConfigurationReader(server, client, _asyncClassLogger); _configurationReader.ReadParameters(); // Get MQ Server object _mqServer = new OrderExecutionClientMqServer(_configurationReader.OeeMqServerparameters, _configurationReader.ClientMqParameters, _asyncClassLogger); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="applicationId">Unique Application ID</param> /// <param name="asyncClassLogger">Class level logger for order client</param> /// <param name="heartbeatInterval">Duration between successive Heartbeats in milliseconds</param> public ClientHeartBeatHandler(string applicationId, AsyncClassLogger asyncClassLogger, int heartbeatInterval = 60000) { _asyncClassLogger = asyncClassLogger; _heartbeatInterval = heartbeatInterval; // Initialize _heartbeatTimer = new Timer(); _serverResponseTimer = new Timer(); _heartbeatMessage = new HeartbeatMessage(); _heartbeatMessage.ApplicationId = applicationId; _heartbeatTimer.Elapsed += OnHeartbeatTimerElapsed; _serverResponseTimer.Elapsed += OnServerResponseTimerElapsed; }
/// <summary> /// Argument Constructor /// </summary> /// <param name="marketDataEngineClient">MDE-Client for communication with the MDE-Server</param> public HistoricalDataService(MarketDataEngineClient marketDataEngineClient) { _asyncClassLogger = new AsyncClassLogger("HistoricalDataService"); // Set logging level _asyncClassLogger.SetLoggingLevel(); //set logging path _asyncClassLogger.LogDirectory(DirectoryStructure.CLIENT_LOGS_LOCATION); // Initialize objects _subscriptionRequests = new ConcurrentDictionary <string, HistoricDataRequest>(); // Copy reference _dataEngineClient = marketDataEngineClient; // Register required MDE-Client Events RegisterDataEngineClientEvents(); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="server">MDE Server Config file</param> /// <param name="client">MDE Client MQ Config File</param> public MarketDataEngineClient(string server = "MDEServer.xml", string client = "ClientMqConfig.xml") { _asyncClassLogger = new AsyncClassLogger("MarketDataClient"); if (_asyncClassLogger != null) { _asyncClassLogger.SetLoggingLevel(); //set logging path _asyncClassLogger.LogDirectory(TradeConstants.DirectoryStructure.CLIENT_LOGS_LOCATION); } // Get Configuration details _configurationReader = new ConfigurationReader(server, client); _configurationReader.ReadParameters(); // Get MQ Server object _mqServer = new ClientMqServer(_configurationReader.MdeMqServerparameters, _configurationReader.ClientMqParameters, _asyncClassLogger); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="strategyKey">Unique Key to Identify the Strategy Instance</param> /// <param name="strategyType">C# Class Type which implements TradeHubStrategy.cs</param> /// <param name="ctorArguments">Holds selected ctor arguments to execute strategy</param> public StrategyExecutor(string strategyKey, Type strategyType, object[] ctorArguments) { //_asyncClassLogger = ContextRegistry.GetContext()["StrategyRunnerLogger"] as AsyncClassLogger; _asyncClassLogger = new AsyncClassLogger("StrategyExecutor"); { _asyncClassLogger.SetLoggingLevel(); //set logging path string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\TradeHub Logs\\Client"; _asyncClassLogger.LogDirectory(path); } _tradeHubStrategy = null; _strategyKey = strategyKey; _strategyType = strategyType; _ctorArguments = ctorArguments; _strategyStatus = Infrastructure.Constants.StrategyStatus.None; // Initialize statistics _statistics = new Statistics(_strategyKey); // Initialze Utility Classes //_orderExecutor = new OrderExecutor(_asyncClassLogger); _orderExecutor = new OrderExecutorGeneric(); _marketDataListener = new MarketDataListener(_asyncClassLogger); _orderRequestListener = new OrderRequestListener(_orderExecutor, _asyncClassLogger); // Use MarketDataListener.cs as Event Handler to get data from DataHandler.cs _dataHandler = new DataHandler( new IEventHandler <TradeHub.Common.HistoricalDataProvider.ValueObjects.MarketDataObject>[] { _marketDataListener }); _marketDataListener.BarSubscriptionList = _dataHandler.BarSubscriptionList; _marketDataListener.TickSubscriptionList = _dataHandler.TickSubscriptionList; // Initialize MarketRequestListener.cs to manage incoming market data requests from strategy _marketRequestListener = new MarketRequestListener(_dataHandler, _asyncClassLogger); //Register OrderExecutor Events RegisterOrderExecutorEvents(); //Register Market Data Listener Events RegisterMarketDataListenerEvents(); }
/// <summary> /// Argument Constructor /// </summary> /// <param name="strategyInstance">Holds necessary information for Instance Execution and UI-Update</param> /// <param name="currentDispatcher"></param> public StrategyExecutor(StrategyInstance strategyInstance, Dispatcher currentDispatcher) { this._currentDispatcher = currentDispatcher; _asyncClassLogger = new AsyncClassLogger("StrategyExecutor"); //set logging path string path = DirectoryStructure.CLIENT_LOGS_LOCATION; _asyncClassLogger.SetLoggingLevel(); _asyncClassLogger.LogDirectory(path); _tradeHubStrategy = null; _strategyInstance = strategyInstance; _strategyKey = _strategyInstance.InstanceKey; _strategyType = _strategyInstance.StrategyType; _ctorArguments = _strategyInstance.GetParameterValues(); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { Close(); } // Release unmanaged resources. _asyncClassLogger = null; _marketDataListener = null; _marketRequestListener = null; _dataHandler = null; _tradeHubStrategy = null; _currentDispatcher = null; _disposed = true; } }
public IqFeedMarketDataProvider() { // Create object for logging details _logger = new AsyncClassLogger("IqFeedDataProvider"); _logger.SetLoggingLevel(); _logger.LogDirectory(Constants.DirectoryStructure.MDE_LOGS_LOCATION); // Set provider name _marketDataProviderName = Constants.MarketDataProvider.IqFeed; // Object will be used for connecting to local IQ Feed Connector application _connectionForm = new ConnectionForm(_logger); // Initialize Data classes _levelOneData = new LevelOneData(_logger); _barData = new BarData(_logger); _historicalData = new HistoricalData(_logger); // Register local events SubscribeLocalDataEvents(); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // Make sure event is only subscribed once EventSystem.Unsubscribe <BruteForceParameters>(StartOptimization); _ctorArguments.Clear(); _strategiesCollection.Clear(); } // Release unmanaged resources. _asyncClassLogger = null; _ctorArguments = null; _strategiesCollection = null; _currentDispatcher = null; _disposed = true; } }