diff --git a/CryptoExchange.Net.UnitTests/TestImplementations/TestBaseClient.cs b/CryptoExchange.Net.UnitTests/TestImplementations/TestBaseClient.cs
index c696169..3fac0e9 100644
--- a/CryptoExchange.Net.UnitTests/TestImplementations/TestBaseClient.cs
+++ b/CryptoExchange.Net.UnitTests/TestImplementations/TestBaseClient.cs
@@ -54,6 +54,8 @@ namespace CryptoExchange.Net.UnitTests
return deserializeResult;
}
+ ///
+ public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
public override TimeSpan? GetTimeOffset() => null;
public override TimeSyncInfo GetTimeSyncInfo() => null;
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) => throw new NotImplementedException();
diff --git a/CryptoExchange.Net.UnitTests/TestImplementations/TestRestClient.cs b/CryptoExchange.Net.UnitTests/TestImplementations/TestRestClient.cs
index 1326abf..1ad9c9f 100644
--- a/CryptoExchange.Net.UnitTests/TestImplementations/TestRestClient.cs
+++ b/CryptoExchange.Net.UnitTests/TestImplementations/TestRestClient.cs
@@ -137,6 +137,9 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations
RequestFactory = new Mock().Object;
}
+ ///
+ public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
+
public async Task> Request(CancellationToken ct = default) where T : class
{
return await SendRequestAsync(new Uri("http://www.test.com"), HttpMethod.Get, ct, requestWeight: 0);
@@ -178,6 +181,9 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations
RequestFactory = new Mock().Object;
}
+ ///
+ public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
+
public async Task> Request(CancellationToken ct = default) where T : class
{
return await SendRequestAsync(new Uri("http://www.test.com"), HttpMethod.Get, ct, requestWeight: 0);
diff --git a/CryptoExchange.Net.UnitTests/TestImplementations/TestSocketClient.cs b/CryptoExchange.Net.UnitTests/TestImplementations/TestSocketClient.cs
index 1ab342c..1df4635 100644
--- a/CryptoExchange.Net.UnitTests/TestImplementations/TestSocketClient.cs
+++ b/CryptoExchange.Net.UnitTests/TestImplementations/TestSocketClient.cs
@@ -84,6 +84,9 @@ namespace CryptoExchange.Net.UnitTests.TestImplementations
}
+ ///
+ public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
+
internal IWebsocket CreateSocketInternal(string address)
{
return CreateSocket(address);
diff --git a/CryptoExchange.Net/Clients/BaseApiClient.cs b/CryptoExchange.Net/Clients/BaseApiClient.cs
index 5f7113d..a377fbd 100644
--- a/CryptoExchange.Net/Clients/BaseApiClient.cs
+++ b/CryptoExchange.Net/Clients/BaseApiClient.cs
@@ -78,6 +78,9 @@ namespace CryptoExchange.Net.Clients
///
protected abstract AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials);
+ ///
+ public abstract string FormatSymbol(string baseAsset, string quoteAsset);
+
///
public void SetApiCredentials(T credentials) where T : ApiCredentials
{
diff --git a/CryptoExchange.Net/Interfaces/IBaseApiClient.cs b/CryptoExchange.Net/Interfaces/IBaseApiClient.cs
index fea84d5..88bbd73 100644
--- a/CryptoExchange.Net/Interfaces/IBaseApiClient.cs
+++ b/CryptoExchange.Net/Interfaces/IBaseApiClient.cs
@@ -12,6 +12,14 @@ namespace CryptoExchange.Net.Interfaces
///
string BaseAddress { get; }
+ ///
+ /// Format a base and quote asset to an exchange accepted symbol
+ ///
+ /// The base asset
+ /// The quote asset
+ ///
+ string FormatSymbol(string baseAsset, string quoteAsset);
+
///
/// Set the API credentials for this API client
///
diff --git a/CryptoExchange.Net/Interfaces/IOrderBookFactory.cs b/CryptoExchange.Net/Interfaces/IOrderBookFactory.cs
new file mode 100644
index 0000000..2ffc9e3
--- /dev/null
+++ b/CryptoExchange.Net/Interfaces/IOrderBookFactory.cs
@@ -0,0 +1,27 @@
+using CryptoExchange.Net.Objects.Options;
+using System;
+
+namespace CryptoExchange.Net.Interfaces
+{
+ ///
+ /// Factory for ISymbolOrderBook instances
+ ///
+ public interface IOrderBookFactory where TOptions : OrderBookOptions
+ {
+ ///
+ /// Create a new order book by symbol name
+ ///
+ /// Symbol name
+ /// Options for the order book
+ ///
+ public ISymbolOrderBook Create(string symbol, Action? options = null);
+ ///
+ /// Create a new order book by base and quote asset names
+ ///
+ /// Base asset name
+ /// Quote asset name
+ /// Options for the order book
+ ///
+ public ISymbolOrderBook Create(string baseAsset, string quoteAsset, Action? options = null);
+ }
+}
diff --git a/CryptoExchange.Net/Objects/Options/OrderBookOptions.cs b/CryptoExchange.Net/Objects/Options/OrderBookOptions.cs
index 1e6b062..9bcc39d 100644
--- a/CryptoExchange.Net/Objects/Options/OrderBookOptions.cs
+++ b/CryptoExchange.Net/Objects/Options/OrderBookOptions.cs
@@ -3,7 +3,7 @@
///
/// Base for order book options
///
- public class OrderBookOptions : ExchangeOptions
+ public class OrderBookOptions
{
///
/// Whether or not checksum validation is enabled. Default is true, disabling will ignore checksum messages.
@@ -19,11 +19,7 @@
{
return new T
{
- ApiCredentials = ApiCredentials?.Copy(),
- OutputOriginalData = OutputOriginalData,
ChecksumValidationEnabled = ChecksumValidationEnabled,
- Proxy = Proxy,
- RequestTimeout = RequestTimeout
};
}
}
diff --git a/CryptoExchange.Net/OrderBook/OrderBookFactory.cs b/CryptoExchange.Net/OrderBook/OrderBookFactory.cs
new file mode 100644
index 0000000..279dddb
--- /dev/null
+++ b/CryptoExchange.Net/OrderBook/OrderBookFactory.cs
@@ -0,0 +1,30 @@
+using CryptoExchange.Net.Interfaces;
+using CryptoExchange.Net.Objects.Options;
+using System;
+
+namespace CryptoExchange.Net.OrderBook
+{
+ ///
+ public class OrderBookFactory : IOrderBookFactory where TOptions: OrderBookOptions
+ {
+ private readonly Func?, ISymbolOrderBook> _symbolCtor;
+ private readonly Func?, ISymbolOrderBook> _assetsCtor;
+
+ ///
+ /// ctor
+ ///
+ ///
+ ///
+ public OrderBookFactory(Func?, ISymbolOrderBook> symbolCtor, Func?, ISymbolOrderBook> assetsCtor)
+ {
+ _symbolCtor = symbolCtor;
+ _assetsCtor = assetsCtor;
+ }
+
+ ///
+ public ISymbolOrderBook Create(string symbol, Action? options = null) => _symbolCtor(symbol, options);
+
+ ///
+ public ISymbolOrderBook Create(string baseAsset, string quoteAsset, Action? options = null) => _assetsCtor(baseAsset, quoteAsset, options);
+ }
+}
diff --git a/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs b/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs
index 40c4f8d..6162317 100644
--- a/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs
+++ b/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs
@@ -729,7 +729,7 @@ namespace CryptoExchange.Net.Sockets
public int Id { get; set; }
///
- /// The request id
+ /// The request weight
///
public int Weight { get; set; }