mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-07-25 18:57:07 +00:00
Updated example, removed global.json
This commit is contained in:
parent
120132c45b
commit
7a195f662c
@ -5,15 +5,15 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Binance.Net" Version="8.0.0-alpha3" />
|
||||
<PackageReference Include="Bitfinex.Net" Version="5.0.0-alpha3" />
|
||||
<PackageReference Include="Bittrex.Net" Version="7.0.0-alpha3" />
|
||||
<PackageReference Include="Bybit.Net" Version="0.0.1-alpha3" />
|
||||
<PackageReference Include="CoinEx.Net" Version="5.0.0-alpha3" />
|
||||
<PackageReference Include="FTX.Net" Version="1.0.0-alpha3" />
|
||||
<PackageReference Include="Huobi.Net" Version="4.0.0-alpha4" />
|
||||
<PackageReference Include="KrakenExchange.Net" Version="3.0.0-alpha3" />
|
||||
<PackageReference Include="Kucoin.Net" Version="4.0.0-alpha3" />
|
||||
<PackageReference Include="Binance.Net" Version="8.0.0-alpha4" />
|
||||
<PackageReference Include="Bitfinex.Net" Version="5.0.0-alpha4" />
|
||||
<PackageReference Include="Bittrex.Net" Version="7.0.0-alpha4" />
|
||||
<PackageReference Include="Bybit.Net" Version="0.0.1-alpha4" />
|
||||
<PackageReference Include="CoinEx.Net" Version="5.0.0-alpha4" />
|
||||
<PackageReference Include="FTX.Net" Version="1.0.0-alpha4" />
|
||||
<PackageReference Include="Huobi.Net" Version="4.0.0-alpha5" />
|
||||
<PackageReference Include="KrakenExchange.Net" Version="3.0.0-alpha4" />
|
||||
<PackageReference Include="Kucoin.Net" Version="4.0.0-alpha4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -10,7 +10,7 @@
|
||||
@inject IKucoinClient kucoinClient
|
||||
|
||||
<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>
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
@implements IDisposable
|
||||
|
||||
<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>
|
||||
}
|
||||
|
@ -11,13 +11,13 @@
|
||||
@using Huobi.Net.SymbolOrderBooks
|
||||
@using Kraken.Net.SymbolOrderBooks
|
||||
@using Kucoin.Net.Clients
|
||||
@using Kucoin.Net.SymbolOrderBook
|
||||
@using Kucoin.Net.SymbolOrderBooks
|
||||
@using System.Collections.Concurrent
|
||||
@using System.Timers
|
||||
@implements IDisposable
|
||||
|
||||
<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;">
|
||||
<h4>@book.Key</h4>
|
||||
@ -25,7 +25,7 @@
|
||||
{
|
||||
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>
|
||||
|
@ -1,4 +1,4 @@
|
||||
@page "/ExchangeClient"
|
||||
@page "/SpotClient"
|
||||
@inject IBinanceClient binanceClient
|
||||
@inject IBitfinexClient bitfinexClient
|
||||
@inject IBittrexClient bittrexClient
|
||||
@ -13,34 +13,34 @@
|
||||
@using Bittrex.Net.Clients.SpotApi
|
||||
@using Bybit.Net.Clients.SpotApi
|
||||
@using CoinEx.Net.Clients.SpotApi
|
||||
@using CryptoExchange.Net.ExchangeInterfaces
|
||||
@using CryptoExchange.Net.Interfaces
|
||||
@using FTX.Net.Clients.TradeApi
|
||||
@using Huobi.Net.Clients.SpotApi
|
||||
@using Kraken.Net.Clients.SpotApi
|
||||
@using Kucoin.Net.Clients.SpotApi
|
||||
|
||||
<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>
|
||||
}
|
||||
|
||||
@code{
|
||||
private Dictionary<string, decimal> _prices = new Dictionary<string, decimal>();
|
||||
private Dictionary<string, decimal?> _prices = new Dictionary<string, decimal?>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var clients = new IExchangeClient[]
|
||||
var clients = new ISpotClient[]
|
||||
{
|
||||
binanceClient.SpotApi.AsExchangeClient(),
|
||||
bitfinexClient.SpotApi.AsExchangeClient(),
|
||||
bittrexClient.SpotApi.AsExchangeClient(),
|
||||
bybitClient.SpotApi.AsExchangeClient(),
|
||||
coinexClient.SpotApi.AsExchangeClient(),
|
||||
ftxClient.TradeApi.AsExchangeClient(),
|
||||
huobiClient.SpotApi.AsExchangeClient(),
|
||||
krakenClient.SpotApi.AsExchangeClient(),
|
||||
kucoinClient.SpotApi.AsExchangeClient()
|
||||
binanceClient.SpotApi.ComonSpotClient,
|
||||
bitfinexClient.SpotApi.ComonSpotClient,
|
||||
bittrexClient.SpotApi.ComonSpotClient,
|
||||
bybitClient.SpotApi.ComonSpotClient,
|
||||
coinexClient.SpotApi.ComonSpotClient,
|
||||
ftxClient.TradeApi.ComonSpotClient,
|
||||
huobiClient.SpotApi.ComonSpotClient,
|
||||
krakenClient.SpotApi.ComonSpotClient,
|
||||
kucoinClient.SpotApi.ComonSpotClient
|
||||
};
|
||||
|
||||
var tasks = clients.Select(c => (c.ExchangeName, c.GetTickerAsync(c.GetSymbolName("ETH", "BTC"))));
|
||||
@ -49,7 +49,7 @@
|
||||
{
|
||||
if(task.Item2.Result.Success)
|
||||
// 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.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorClient
|
||||
{
|
||||
|
@ -13,8 +13,8 @@
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="ExchangeClient">
|
||||
Get data IExchangeClient
|
||||
<NavLink class="nav-link" href="ISpotClient">
|
||||
Get data ISpotClient
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
|
@ -1,21 +1,29 @@
|
||||
using Binance.Net;
|
||||
using Binance.Net.Clients;
|
||||
using Binance.Net.Interfaces.Clients;
|
||||
using Binance.Net.Objects;
|
||||
using Bitfinex.Net;
|
||||
using Bitfinex.Net.Clients;
|
||||
using Bitfinex.Net.Interfaces.Clients;
|
||||
using Bittrex.Net;
|
||||
using Bittrex.Net.Clients;
|
||||
using Bittrex.Net.Interfaces.Clients;
|
||||
using Bybit.Net;
|
||||
using Bybit.Net.Clients;
|
||||
using Bybit.Net.Interfaces.Clients;
|
||||
using CoinEx.Net.Clients;
|
||||
using CoinEx.Net.Interfaces.Clients;
|
||||
using CryptoExchange.Net.Authentication;
|
||||
using FTX.Net;
|
||||
using FTX.Net.Clients;
|
||||
using FTX.Net.Interfaces.Clients;
|
||||
using Huobi.Net;
|
||||
using Huobi.Net.Clients;
|
||||
using Huobi.Net.Interfaces.Clients;
|
||||
using Kraken.Net;
|
||||
using Kraken.Net.Clients;
|
||||
using Kraken.Net.Interfaces.Clients;
|
||||
using Kucoin.Net;
|
||||
using Kucoin.Net.Clients;
|
||||
using Kucoin.Net.Interfaces.Clients;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@ -23,6 +31,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BlazorClient
|
||||
{
|
||||
@ -42,33 +51,25 @@ namespace BlazorClient
|
||||
services.AddRazorPages();
|
||||
services.AddServerSideBlazor();
|
||||
|
||||
// Register the rest clients as transient, will create a new one when needed
|
||||
services.AddTransient<IBinanceClient, BinanceClient>();
|
||||
services.AddTransient<IBitfinexClient, BitfinexClient>();
|
||||
services.AddTransient<IBittrexClient, BittrexClient>();
|
||||
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 clients, options can be provided in the callback parameter
|
||||
services.AddBinance((restClientOptions, socketClientOptions) => {
|
||||
restClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
|
||||
restClientOptions.LogLevel = LogLevel.Debug;
|
||||
|
||||
// Register the socket clients as scoped so the same instance will be reused per client
|
||||
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")
|
||||
socketClientOptions.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.
|
||||
|
@ -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