public async Task <ActionResult> ExchangePairsExchangeSymbols(string exchange) { JArray symbolArray = new JArray(); IExchangeAPI api = ExchangeAPI.GetExchangeAPI(exchange); var exchangeCoins = await api.GetMarketSymbolsAsync(); foreach (var coin in exchangeCoins) { symbolArray.Add(coin); } return(new JsonResult(symbolArray)); }
protected static async Task <string[]> ValidateMarketSymbolsAsync(IExchangeAPI api, string[] marketSymbols, bool isWebSocket = false) { var apiSymbols = (await api.GetMarketSymbolsAsync(isWebSocket)).ToArray(); if (marketSymbols is null || marketSymbols.Length == 0) { return(apiSymbols); } return(ValidateMarketSymbolsInternal(api, marketSymbols, apiSymbols) .ToArray()); }
private async Task TestMarketSymbols(IExchangeAPI api, string marketSymbol) { if (FunctionRegex == null || Regex.IsMatch("symbol", FunctionRegex, RegexOptions.IgnoreCase)) { Console.Write("Test {0} GetSymbolsAsync... ", api.Name); IReadOnlyCollection <string> symbols = (await api.GetMarketSymbolsAsync()) .ToArray(); Assert(symbols.Count != 0 && symbols.Contains(marketSymbol, StringComparer.OrdinalIgnoreCase)); Console.WriteLine($"OK (default: {marketSymbol}; {symbols.Count} symbols)"); } }
private static string[] ValidateMarketSymbols(IExchangeAPI api, string[] marketSymbols) { string[] apiSymbols = api.GetMarketSymbolsAsync().Sync().ToArray(); if (marketSymbols == null || marketSymbols.Length == 0) { marketSymbols = apiSymbols; } foreach (string marketSymbol in marketSymbols) { if (!apiSymbols.Contains(marketSymbol)) { throw new ArgumentException(string.Format("Symbol {0} does not exist in API {1}, valid symbols: {2}", marketSymbol, api.Name, string.Join(",", apiSymbols.OrderBy(s => s)))); } } return(marketSymbols); }
/// <summary> /// Constructor /// </summary> /// <param name="api">Exchange API</param> /// <param name="marketSymbol">The market symbol to trade by default, can be null</param> public ExchangeInfo(IExchangeAPI api, string marketSymbol = null) { API = api; MarketSymbols = api.GetMarketSymbolsAsync().Sync().ToArray(); TradeInfo = new ExchangeTradeInfo(this, marketSymbol); }