1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-11 16:32:57 +00:00
This commit is contained in:
Jkorf
2025-05-14 14:30:05 +02:00
parent a04b636a11
commit f1342b5ff2
11 changed files with 71 additions and 48 deletions
+20 -19
View File
@@ -5,26 +5,27 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Binance.Net" Version="10.18.0" />
<PackageReference Include="Bitfinex.Net" Version="8.1.1" />
<PackageReference Include="BitMart.Net" Version="1.14.0" />
<PackageReference Include="Bybit.Net" Version="4.3.2" />
<PackageReference Include="CoinEx.Net" Version="8.0.1" />
<PackageReference Include="CryptoCom.Net" Version="1.6.0" />
<PackageReference Include="DeepCoin.Net" Version="1.0.0" />
<PackageReference Include="GateIo.Net" Version="1.20.1" />
<PackageReference Include="HyperLiquid.Net" Version="1.1.0" />
<PackageReference Include="JK.BingX.Net" Version="1.21.0" />
<PackageReference Include="JK.Bitget.Net" Version="1.21.0" />
<PackageReference Include="JK.Mexc.Net" Version="2.1.0" />
<PackageReference Include="JK.OKX.Net" Version="2.15.0" />
<PackageReference Include="JKorf.BitMEX.Net" Version="1.1.0" />
<PackageReference Include="JKorf.Coinbase.Net" Version="1.8.1" />
<PackageReference Include="JKorf.HTX.Net" Version="6.9.0" />
<PackageReference Include="KrakenExchange.Net" Version="5.7.1" />
<PackageReference Include="Kucoin.Net" Version="6.0.0" />
<PackageReference Include="Binance.Net" Version="11.0.0" />
<PackageReference Include="Bitfinex.Net" Version="9.0.0" />
<PackageReference Include="BitMart.Net" Version="2.0.0" />
<PackageReference Include="Bybit.Net" Version="5.0.0" />
<PackageReference Include="CoinEx.Net" Version="9.0.1" />
<PackageReference Include="CryptoCom.Net" Version="2.0.0" />
<PackageReference Include="DeepCoin.Net" Version="2.0.0" />
<PackageReference Include="GateIo.Net" Version="2.0.0" />
<PackageReference Include="HyperLiquid.Net" Version="2.0.0" />
<PackageReference Include="JK.BingX.Net" Version="2.0.0" />
<PackageReference Include="JK.Bitget.Net" Version="2.0.0" />
<PackageReference Include="JK.Mexc.Net" Version="3.0.0" />
<PackageReference Include="JK.OKX.Net" Version="3.0.0" />
<PackageReference Include="JKorf.BitMEX.Net" Version="2.0.0" />
<PackageReference Include="JKorf.Coinbase.Net" Version="2.0.0" />
<PackageReference Include="JKorf.HTX.Net" Version="7.0.0" />
<PackageReference Include="KrakenExchange.Net" Version="6.0.0" />
<PackageReference Include="Kucoin.Net" Version="7.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="WhiteBit.Net" Version="1.4.0" />
<PackageReference Include="WhiteBit.Net" Version="2.0.0" />
<PackageReference Include="XT.Net" Version="2.0.0" />
</ItemGroup>
</Project>
+8 -3
View File
@@ -18,6 +18,7 @@
@inject IMexcRestClient mexcClient
@inject IOKXRestClient okxClient
@inject IWhiteBitRestClient whitebitClient
@inject IXTRestClient xtClient
<h3>BTC-USD prices:</h3>
@foreach(var price in _prices.OrderBy(p => p.Key))
@@ -33,7 +34,7 @@
var binanceTask = binanceClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT");
var bingXTask = bingXClient.SpotApi.ExchangeData.GetTickersAsync("BTC-USDT");
var bitfinexTask = bitfinexClient.SpotApi.ExchangeData.GetTickerAsync("tBTCUSD");
var bitgetTask = bitgetClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT_SPBL");
var bitgetTask = bitgetClient.SpotApiV2.ExchangeData.GetTickersAsync("BTCUSDT");
var bitmartTask = bitmartClient.SpotApi.ExchangeData.GetTickerAsync("BTC_USDT");
var bitmexTask = bitmexClient.ExchangeApi.ExchangeData.GetSymbolsAsync("XBT_USDT");
var bybitTask = bybitClient.V5Api.ExchangeData.GetSpotTickersAsync("BTCUSDT");
@@ -49,6 +50,7 @@
var mexcTask = mexcClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT");
var okxTask = okxClient.UnifiedApi.ExchangeData.GetTickerAsync("BTCUSDT");
var whitebitTask = whitebitClient.V4Api.ExchangeData.GetTickersAsync();
var xtTask = xtClient.SpotApi.ExchangeData.GetTickersAsync("eth_btc");
await Task.WhenAll(binanceTask, bingXTask, bitfinexTask, bitgetTask, bitmartTask, bybitTask, coinexTask, deepCoinTask, gateioTask, htxTask, krakenTask, kucoinTask, mexcTask, okxTask);
@@ -62,10 +64,10 @@
_prices.Add("Bitfinex", bitfinexTask.Result.Data.LastPrice);
if (bitgetTask.Result.Success)
_prices.Add("Bitget", bitgetTask.Result.Data.ClosePrice);
_prices.Add("Bitget", bitgetTask.Result.Data.Single().LastPrice);
if (bitmartTask.Result.Success)
_prices.Add("BitMart", bitgetTask.Result.Data.ClosePrice);
_prices.Add("BitMart", bitmartTask.Result.Data.LastPrice);
if (bitmexTask.Result.Success)
_prices.Add("BitMEX", bitmexTask.Result.Data.First().LastPrice);
@@ -119,6 +121,9 @@
var tickers = whitebitTask.Result.Data;
_prices.Add("WhiteBit", tickers.Single(x => x.Symbol == "BTC_USDT").LastPrice);
}
if (xtTask.Result.Success)
_prices.Add("XT", xtTask.Result.Data.Single().LastPrice ?? 0);
}
}
+4 -1
View File
@@ -18,10 +18,12 @@
@inject IMexcSocketClient mexcSocketClient
@inject IOKXSocketClient okxSocketClient
@inject IWhiteBitSocketClient whitebitSocketClient
@inject IXTSocketClient xtSocketClient
@using System.Collections.Concurrent
@using CryptoExchange.Net.Objects
@using CryptoExchange.Net.Objects.Sockets;
@using CryptoExchange.Net.Sockets
@using XT.Net.Interfaces.Clients
@implements IDisposable
<h3>ETH-BTC prices, live updates:</h3>
@@ -41,7 +43,7 @@
binanceSocketClient.SpotApi.ExchangeData.SubscribeToTickerUpdatesAsync("ETHBTC", data => UpdateData("Binance", data.Data.LastPrice)),
bingXSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH-BTC", data => UpdateData("BingX", data.Data.LastPrice)),
bitfinexSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("tETHBTC", data => UpdateData("Bitfinex", data.Data.LastPrice)),
bitgetSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETHBTC", data => UpdateData("Bitget", data.Data.LastPrice)),
bitgetSocketClient.SpotApiV2.SubscribeToTickerUpdatesAsync("ETHBTC", data => UpdateData("Bitget", data.Data.LastPrice)),
bitmartSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH_BTC", data => UpdateData("BitMart", data.Data.LastPrice)),
bitmexSocketClient.ExchangeApi.SubscribeToSymbolUpdatesAsync("ETH_XBT", data => UpdateData("BitMEX", data.Data.LastPrice ?? 0)),
bybitSocketClient.V5SpotApi.SubscribeToTickerUpdatesAsync("ETHBTC", data => UpdateData("Bybit", data.Data.LastPrice)),
@@ -51,6 +53,7 @@
deepCoinSocketClient.ExchangeApi.SubscribeToSymbolUpdatesAsync("ETH-BTC", data => UpdateData("DeepCoin", data.Data.LastPrice ?? 0)),
gateioSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH_BTC", data => UpdateData("GateIo", data.Data.LastPrice)),
htxSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ethbtc", data => UpdateData("HTX", data.Data.ClosePrice ?? 0)),
xtSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("eth_btc", data => UpdateData("XT", data.Data.LastPrice ?? 0)),
// HyperLiquid doesn't support the ETH/BTC pair
//hyperLiquidSocketClient.SpotApi.SubscribeToSymbolUpdatesAsync("ETH", data => UpdateData("HyperLiquid", data.Data.MidPrice ?? 0)),
krakenSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH/BTC", data => UpdateData("Kraken", data.Data.LastPrice)),
+8 -3
View File
@@ -10,6 +10,7 @@
@using Bybit.Net.Interfaces
@using CoinEx.Net.Interfaces
@using Coinbase.Net.Interfaces
@using CryptoExchange.Net.Authentication
@using CryptoExchange.Net.Interfaces
@using CryptoCom.Net.Interfaces
@using DeepCoin.Net.Interfaces
@@ -22,6 +23,7 @@
@using Mexc.Net.Interfaces
@using OKX.Net.Interfaces;
@using WhiteBit.Net.Interfaces
@using XT.Net.Interfaces
@inject IBinanceOrderBookFactory binanceFactory
@inject IBingXOrderBookFactory bingXFactory
@inject IBitfinexOrderBookFactory bitfinexFactory
@@ -41,6 +43,7 @@
@inject IMexcOrderBookFactory mexcFactory
@inject IOKXOrderBookFactory okxFactory
@inject IWhiteBitOrderBookFactory whitebitFactory
@inject IXTOrderBookFactory xtFactory
@implements IDisposable
<h3>ETH-BTC books, live updates:</h3>
@@ -69,7 +72,7 @@
// Since the Kucoin order book stream needs authentication we will need to provide API credentials beforehand
KucoinRestClient.SetDefaultOptions(options =>
{
options.ApiCredentials = new Kucoin.Net.Objects.KucoinApiCredentials("KEY", "SECRET", "PASSPHRASE");
options.ApiCredentials = new ApiCredentials("KEY", "SECRET", "PASSPHRASE");
});
_books = new Dictionary<string, ISymbolOrderBook>
@@ -85,7 +88,8 @@
{ "CoinEx", coinExFactory.CreateSpot("ETHBTC") },
{ "CryptoCom", cryptocomFactory.Create("ETH_BTC") },
{ "GateIo", gateioFactory.CreateSpot("ETH_BTC") },
{ "DeepCoin", deepCoinFactory.Create("ETH-BTC") },
// DeepCoin does not support the ETH/BTC pair
//{ "DeepCoin", deepCoinFactory.Create("ETH-BTC") },
{ "HTX", htxFactory.CreateSpot("ethbtc") },
// HyperLiquid does not support the ETH/BTC pair
//{ "HyperLiquid", hyperLiquidFactory.Create("ETH/BTC") },
@@ -94,9 +98,10 @@
{ "Mexc", mexcFactory.CreateSpot("ETHBTC") },
{ "OKX", okxFactory.Create("ETH-BTC") },
{ "WhiteBit", whitebitFactory.CreateV4("ETH_BTC") },
{ "XT", xtFactory.CreateSpot("eth_btc") },
};
await Task.WhenAll(_books.Select(b => b.Value.StartAsync()));
var result = await Task.WhenAll(_books.Select(b => b.Value.StartAsync()));
// Use a manual update timer so the page isn't refreshed too often
_timer = new Timer(500);
@@ -24,6 +24,7 @@
@using Mexc.Net.Interfaces
@using OKX.Net.Interfaces;
@using WhiteBit.Net.Interfaces
@using XT.Net.Interfaces
@inject IBinanceTrackerFactory binanceFactory
@inject IBingXTrackerFactory bingXFactory
@inject IBitfinexTrackerFactory bitfinexFactory
@@ -43,6 +44,7 @@
@inject IMexcTrackerFactory mexcFactory
@inject IOKXTrackerFactory okxFactory
@inject IWhiteBitTrackerFactory whitebitFactory
@inject IXTTrackerFactory xtFactory
@implements IDisposable
<h3>ETH-BTC trade Trackers, live updates:</h3>
@@ -89,6 +91,7 @@
{ mexcFactory.CreateTradeTracker(usdtSymbol, period: TimeSpan.FromMinutes(5)) },
{ okxFactory.CreateTradeTracker(usdtSymbol, period: TimeSpan.FromMinutes(5)) },
{ whitebitFactory.CreateTradeTracker(usdtSymbol, period: TimeSpan.FromMinutes(5)) },
{ xtFactory.CreateTradeTracker(usdtSymbol, period: TimeSpan.FromMinutes(5)) },
};
await Task.WhenAll(_trackers.Select(b => b.StartAsync()));
+1 -3
View File
@@ -31,9 +31,6 @@ namespace BlazorClient
services.AddBinance(restOptions =>
{
restOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
}, socketOptions =>
{
socketOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
services.AddBingX();
@@ -54,6 +51,7 @@ namespace BlazorClient
services.AddMexc();
services.AddOKX();
services.AddWhiteBit();
services.AddXT();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+1
View File
@@ -27,4 +27,5 @@
@using Mexc.Net.Interfaces.Clients;
@using OKX.Net.Interfaces.Clients;
@using WhiteBit.Net.Interfaces.Clients
@using XT.Net.Interfaces.Clients
@using CryptoExchange.Net.Interfaces;