1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-11 16:32:57 +00:00

Updated examples

This commit is contained in:
Jkorf
2024-09-27 13:53:33 +02:00
parent 23e947f258
commit c1b0437c93
12 changed files with 157 additions and 44 deletions
+8 -7
View File
@@ -1,5 +1,6 @@
@page "/SpotClient"
@inject ICryptoRestClient restClient
@using CryptoExchange.Net.SharedApis
@inject IEnumerable<ISpotTickerRestClient> restClients
<h3>ETH-BTC prices:</h3>
@foreach(var price in _prices.OrderBy(p => p.Key))
@@ -12,13 +13,13 @@
protected override async Task OnInitializedAsync()
{
var clients = restClient.GetSpotClients();
var tasks = clients.Select(c => (c.ExchangeName, c.GetTickerAsync(c.GetSymbolName("ETH", "BTC"))));
await Task.WhenAll(tasks.Select(t => t.Item2));
foreach(var task in tasks)
var symbol = new SharedSymbol(TradingMode.Spot, "ETH", "BTC");
var tasks = restClients.Select(x => x.GetSpotTickerAsync(new GetTickerRequest(symbol)));
await Task.WhenAll(tasks);
foreach (var ticker in tasks.Select(x => x.Result))
{
if(task.Item2.Result.Success)
_prices.Add(task.Item1, task.Item2.Result.Data.HighPrice);
if (ticker.Success)
_prices.Add(ticker.Exchange, ticker.Data.LastPrice);
}
}