Binance api 仅获取 USDT 对 - 通过仅从最后 4 个字母为 USDT 的交易品种获取数据来实现
Binance api get only USDT pairs - Achieve that by only getting data from symbol that has USDT as the last 4 letters
我这里有一个函数可以从 binance api 获取数据,但问题是,它获取所有交易对。我只想在我的选择器中显示以 USDT 结尾的那些。我该怎么做?
public class Crypto
{
public string symbol { get; set; }
public string price { get; set; }
}
private async void GetSymbol()
{
HttpClient client = new HttpClient();
var response = await client.GetStringAsync("https://api.binance.com/api/v3/ticker/price");
var cryptoconverted = JsonConvert.DeserializeObject<List<Crypto>>(response);
var sorted = cryptoconverted.OrderBy(x => x.symbol).ToList();
pairPicker.ItemsSource = sorted;
}
您可以使用EndsWith() as a condition inside of Linq Where()方法:
var sorted = cryptoconverted.OrderBy(x => x.symbol).Where(x => x.symbol.EndsWith("USDT")).ToList();
我这里有一个函数可以从 binance api 获取数据,但问题是,它获取所有交易对。我只想在我的选择器中显示以 USDT 结尾的那些。我该怎么做?
public class Crypto
{
public string symbol { get; set; }
public string price { get; set; }
}
private async void GetSymbol()
{
HttpClient client = new HttpClient();
var response = await client.GetStringAsync("https://api.binance.com/api/v3/ticker/price");
var cryptoconverted = JsonConvert.DeserializeObject<List<Crypto>>(response);
var sorted = cryptoconverted.OrderBy(x => x.symbol).ToList();
pairPicker.ItemsSource = sorted;
}
您可以使用EndsWith() as a condition inside of Linq Where()方法:
var sorted = cryptoconverted.OrderBy(x => x.symbol).Where(x => x.symbol.EndsWith("USDT")).ToList();