public override async void OnNext(CryptoCoin coin)
        {
            if (!Symbols.Contains(coin.Symbol))
            {
                return;
            }

            if (!LastSignificantPrice.ContainsKey(coin.Symbol))
            {
                LastSignificantPrice[coin.Symbol] = coin;
            }

            var change     = PriceChange.Difference(coin, LastSignificantPrice[coin.Symbol]);
            var percentage = Math.Abs(change.Percentage);

            if (percentage >= Threshold)
            {
                var previous = LastSignificantPrice[coin.Symbol].Clone( );
                LastSignificantPrice[coin.Symbol] = coin.Clone( );

                await OnTriggerAsync(previous.Clone( ), coin.Clone( )).ConfigureAwait(false);

                Trigger?.Invoke(this, previous.Clone( ), coin.Clone( ));
            }
        }
Exemple #2
0
        public override void OnNext(CryptoCoin coin)
        {
            if (!Coins.Contains(coin.Id))
            {
                return;
            }

            if (!LastSignificantPrice.ContainsKey(coin.Id))
            {
                LastSignificantPrice[coin.Id] = coin.Clone( );
                Changed?.Invoke(this, null, coin.Clone( ));
            }

            var change     = coin - LastSignificantPrice[coin.Id];
            var percentage = Math.Abs(change.Percentage);

            Updated?.Invoke(this, LastSignificantPrice[coin.Id].Clone( ), coin.Clone( ));

            if (percentage >= Threshold)
            {
                Changed?.Invoke(this, LastSignificantPrice[coin.Id].Clone( ), coin.Clone( ));
                LastSignificantPrice[coin.Id] = coin.Clone( );
                Logger.Info(
                    $"Invoked subscription for {UserName} @ {coin.Average:C} {coin.Symbol} {Exchange.Name}"
                    );
            }
        }
Exemple #3
0
            public void Process(CryptoCoin coin)
            {
                if (!LastSignificantPrice.ContainsKey(coin.Symbol))
                {
                    LastSignificantPrice[coin.Symbol] = coin.Clone( );
                }

                var change     = coin - LastSignificantPrice[coin.Symbol];
                var percentage = Math.Abs(change.Percentage);

                if (percentage >= Threshold)
                {
                    Changed?.BeginInvoke(Exchange, LastSignificantPrice[coin.Symbol], coin, null, null);
                    LastSignificantPrice[coin.Symbol] = coin.Clone( );
                }
            }