diff --git a/CryptoExchange.Net.sln b/CryptoExchange.Net.sln
index e2c2a6c0..39abdc12 100644
--- a/CryptoExchange.Net.sln
+++ b/CryptoExchange.Net.sln
@@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorClient", "Examples\Bl
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{5734C2A9-F12C-4754-A8B9-640C24DC4E02}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleClient", "Examples\ConsoleClient\ConsoleClient.csproj", "{23480C58-23BF-4EBF-A173-B7F51A043A99}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleClient", "Examples\ConsoleClient\ConsoleClient.csproj", "{23480C58-23BF-4EBF-A173-B7F51A043A99}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedClients", "Examples\SharedClients\SharedClients.csproj", "{988A87EF-EAEA-4313-A6CF-FA869813D5AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -35,6 +37,10 @@ Global
{23480C58-23BF-4EBF-A173-B7F51A043A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23480C58-23BF-4EBF-A173-B7F51A043A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23480C58-23BF-4EBF-A173-B7F51A043A99}.Release|Any CPU.Build.0 = Release|Any CPU
+ {988A87EF-EAEA-4313-A6CF-FA869813D5AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {988A87EF-EAEA-4313-A6CF-FA869813D5AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {988A87EF-EAEA-4313-A6CF-FA869813D5AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {988A87EF-EAEA-4313-A6CF-FA869813D5AB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -42,6 +48,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{AF4F5C19-162E-48F4-8B0B-BA5A2D7CE06A} = {5734C2A9-F12C-4754-A8B9-640C24DC4E02}
{23480C58-23BF-4EBF-A173-B7F51A043A99} = {5734C2A9-F12C-4754-A8B9-640C24DC4E02}
+ {988A87EF-EAEA-4313-A6CF-FA869813D5AB} = {5734C2A9-F12C-4754-A8B9-640C24DC4E02}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0D1B9CE9-E0B7-4B8B-88BF-6EA2CC8CA3D7}
diff --git a/Examples/BlazorClient/BlazorClient.csproj b/Examples/BlazorClient/BlazorClient.csproj
index 9d18469e..a7348ce1 100644
--- a/Examples/BlazorClient/BlazorClient.csproj
+++ b/Examples/BlazorClient/BlazorClient.csproj
@@ -5,17 +5,20 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/BlazorClient/Pages/Index.razor b/Examples/BlazorClient/Pages/Index.razor
index 196e4676..38aa9d5b 100644
--- a/Examples/BlazorClient/Pages/Index.razor
+++ b/Examples/BlazorClient/Pages/Index.razor
@@ -2,12 +2,15 @@
@inject IBinanceRestClient binanceClient
@inject IBingXRestClient bingXClient
@inject IBitfinexRestClient bitfinexClient
+@inject IBitMartRestClient bitmartClient
@inject IBitgetRestClient bitgetClient
@inject IBybitRestClient bybitClient
@inject ICoinExRestClient coinexClient
-@inject IHuobiRestClient huobiClient
+@inject IGateIoRestClient gateioClient
+@inject IHTXRestClient huobiClient
@inject IKrakenRestClient krakenClient
@inject IKucoinRestClient kucoinClient
+@inject IMexcRestClient mexcClient
@inject IOKXRestClient okxClient
BTC-USD prices:
@@ -25,14 +28,17 @@
var bingXTask = bingXClient.SpotApi.ExchangeData.GetTickersAsync("BTC-USDT");
var bitfinexTask = bitfinexClient.SpotApi.ExchangeData.GetTickerAsync("tBTCUSD");
var bitgetTask = bitgetClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT_SPBL");
+ var bitmartTask = bitmartClient.SpotApi.ExchangeData.GetTickerAsync("BTC_USDT");
var bybitTask = bybitClient.V5Api.ExchangeData.GetSpotTickersAsync("BTCUSDT");
var coinexTask = coinexClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT");
- var huobiTask = huobiClient.SpotApi.ExchangeData.GetTickerAsync("btcusdt");
+ var gateioTask = gateioClient.SpotApi.ExchangeData.GetTickersAsync("BTC_USDT");
+ var htxTask = huobiClient.SpotApi.ExchangeData.GetTickerAsync("btcusdt");
var krakenTask = krakenClient.SpotApi.ExchangeData.GetTickerAsync("XBTUSD");
var kucoinTask = kucoinClient.SpotApi.ExchangeData.GetTickerAsync("BTC-USDT");
+ var mexcTask = mexcClient.SpotApi.ExchangeData.GetTickerAsync("BTCUSDT");
var okxTask = okxClient.UnifiedApi.ExchangeData.GetTickerAsync("BTCUSDT");
- await Task.WhenAll(binanceTask, bingXTask, bitfinexTask, bybitTask, coinexTask, huobiTask, krakenTask, kucoinTask);
+ await Task.WhenAll(binanceTask, bingXTask, bitfinexTask, bitgetTask, bitmartTask, bybitTask, coinexTask, gateioTask, htxTask, krakenTask, kucoinTask, mexcTask, okxTask);
if (binanceTask.Result.Success)
_prices.Add("Binance", binanceTask.Result.Data.LastPrice);
@@ -46,14 +52,20 @@
if (bitgetTask.Result.Success)
_prices.Add("Bitget", bitgetTask.Result.Data.ClosePrice);
+ if (bitmartTask.Result.Success)
+ _prices.Add("BitMart", bitgetTask.Result.Data.ClosePrice);
+
if (bybitTask.Result.Success)
_prices.Add("Bybit", bybitTask.Result.Data.List.First().LastPrice);
if (coinexTask.Result.Success)
_prices.Add("CoinEx", coinexTask.Result.Data.Ticker.LastPrice);
- if (huobiTask.Result.Success)
- _prices.Add("Huobi", huobiTask.Result.Data.ClosePrice ?? 0);
+ if (gateioTask.Result.Success)
+ _prices.Add("GateIo", gateioTask.Result.Data.First().LastPrice);
+
+ if (htxTask.Result.Success)
+ _prices.Add("HTX", htxTask.Result.Data.ClosePrice ?? 0);
if (krakenTask.Result.Success)
_prices.Add("Kraken", krakenTask.Result.Data.First().Value.LastTrade.Price);
@@ -61,6 +73,9 @@
if (kucoinTask.Result.Success)
_prices.Add("Kucoin", kucoinTask.Result.Data.LastPrice ?? 0);
+ if (mexcTask.Result.Success)
+ _prices.Add("Mexc", mexcTask.Result.Data.LastPrice);
+
if (okxTask.Result.Success)
_prices.Add("OKX", okxTask.Result.Data.LastPrice ?? 0);
}
diff --git a/Examples/BlazorClient/Pages/LiveData.razor b/Examples/BlazorClient/Pages/LiveData.razor
index 38165219..b1d2e4ca 100644
--- a/Examples/BlazorClient/Pages/LiveData.razor
+++ b/Examples/BlazorClient/Pages/LiveData.razor
@@ -3,11 +3,14 @@
@inject IBingXSocketClient bingXSocketClient
@inject IBitfinexSocketClient bitfinexSocketClient
@inject IBitgetSocketClient bitgetSocketClient
+@inject IBitMartSocketClient bitmartSocketClient
@inject IBybitSocketClient bybitSocketClient
@inject ICoinExSocketClient coinExSocketClient
-@inject IHuobiSocketClient huobiSocketClient
+@inject IGateIoSocketClient gateioSocketClient
+@inject IHTXSocketClient htxSocketClient
@inject IKrakenSocketClient krakenSocketClient
@inject IKucoinSocketClient kucoinSocketClient
+@inject IMexcSocketClient mexcSocketClient
@inject IOKXSocketClient okxSocketClient
@using System.Collections.Concurrent
@using CryptoExchange.Net.Objects
@@ -33,11 +36,14 @@
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)),
+ bitmartSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH_BTC", data => UpdateData("BitMart", data.Data.LastPrice)),
bybitSocketClient.V5SpotApi.SubscribeToTickerUpdatesAsync("ETHBTC", data => UpdateData("Bybit", data.Data.LastPrice)),
coinExSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETHBTC", data => UpdateData("CoinEx", data.Data.LastPrice)),
- huobiSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ethbtc", data => UpdateData("Huobi", data.Data.ClosePrice ?? 0)),
+ gateioSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH_BTC", data => UpdateData("GateIo", data.Data.LastPrice)),
+ htxSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ethbtc", data => UpdateData("HTX", data.Data.ClosePrice ?? 0)),
krakenSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH/XBT", data => UpdateData("Kraken", data.Data.LastTrade.Price)),
kucoinSocketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETH-BTC", data => UpdateData("Kucoin", data.Data.LastPrice ?? 0)),
+ mexcSocketClient.SpotApi.SubscribeToMiniTickerUpdatesAsync("ETHBTC", data => UpdateData("Mexc", data.Data.LastPrice)),
okxSocketClient.UnifiedApi.ExchangeData.SubscribeToTickerUpdatesAsync("ETH-BTC", data => UpdateData("OKX", data.Data.LastPrice ?? 0)),
};
diff --git a/Examples/BlazorClient/Pages/OrderBooks.razor b/Examples/BlazorClient/Pages/OrderBooks.razor
index 7d2d2ae0..d32dbf9f 100644
--- a/Examples/BlazorClient/Pages/OrderBooks.razor
+++ b/Examples/BlazorClient/Pages/OrderBooks.razor
@@ -5,23 +5,29 @@
@using BingX.Net.Interfaces
@using Bitfinex.Net.Interfaces
@using Bitget.Net.Interfaces;
+@using BitMart.Net.Interfaces;
@using Bybit.Net.Interfaces
@using CoinEx.Net.Interfaces
@using CryptoExchange.Net.Interfaces
-@using Huobi.Net.Interfaces
+@using GateIo.Net.Interfaces
+@using HTX.Net.Interfaces
@using Kraken.Net.Interfaces
@using Kucoin.Net.Clients
@using Kucoin.Net.Interfaces
+@using Mexc.Net.Interfaces
@using OKX.Net.Interfaces;
@inject IBinanceOrderBookFactory binanceFactory
@inject IBingXOrderBookFactory bingXFactory
@inject IBitfinexOrderBookFactory bitfinexFactory
@inject IBitgetOrderBookFactory bitgetFactory
+@inject IBitMartOrderBookFactory bitmartFactory
@inject IBybitOrderBookFactory bybitFactory
@inject ICoinExOrderBookFactory coinExFactory
-@inject IHuobiOrderBookFactory huobiFactory
+@inject IGateIoOrderBookFactory gateioFactory
+@inject IHTXOrderBookFactory htxFactory
@inject IKrakenOrderBookFactory krakenFactory
@inject IKucoinOrderBookFactory kucoinFactory
+@inject IMexcOrderBookFactory mexcFactory
@inject IOKXOrderBookFactory okxFactory
@implements IDisposable
@@ -60,11 +66,14 @@
{ "BingX", bingXFactory.CreateSpot("ETH-BTC") },
{ "Bitfinex", bitfinexFactory.Create("tETHBTC") },
{ "Bitget", bitgetFactory.CreateSpot("ETHBTC") },
+ { "BitMart", bitmartFactory.CreateSpot("ETH_BTC", null) },
{ "Bybit", bybitFactory.Create("ETHBTC", Bybit.Net.Enums.Category.Spot) },
{ "CoinEx", coinExFactory.CreateSpot("ETHBTC") },
- { "Huobi", huobiFactory.CreateSpot("ethbtc") },
+ { "GateIo", gateioFactory.CreateSpot("ETH_BTC") },
+ { "HTX", htxFactory.CreateSpot("ethbtc") },
{ "Kraken", krakenFactory.CreateSpot("ETH/XBT") },
{ "Kucoin", kucoinFactory.CreateSpot("ETH-BTC") },
+ { "Mexc", mexcFactory.CreateSpot("ETHBTC") },
{ "OKX", okxFactory.Create("ETH-BTC") },
};
diff --git a/Examples/BlazorClient/Pages/SpotClient.razor b/Examples/BlazorClient/Pages/SpotClient.razor
index 794766ac..a39d7e07 100644
--- a/Examples/BlazorClient/Pages/SpotClient.razor
+++ b/Examples/BlazorClient/Pages/SpotClient.razor
@@ -1,5 +1,6 @@
@page "/SpotClient"
-@inject ICryptoRestClient restClient
+@using CryptoExchange.Net.SharedApis
+@inject IEnumerable restClients
ETH-BTC prices:
@foreach(var price in _prices.OrderBy(p => p.Key))
@@ -12,13 +13,13 @@
protected override async Task OnInitializedAsync()
{
- var clients = restClient.GetSpotClients();
- var tasks = clients.Select(c => (c.ExchangeName, c.GetTickerAsync(c.GetSymbolName("ETH", "BTC"))));
- await Task.WhenAll(tasks.Select(t => t.Item2));
- foreach(var task in tasks)
+ 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(task.Item2.Result.Success)
- _prices.Add(task.Item1, task.Item2.Result.Data.HighPrice);
+ if (ticker.Success)
+ _prices.Add(ticker.Exchange, ticker.Data.LastPrice);
}
}
diff --git a/Examples/BlazorClient/Startup.cs b/Examples/BlazorClient/Startup.cs
index 18cb770a..972bb48b 100644
--- a/Examples/BlazorClient/Startup.cs
+++ b/Examples/BlazorClient/Startup.cs
@@ -39,11 +39,14 @@ public void ConfigureServices(IServiceCollection services)
services.AddBingX();
services.AddBitfinex();
services.AddBitget();
+ services.AddBitMart();
services.AddBybit();
services.AddCoinEx();
- services.AddHuobi();
+ services.AddGateIo();
+ services.AddHTX();
services.AddKraken();
services.AddKucoin();
+ services.AddMexc();
services.AddOKX();
}
diff --git a/Examples/BlazorClient/_Imports.razor b/Examples/BlazorClient/_Imports.razor
index 96db5a96..c178854f 100644
--- a/Examples/BlazorClient/_Imports.razor
+++ b/Examples/BlazorClient/_Imports.razor
@@ -12,10 +12,13 @@
@using BingX.Net.Interfaces.Clients;
@using Bitfinex.Net.Interfaces.Clients;
@using Bitget.Net.Interfaces.Clients;
+@using BitMart.Net.Interfaces.Clients;
@using Bybit.Net.Interfaces.Clients;
@using CoinEx.Net.Interfaces.Clients;
-@using Huobi.Net.Interfaces.Clients;
+@using GateIo.Net.Interfaces.Clients;
+@using HTX.Net.Interfaces.Clients;
@using Kraken.Net.Interfaces.Clients;
@using Kucoin.Net.Interfaces.Clients;
+@using Mexc.Net.Interfaces.Clients;
@using OKX.Net.Interfaces.Clients;
@using CryptoExchange.Net.Interfaces;
\ No newline at end of file
diff --git a/Examples/ConsoleClient/ConsoleClient.csproj b/Examples/ConsoleClient/ConsoleClient.csproj
index 590b49ea..62874832 100644
--- a/Examples/ConsoleClient/ConsoleClient.csproj
+++ b/Examples/ConsoleClient/ConsoleClient.csproj
@@ -1,4 +1,4 @@
-
+
Exe
@@ -6,16 +6,18 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/ConsoleClient/Program.cs b/Examples/ConsoleClient/Program.cs
index 66ebc2bb..f40ae10b 100644
--- a/Examples/ConsoleClient/Program.cs
+++ b/Examples/ConsoleClient/Program.cs
@@ -4,12 +4,10 @@
using System.Linq;
using System.Threading.Tasks;
using Binance.Net.Clients;
-using Binance.Net.Objects;
using Bybit.Net.Clients;
using ConsoleClient.Exchanges;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Objects.Sockets;
-using CryptoExchange.Net.Sockets;
namespace ConsoleClient
{
diff --git a/Examples/SharedClients/Program.cs b/Examples/SharedClients/Program.cs
new file mode 100644
index 00000000..d48ee502
--- /dev/null
+++ b/Examples/SharedClients/Program.cs
@@ -0,0 +1,50 @@
+using Binance.Net.Clients;
+using BitMart.Net.Clients;
+using CryptoExchange.Net.SharedApis;
+using OKX.Net.Clients;
+
+var symbol = new SharedSymbol(TradingMode.Spot, "ETH", "USDT");
+var binanceSpotRestClient = new BinanceRestClient().SpotApi.SharedClient;
+var okxSpotRestClient = new OKXRestClient().UnifiedApi.SharedClient;
+var bitmartSpotRestClient = new BitMartRestClient().SpotApi.SharedClient;
+
+var binanceSpotSocketClient = new BinanceSocketClient().SpotApi.SharedClient;
+var okxSpotSocketClient = new OKXSocketClient().UnifiedApi.SharedClient;
+var bitmartSpotSocketClient = new BitMartSocketClient().SpotApi.SharedClient;
+
+await GetLastTradePriceAsync(binanceSpotRestClient, symbol);
+await GetLastTradePriceAsync(okxSpotRestClient, symbol);
+await GetLastTradePriceAsync(bitmartSpotRestClient, symbol);
+
+Console.WriteLine();
+Console.WriteLine("Press enter to start websocket");
+Console.ReadLine();
+
+await SubscribeTickerUpdatesAsync(binanceSpotSocketClient, symbol);
+await SubscribeTickerUpdatesAsync(okxSpotSocketClient, symbol);
+await SubscribeTickerUpdatesAsync(bitmartSpotSocketClient, symbol);
+
+Console.ReadLine();
+
+async Task GetLastTradePriceAsync(ISpotTickerRestClient client, SharedSymbol symbol)
+{
+ var result = await client.GetSpotTickerAsync(new GetTickerRequest(symbol));
+ if (!result.Success)
+ {
+ Console.WriteLine($"Failed to get ticker: {result.Error}");
+ return;
+ }
+
+ Console.WriteLine($"{client.Exchange} {result.Data.Symbol}: {result.Data.LastPrice}");
+}
+
+async Task SubscribeTickerUpdatesAsync(ITickerSocketClient client, SharedSymbol symbol)
+{
+ var result = await client.SubscribeToTickerUpdatesAsync(new SubscribeTickerRequest(symbol), update =>
+ {
+ Console.WriteLine($"{client.Exchange} {update.Data.Symbol} {update.Data.LastPrice}");
+ });
+
+ if (!result.Success)
+ Console.WriteLine($"Failed to subscribe ticker: {result.Error}");
+}
\ No newline at end of file
diff --git a/Examples/SharedClients/SharedClients.csproj b/Examples/SharedClients/SharedClients.csproj
new file mode 100644
index 00000000..4a4094b4
--- /dev/null
+++ b/Examples/SharedClients/SharedClients.csproj
@@ -0,0 +1,16 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+