public static void AddPoloniex(IEnumerable <CurrencyPair> poloniex) { if (Poloniexes.Count >= 10) { Poloniexes.RemoveAt(0); } Poloniexes.Add(poloniex); }
public static string GetLastPoloneix() { var lengthMaxName = Poloniexes.Last().Select(x => x.SecondCurrency.Length).Max(); var lengthMaxLast = Poloniexes.Last().Select(x => $"{x.Last:F2}".Length).Max(); var lengthMaxPercent = Poloniexes.Last().Select(x => $"{x.PercentChange:F2}".Length).Max(); string FormatItem(CurrencyPair poloniex) => "`" + $"{poloniex.SecondCurrency}" + new string(' ', 3 + lengthMaxName - poloniex.SecondCurrency.Length) + $"{poloniex.Last:F2}$" + new string(' ', 3 + lengthMaxLast - $"{poloniex.Last:F2}".Length) + $"{(100*poloniex.PercentChange):F2}%" + new string(' ', 3 + lengthMaxPercent - $"{poloniex.PercentChange:F2}".Length) + "`"; return(string.Join(Environment.NewLine + Environment.NewLine, Poloniexes.Last().OrderByDescending(z => z.BaseVolume).Select(x => FormatItem(x)))); }