Ejemplo n.º 1
0
 public static InlineQueryResultArticle ToInlineQueryResult(
     this ICryptoExchange exchange,
     params string[] symbols
     ) =>
 new InlineQueryResultArticle(
     exchange.Name, exchange.Name,
     $"{exchange.Name}\n{exchange.ToTable ( symbols )}".ToMarkdownMessage( )
     );
Ejemplo n.º 2
0
 private async Task OnChangedAsync(ICryptoExchange exchange,
                                   CryptoCoin coin)
 {
     foreach (var service in Services)
     {
         await service.OnChangedAsync(exchange, coin).ConfigureAwait(false);
     }
     Changed?.Invoke(exchange, coin);
 }
Ejemplo n.º 3
0
        protected virtual void Start(ICryptoExchange exchange)
        {
            if (exchange is null)
            {
                return;
            }

            Exchange = exchange;
            Exchange.Subscribe(this);
        }
Ejemplo n.º 4
0
        public override Task OnChangedAsync(ICryptoExchange exchange,
                                            CryptoCoin coin)
        {
            lock ( consoleLock )
            {
                Console.Write($"{exchange.Name,-12}", Color.DodgerBlue);
                Console.WriteLineStyled($" | {coin}", StyleSheet);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 5
0
        public bool TryGetExchange(string exchangeId,
                                   out ICryptoExchange exchange)
        {
            if (Enums.TryParse(exchangeId, out CryptoExchangeId id))
            {
                return(TryGetExchange(id, out exchange));
            }

            exchange = null;

            return(false);
        }
Ejemplo n.º 6
0
 public static IList <IList <object> > ToSheetsRows(this ICryptoExchange exchange)
 {
     return(ToSheetsRows(exchange,
                         coin => new object[]
     {
         coin.LowestAsk,
         coin.HighestBid,
         coin.Rate,
         $"{coin.Time:G}",
         coin.Spread,
         coin.SpreadPercentage
     }));
 }
Ejemplo n.º 7
0
        public static string GetSummary(this ICryptoExchange exchange)
        {
            var sb = new StringBuilder( );

            sb.AppendLine($"Name: {exchange.Name}");
            sb.AppendLine($"Is Running: {exchange.IsStarted}");
            sb.AppendLine($"Url: {exchange.Url}");
            sb.AppendLine($"Up Time: {exchange.UpTime.Humanize ( 2, minUnit: TimeUnit.Second )}");
            sb.AppendLine($"Last Change: {exchange.LastChangeDuration.Humanize ( 2 )}");
            sb.AppendLine($"Base Symbols: {exchange.BaseSymbols.Humanize ( )}");
            sb.AppendLine($"Total Pairs: {exchange.Count}");

            return(sb.ToString( ));
        }
        protected override void Start(ICryptoExchange exchange)
        {
            if (exchange is null)
            {
                return;
            }

            base.Start(exchange);

            if (LastSignificantPrice is null)
            {
                LastSignificantPrice = new ConcurrentDictionary <string, CryptoCoin> (
                    exchange.ExchangeData
                    .Where(x => Symbols.Contains(x.Key))
                    );
            }
        }
Ejemplo n.º 9
0
        public override async Task OnChangedAsync(ICryptoExchange exchange,
                                                  CryptoCoin coin)
        {
            if (DateTime.UtcNow - LastUpdate < Config.UpdateFrequency)
            {
                return;
            }
            LastUpdate = DateTime.UtcNow;

            try
            {
                var valueRanges = GetValueRangeToUpdate( );
                await UpdateSheetAsync(valueRanges).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Ejemplo n.º 10
0
 public static IList <IList <object> > ToSheetsRows(this ICryptoExchange exchange,
                                                    Func <CryptoCoin, IList <object> > selector)
 {
     return(exchange
            .Markets
            .BaseSymbols
            .OrderBy(x => x)
            .SelectMany(x => exchange
                        .Markets
                        .Data[x]
                        .OrderBy(y => y.Key)
                        .Select(y => (IList <object>)selector(y.Value)
                                .Prepend(x)
                                .Prepend(y.Key)
                                .ToList( )))
            .Prepend(new List <object> ( ))
            .Prepend(new List <object> {
         $"{exchange.Name} ({exchange.Count})"
     })
            .ToList( ));
 }
Ejemplo n.º 11
0
 public bool TryGetExchange(CryptoExchangeId exchangeId,
                            out ICryptoExchange exchange) =>
 Exchanges.TryGetValue(exchangeId, out exchange);
Ejemplo n.º 12
0
 public virtual Task OnChangedAsync(ICryptoExchange exchange,
                                    CryptoCoin coin) =>
 Task.CompletedTask;