public async Task Invoke(HttpContext context, ITradeStrategyCacheManager tradeStrategyCacheManager)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (tradeStrategyCacheManager == null)
            {
                throw new ArgumentNullException(nameof(tradeStrategyCacheManager));
            }

            try
            {
                var json = context.Request.Form["strategyparameters"];

                var strategyParameters = JsonConvert.DeserializeObject <StrategyParameters>(json);

                if (tradeStrategyCacheManager.TryGetTradeStrategy(strategyParameters.StrategyName, out ITradeStrategy tradeStrategy))
                {
                    await context.Response.WriteAsync("YES").ConfigureAwait(false);
                }
                else
                {
                    await context.Response.WriteAsync("NO").ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                var response = context.Response;
                response.ContentType = "application/json";
                response.StatusCode  = (int)HttpStatusCode.InternalServerError;
                await response.WriteAsync(JsonConvert.SerializeObject(ex)).ConfigureAwait(false);
            }
        }
Example #2
0
        public ServerManager(IServerMonitor serverMonitor,
                             IBatchNotification <ServerNotification> serverBatchNotificationPublisher,
                             ITradeStrategyCacheManager tradeStrategyCacheManager,
                             StrategyNotificationHub strategyNotificationHub,
                             ServerNotificationHub serverNotificationHub)
        {
            ServerMonitor = serverMonitor;

            this.serverBatchNotificationPublisher = serverBatchNotificationPublisher;
            this.tradeStrategyCacheManager        = tradeStrategyCacheManager;
            this.strategyNotificationHub          = strategyNotificationHub;
            this.serverNotificationHub            = serverNotificationHub;

            disposables = new List <IDisposable>();

            ObserverTradeStrategyCacheManager();
            ObserverStrategyNotificationHub();
            ObserverServerNotificationHub();
        }
Example #3
0
        public StrategyRunner(
            IBatchNotificationFactory <StrategyNotification> batchNotificationFactory,
            ISubscriptionsCacheManager subscriptionsCacheManager,
            ITradeStrategyCacheManager tradeStrategyCacheManager)
        {
            if (batchNotificationFactory == null)
            {
                throw new ArgumentNullException(nameof(batchNotificationFactory));
            }

            this.subscriptionsCacheManager = subscriptionsCacheManager ?? throw new ArgumentNullException(nameof(subscriptionsCacheManager));
            this.tradeStrategyCacheManager = tradeStrategyCacheManager ?? throw new ArgumentNullException(nameof(tradeStrategyCacheManager));

            strategyLogger = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyLogger);
            strategyAccountInfoPublisher        = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyAccountInfoPublisher);
            strategyCustomNotificationPublisher = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyCustomNotificationPublisher);
            strategyNotificationPublisher       = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyNotificationPublisher);
            strategyOrderBookPublisher          = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyOrderBookPublisher);
            strategyTradePublisher           = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyTradePublisher);
            strategyStatisticsPublisher      = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyStatisticsPublisher);
            strategyCandlesticksPublisher    = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyCandlesticksPublisher);
            strategyParameterUpdatePublisher = batchNotificationFactory.GetBatchNotifier(BatchNotificationType.StrategyParameterUpdatePublisher);
        }