Beispiel #1
0
        private static async void AnalyticsManager_OnUpdate()
        {
            await analyticsUpdateSyncRoot.WaitAsync();

            try
            {
                var updates = new Dictionary <BaseSubscription, SubscriptionUpdateBase>();
                foreach (var subscription in InfoConnectionManager.GetActiveSubscriptions())
                {
                    var update = default(SubscriptionUpdateBase);
                    switch (subscription)
                    {
                    case DepthsSubscription depthsSubscription:
                    {
                        var depth = AnalyticsManager.MarketDepthsManager.GetDepth(depthsSubscription.Market, depthsSubscription.Precision);
                        update = MarketDepthUpdate.Generate(depth, depthsSubscription.Name);
                    }
                    break;

                    case PriceHistorySubscription priceHistorySubscription:
                    {
                        var priceFrames = await AnalyticsManager.PriceHistoryManager.GetPriceHistory(0, priceHistorySubscription.Market, priceHistorySubscription.FramePeriod);

                        update = PriceHistoryUpdate.Generate(priceFrames.frames, priceHistorySubscription.Name);
                    }
                    break;

                    case TradesFeedSubscription tradesFeedSubscription:
                    {
                        var trades = AnalyticsManager.TradesHistoryManager.GetTrades(tradesFeedSubscription.Market);
                        update = TradesFeedUpdate.Generate(trades, tradesFeedSubscription.Name);
                    }
                    break;

                    case AllMarketTickersSubscription allMarketTickersSubscription:
                    {
                        var allTickers = AnalyticsManager.MarketTickersManager.GetAllTickers();
                        update = AllTickersUpdate.Generate(allTickers, allMarketTickersSubscription.Name);
                    }
                    break;

                    case MarketTickerSubscription marketTickerSubscription:
                    {
                        var marketTicker = AnalyticsManager.MarketTickersManager.GetMarketTicker(marketTickerSubscription.Market);
                        update = MarketTickerUpdate.Generate(marketTicker, marketTickerSubscription.Name);
                    }
                    break;
                    }
                    if (update != null)
                    {
                        updates.Add(subscription, update);
                    }
                }
                InfoConnectionManager.SendSubscriptionUpdates(updates);
            }
            finally
            {
                analyticsUpdateSyncRoot.Release();
            }
        }
Beispiel #2
0
 private static void PerformanceStatisticsManager_OnUpdates(PerformanceStatisticsManager.PerformanceStatisticsManagerUpdate updates)
 {
     if (!SubscriptionsManager.TryGetSubscription(PerformanceStatisticsSubscription.SubscriptionName, out var subscription))
     {
         return;
     }
     InfoConnectionManager.SendSubscriptionUpdate(subscription, PerformanceStatisticsUpdate.Generate(updates, PerformanceStatisticsSubscription.SubscriptionName));
 }
Beispiel #3
0
        public AlphaContext(AlphaSettings settings, IStorage storage, StellarDataProviderBase stellarDataProvider, bool useLegacyOrderbook = false)
            : base(settings, storage, stellarDataProvider, useLegacyOrderbook)
        {
            AppState = new AlphaStateManager(this);
            AppState.StateChanged += AppState_StateChanged;

            QuantumHandler = new AlphaQuantumHandler(this);

            ConnectionManager = new ConnectionManager(this);

            SubscriptionsManager  = new SubscriptionsManager();
            InfoConnectionManager = new InfoConnectionManager(this);

            Catchup = new AlphaCatchup(this);

            MessageHandlers = new MessageHandlers <AlphaWebSocketConnection, AlphaContext>(this);

            InfoCommandsHandlers = new InfoCommandsHandlers(this);
        }