mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-07-26 11:17:09 +00:00
Updated example, removed global.json
This commit is contained in:
parent
120132c45b
commit
7a195f662c
@ -5,15 +5,15 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Binance.Net" Version="8.0.0-alpha3" />
|
<PackageReference Include="Binance.Net" Version="8.0.0-alpha4" />
|
||||||
<PackageReference Include="Bitfinex.Net" Version="5.0.0-alpha3" />
|
<PackageReference Include="Bitfinex.Net" Version="5.0.0-alpha4" />
|
||||||
<PackageReference Include="Bittrex.Net" Version="7.0.0-alpha3" />
|
<PackageReference Include="Bittrex.Net" Version="7.0.0-alpha4" />
|
||||||
<PackageReference Include="Bybit.Net" Version="0.0.1-alpha3" />
|
<PackageReference Include="Bybit.Net" Version="0.0.1-alpha4" />
|
||||||
<PackageReference Include="CoinEx.Net" Version="5.0.0-alpha3" />
|
<PackageReference Include="CoinEx.Net" Version="5.0.0-alpha4" />
|
||||||
<PackageReference Include="FTX.Net" Version="1.0.0-alpha3" />
|
<PackageReference Include="FTX.Net" Version="1.0.0-alpha4" />
|
||||||
<PackageReference Include="Huobi.Net" Version="4.0.0-alpha4" />
|
<PackageReference Include="Huobi.Net" Version="4.0.0-alpha5" />
|
||||||
<PackageReference Include="KrakenExchange.Net" Version="3.0.0-alpha3" />
|
<PackageReference Include="KrakenExchange.Net" Version="3.0.0-alpha4" />
|
||||||
<PackageReference Include="Kucoin.Net" Version="4.0.0-alpha3" />
|
<PackageReference Include="Kucoin.Net" Version="4.0.0-alpha4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
@inject IKucoinClient kucoinClient
|
@inject IKucoinClient kucoinClient
|
||||||
|
|
||||||
<h3>BTC-USD prices:</h3>
|
<h3>BTC-USD prices:</h3>
|
||||||
@foreach(var price in _prices)
|
@foreach(var price in _prices.OrderBy(p => p.Key))
|
||||||
{
|
{
|
||||||
<div>@price.Key: @price.Value</div>
|
<div>@price.Key: @price.Value</div>
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<h3>ETH-BTC prices, live updates:</h3>
|
<h3>ETH-BTC prices, live updates:</h3>
|
||||||
@foreach(var price in _prices)
|
@foreach(var price in _prices.OrderBy(p => p.Key))
|
||||||
{
|
{
|
||||||
<div>@price.Key: @price.Value</div>
|
<div>@price.Key: @price.Value</div>
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
@using Huobi.Net.SymbolOrderBooks
|
@using Huobi.Net.SymbolOrderBooks
|
||||||
@using Kraken.Net.SymbolOrderBooks
|
@using Kraken.Net.SymbolOrderBooks
|
||||||
@using Kucoin.Net.Clients
|
@using Kucoin.Net.Clients
|
||||||
@using Kucoin.Net.SymbolOrderBook
|
@using Kucoin.Net.SymbolOrderBooks
|
||||||
@using System.Collections.Concurrent
|
@using System.Collections.Concurrent
|
||||||
@using System.Timers
|
@using System.Timers
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<h3>ETH-BTC books, live updates:</h3>
|
<h3>ETH-BTC books, live updates:</h3>
|
||||||
@foreach(var book in _books)
|
@foreach(var book in _books.OrderBy(p => p.Key))
|
||||||
{
|
{
|
||||||
<div style="margin-bottom: 20px;">
|
<div style="margin-bottom: 20px;">
|
||||||
<h4>@book.Key</h4>
|
<h4>@book.Key</h4>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
{
|
{
|
||||||
for (var i = 0; i < 3; i++)
|
for (var i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
<div>@book.Value.Asks.ElementAt(i).Price - @book.Value.Bids.ElementAt(i).Price </div>
|
<div>@book.Value.Bids.ElementAt(i).Price - @book.Value.Asks.ElementAt(i).Price</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@page "/ExchangeClient"
|
@page "/SpotClient"
|
||||||
@inject IBinanceClient binanceClient
|
@inject IBinanceClient binanceClient
|
||||||
@inject IBitfinexClient bitfinexClient
|
@inject IBitfinexClient bitfinexClient
|
||||||
@inject IBittrexClient bittrexClient
|
@inject IBittrexClient bittrexClient
|
||||||
@ -13,34 +13,34 @@
|
|||||||
@using Bittrex.Net.Clients.SpotApi
|
@using Bittrex.Net.Clients.SpotApi
|
||||||
@using Bybit.Net.Clients.SpotApi
|
@using Bybit.Net.Clients.SpotApi
|
||||||
@using CoinEx.Net.Clients.SpotApi
|
@using CoinEx.Net.Clients.SpotApi
|
||||||
@using CryptoExchange.Net.ExchangeInterfaces
|
@using CryptoExchange.Net.Interfaces
|
||||||
@using FTX.Net.Clients.TradeApi
|
@using FTX.Net.Clients.TradeApi
|
||||||
@using Huobi.Net.Clients.SpotApi
|
@using Huobi.Net.Clients.SpotApi
|
||||||
@using Kraken.Net.Clients.SpotApi
|
@using Kraken.Net.Clients.SpotApi
|
||||||
@using Kucoin.Net.Clients.SpotApi
|
@using Kucoin.Net.Clients.SpotApi
|
||||||
|
|
||||||
<h3>ETH-BTC prices:</h3>
|
<h3>ETH-BTC prices:</h3>
|
||||||
@foreach(var price in _prices)
|
@foreach(var price in _prices.OrderBy(p => p.Key))
|
||||||
{
|
{
|
||||||
<div>@price.Key: @price.Value</div>
|
<div>@price.Key: @price.Value</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code{
|
@code{
|
||||||
private Dictionary<string, decimal> _prices = new Dictionary<string, decimal>();
|
private Dictionary<string, decimal?> _prices = new Dictionary<string, decimal?>();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
var clients = new IExchangeClient[]
|
var clients = new ISpotClient[]
|
||||||
{
|
{
|
||||||
binanceClient.SpotApi.AsExchangeClient(),
|
binanceClient.SpotApi.ComonSpotClient,
|
||||||
bitfinexClient.SpotApi.AsExchangeClient(),
|
bitfinexClient.SpotApi.ComonSpotClient,
|
||||||
bittrexClient.SpotApi.AsExchangeClient(),
|
bittrexClient.SpotApi.ComonSpotClient,
|
||||||
bybitClient.SpotApi.AsExchangeClient(),
|
bybitClient.SpotApi.ComonSpotClient,
|
||||||
coinexClient.SpotApi.AsExchangeClient(),
|
coinexClient.SpotApi.ComonSpotClient,
|
||||||
ftxClient.TradeApi.AsExchangeClient(),
|
ftxClient.TradeApi.ComonSpotClient,
|
||||||
huobiClient.SpotApi.AsExchangeClient(),
|
huobiClient.SpotApi.ComonSpotClient,
|
||||||
krakenClient.SpotApi.AsExchangeClient(),
|
krakenClient.SpotApi.ComonSpotClient,
|
||||||
kucoinClient.SpotApi.AsExchangeClient()
|
kucoinClient.SpotApi.ComonSpotClient
|
||||||
};
|
};
|
||||||
|
|
||||||
var tasks = clients.Select(c => (c.ExchangeName, c.GetTickerAsync(c.GetSymbolName("ETH", "BTC"))));
|
var tasks = clients.Select(c => (c.ExchangeName, c.GetTickerAsync(c.GetSymbolName("ETH", "BTC"))));
|
||||||
@ -49,7 +49,7 @@
|
|||||||
{
|
{
|
||||||
if(task.Item2.Result.Success)
|
if(task.Item2.Result.Success)
|
||||||
// TODO new version
|
// TODO new version
|
||||||
_prices.Add(task.Item1, task.Item2.Result.Data.CommonHighPrice);
|
_prices.Add(task.Item1, task.Item2.Result.Data.HighPrice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace BlazorClient
|
namespace BlazorClient
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item px-3">
|
<li class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="ExchangeClient">
|
<NavLink class="nav-link" href="ISpotClient">
|
||||||
Get data IExchangeClient
|
Get data ISpotClient
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item px-3">
|
<li class="nav-item px-3">
|
||||||
|
@ -1,21 +1,29 @@
|
|||||||
|
using Binance.Net;
|
||||||
using Binance.Net.Clients;
|
using Binance.Net.Clients;
|
||||||
using Binance.Net.Interfaces.Clients;
|
using Binance.Net.Interfaces.Clients;
|
||||||
using Binance.Net.Objects;
|
using Binance.Net.Objects;
|
||||||
|
using Bitfinex.Net;
|
||||||
using Bitfinex.Net.Clients;
|
using Bitfinex.Net.Clients;
|
||||||
using Bitfinex.Net.Interfaces.Clients;
|
using Bitfinex.Net.Interfaces.Clients;
|
||||||
|
using Bittrex.Net;
|
||||||
using Bittrex.Net.Clients;
|
using Bittrex.Net.Clients;
|
||||||
using Bittrex.Net.Interfaces.Clients;
|
using Bittrex.Net.Interfaces.Clients;
|
||||||
|
using Bybit.Net;
|
||||||
using Bybit.Net.Clients;
|
using Bybit.Net.Clients;
|
||||||
using Bybit.Net.Interfaces.Clients;
|
using Bybit.Net.Interfaces.Clients;
|
||||||
using CoinEx.Net.Clients;
|
using CoinEx.Net.Clients;
|
||||||
using CoinEx.Net.Interfaces.Clients;
|
using CoinEx.Net.Interfaces.Clients;
|
||||||
using CryptoExchange.Net.Authentication;
|
using CryptoExchange.Net.Authentication;
|
||||||
|
using FTX.Net;
|
||||||
using FTX.Net.Clients;
|
using FTX.Net.Clients;
|
||||||
using FTX.Net.Interfaces.Clients;
|
using FTX.Net.Interfaces.Clients;
|
||||||
|
using Huobi.Net;
|
||||||
using Huobi.Net.Clients;
|
using Huobi.Net.Clients;
|
||||||
using Huobi.Net.Interfaces.Clients;
|
using Huobi.Net.Interfaces.Clients;
|
||||||
|
using Kraken.Net;
|
||||||
using Kraken.Net.Clients;
|
using Kraken.Net.Clients;
|
||||||
using Kraken.Net.Interfaces.Clients;
|
using Kraken.Net.Interfaces.Clients;
|
||||||
|
using Kucoin.Net;
|
||||||
using Kucoin.Net.Clients;
|
using Kucoin.Net.Clients;
|
||||||
using Kucoin.Net.Interfaces.Clients;
|
using Kucoin.Net.Interfaces.Clients;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
@ -23,6 +31,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace BlazorClient
|
namespace BlazorClient
|
||||||
{
|
{
|
||||||
@ -42,33 +51,25 @@ namespace BlazorClient
|
|||||||
services.AddRazorPages();
|
services.AddRazorPages();
|
||||||
services.AddServerSideBlazor();
|
services.AddServerSideBlazor();
|
||||||
|
|
||||||
// Register the rest clients as transient, will create a new one when needed
|
// Register the clients, options can be provided in the callback parameter
|
||||||
services.AddTransient<IBinanceClient, BinanceClient>();
|
services.AddBinance((restClientOptions, socketClientOptions) => {
|
||||||
services.AddTransient<IBitfinexClient, BitfinexClient>();
|
restClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
|
||||||
services.AddTransient<IBittrexClient, BittrexClient>();
|
restClientOptions.LogLevel = LogLevel.Debug;
|
||||||
services.AddTransient<IBybitClient, BybitClient>();
|
|
||||||
services.AddTransient<ICoinExClient, CoinExClient>();
|
|
||||||
services.AddTransient<IFTXClient, FTXClient>();
|
|
||||||
services.AddTransient<IHuobiClient, HuobiClient>();
|
|
||||||
services.AddTransient<IKrakenClient, KrakenClient>();
|
|
||||||
services.AddTransient<IKucoinClient, KucoinClient>();
|
|
||||||
|
|
||||||
// Register the socket clients as scoped so the same instance will be reused per client
|
socketClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
|
||||||
services.AddScoped<IBinanceSocketClient, BinanceSocketClient>();
|
|
||||||
services.AddScoped<IBitfinexSocketClient, BitfinexSocketClient>();
|
|
||||||
services.AddScoped<IBittrexSocketClient, BittrexSocketClient>();
|
|
||||||
services.AddScoped<IBybitSocketClient, BybitSocketClient>();
|
|
||||||
services.AddScoped<ICoinExSocketClient, CoinExSocketClient>();
|
|
||||||
services.AddScoped<IFTXSocketClient, FTXSocketClient>();
|
|
||||||
services.AddScoped<IHuobiSocketClient, HuobiSocketClient>();
|
|
||||||
services.AddScoped<IKrakenSocketClient, KrakenSocketClient>();
|
|
||||||
services.AddScoped<IKucoinSocketClient, KucoinSocketClient>();
|
|
||||||
|
|
||||||
// Can set default client options here, for instance:
|
|
||||||
BinanceClient.SetDefaultOptions(new BinanceClientOptions
|
|
||||||
{
|
|
||||||
ApiCredentials = new ApiCredentials("KEY", "SECRET")
|
|
||||||
});
|
});
|
||||||
|
services.AddBitfinex();
|
||||||
|
services.AddBittrex();
|
||||||
|
services.AddBybit();
|
||||||
|
//services.AddCoinEx();
|
||||||
|
services.AddFTX();
|
||||||
|
services.AddHuobi();
|
||||||
|
services.AddKraken();
|
||||||
|
services.AddKucoin();
|
||||||
|
|
||||||
|
// TODO remove when AddCoinEx fixed
|
||||||
|
services.AddScoped<ICoinExClient, CoinExClient>();
|
||||||
|
services.AddScoped<ICoinExSocketClient, CoinExSocketClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"sdk": {
|
|
||||||
"version": "5.0.103"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"sdk": {
|
|
||||||
"version": "6.0.101"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user