1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-06 23:46:12 +00:00
2024-09-27 13:53:33 +02:00

26 lines
785 B
Plaintext

@page "/SpotClient"
@using CryptoExchange.Net.SharedApis
@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);
}
}
}