1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00
2025-03-04 11:41:03 +01:00

29 lines
906 B
Plaintext

@page "/SpotClient"
@using CryptoExchange.Net.SharedApis
@using System.Diagnostics
@inject IEnumerable<ISpotTickerRestClient> restClients
<h3>ETH-BTC prices:</h3>
@foreach(var price in _prices.OrderBy(p => p.Key))
{
<div>@price.Key: @price.Value</div>
}
@code{
private Dictionary<string, decimal?> _prices = new Dictionary<string, decimal?>();
protected override async Task OnInitializedAsync()
{
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 (ticker.Success)
_prices.Add(ticker.Exchange, ticker.Data.LastPrice);
else
Debug.WriteLine($"{ticker.Exchange} failed: {ticker.Error}");
}
}
}