mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-13 09:23:04 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 917d060827 | |||
| c58bc2be07 | |||
| ff3356e2b4 | |||
| 79434c7be5 | |||
| 168dabc11f | |||
| 71ee263683 | |||
| 7239b9c289 |
@@ -38,6 +38,11 @@ namespace CryptoExchange.Net.Clients
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool OutputOriginalData { get; }
|
public bool OutputOriginalData { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not API credentials have been configured for this client. Does not check the credentials are actually valid.
|
||||||
|
/// </summary>
|
||||||
|
public bool Authenticated => ApiOptions.ApiCredentials != null || ClientOptions.ApiCredentials != null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Api options
|
/// Api options
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -94,42 +94,45 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
if (reader.TokenType == JsonTokenType.EndArray)
|
if (reader.TokenType == JsonTokenType.EndArray)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
var attribute = attributes.SingleOrDefault(a => a.ArrayProperty.Index == index);
|
var indexAttributes = attributes.Where(a => a.ArrayProperty.Index == index);
|
||||||
if (attribute == null)
|
if (!indexAttributes.Any())
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetType = attribute.TargetType;
|
foreach (var attribute in indexAttributes)
|
||||||
object? value = null;
|
|
||||||
if (attribute.JsonConverterType != null)
|
|
||||||
{
|
{
|
||||||
// Has JsonConverter attribute
|
var targetType = attribute.TargetType;
|
||||||
var options = new JsonSerializerOptions();
|
object? value = null;
|
||||||
options.Converters.Add((JsonConverter)Activator.CreateInstance(attribute.JsonConverterType));
|
if (attribute.JsonConverterType != null)
|
||||||
value = JsonDocument.ParseValue(ref reader).Deserialize(targetType, options);
|
|
||||||
}
|
|
||||||
else if (attribute.DefaultDeserialization)
|
|
||||||
{
|
|
||||||
// Use default deserialization
|
|
||||||
value = JsonDocument.ParseValue(ref reader).Deserialize(targetType);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
value = reader.TokenType switch
|
|
||||||
{
|
{
|
||||||
JsonTokenType.Null => null,
|
// Has JsonConverter attribute
|
||||||
JsonTokenType.False => false,
|
var options = new JsonSerializerOptions();
|
||||||
JsonTokenType.True => true,
|
options.Converters.Add((JsonConverter)Activator.CreateInstance(attribute.JsonConverterType));
|
||||||
JsonTokenType.String => reader.GetString(),
|
value = JsonDocument.ParseValue(ref reader).Deserialize(targetType, options);
|
||||||
JsonTokenType.Number => reader.GetDecimal(),
|
}
|
||||||
_ => throw new NotImplementedException($"Array deserialization of type {reader.TokenType} not supported"),
|
else if (attribute.DefaultDeserialization)
|
||||||
};
|
{
|
||||||
|
// Use default deserialization
|
||||||
|
value = JsonDocument.ParseValue(ref reader).Deserialize(targetType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = reader.TokenType switch
|
||||||
|
{
|
||||||
|
JsonTokenType.Null => null,
|
||||||
|
JsonTokenType.False => false,
|
||||||
|
JsonTokenType.True => true,
|
||||||
|
JsonTokenType.String => reader.GetString(),
|
||||||
|
JsonTokenType.Number => reader.GetDecimal(),
|
||||||
|
_ => throw new NotImplementedException($"Array deserialization of type {reader.TokenType} not supported"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
attribute.PropertyInfo.SetValue(result, value == null ? null : Convert.ChangeType(value, targetType, CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute.PropertyInfo.SetValue(result, value == null ? null : Convert.ChangeType(value, targetType, CultureInfo.InvariantCulture));
|
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,14 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
return reader.GetDecimal().ToString();
|
return reader.GetDecimal().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return reader.GetString();
|
try
|
||||||
|
{
|
||||||
|
return reader.GetString();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -133,7 +133,20 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public List<T?>? GetValues<T>(MessagePath path) => throw new NotImplementedException();
|
public List<T?>? GetValues<T>(MessagePath path)
|
||||||
|
{
|
||||||
|
if (!IsJson)
|
||||||
|
throw new InvalidOperationException("Can't access json data on non-json message");
|
||||||
|
|
||||||
|
var value = GetPathNode(path);
|
||||||
|
if (value == null)
|
||||||
|
return default;
|
||||||
|
|
||||||
|
if (value.Value.ValueKind != JsonValueKind.Array)
|
||||||
|
return default;
|
||||||
|
|
||||||
|
return value.Value.Deserialize<List<T>>()!;
|
||||||
|
}
|
||||||
|
|
||||||
private JsonElement? GetPathNode(MessagePath path)
|
private JsonElement? GetPathNode(MessagePath path)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
<PackageId>CryptoExchange.Net</PackageId>
|
<PackageId>CryptoExchange.Net</PackageId>
|
||||||
<Authors>JKorf</Authors>
|
<Authors>JKorf</Authors>
|
||||||
<Description>CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.</Description>
|
<Description>CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.</Description>
|
||||||
<PackageVersion>8.0.2</PackageVersion>
|
<PackageVersion>8.0.3</PackageVersion>
|
||||||
<AssemblyVersion>8.0.2</AssemblyVersion>
|
<AssemblyVersion>8.0.3</AssemblyVersion>
|
||||||
<FileVersion>8.0.2</FileVersion>
|
<FileVersion>8.0.3</FileVersion>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<PackageTags>OKX;OKX.Net;Mexc;Mexc.Net;Kucoin;Kucoin.Net;Kraken;Kraken.Net;Huobi;Huobi.Net;CoinEx;CoinEx.Net;Bybit;Bybit.Net;Bitget;Bitget.Net;Bitfinex;Bitfinex.Net;Binance;Binance.Net;CryptoCurrency;CryptoCurrency Exchange</PackageTags>
|
<PackageTags>OKX;OKX.Net;Mexc;Mexc.Net;Kucoin;Kucoin.Net;Kraken;Kraken.Net;Huobi;Huobi.Net;CoinEx;CoinEx.Net;Bybit;Bybit.Net;Bitget;Bitget.Net;Bitfinex;Bitfinex.Net;Binance;Binance.Net;CryptoCurrency;CryptoCurrency Exchange</PackageTags>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
TradingMode[] SupportedTradingModes { get; }
|
TradingMode[] SupportedTradingModes { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not API credentials have been configured for this client. Does not check the credentials are actually valid.
|
||||||
|
/// </summary>
|
||||||
|
bool Authenticated { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Format a base and quote asset to an exchange accepted symbol
|
/// Format a base and quote asset to an exchange accepted symbol
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ Make a one time donation in a crypto currency of your choice. If you prefer to d
|
|||||||
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
|
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
|
||||||
|
|
||||||
## Release notes
|
## Release notes
|
||||||
|
* Version 8.0.3 - 14 Oct 2024
|
||||||
|
* Added support for duplicate array indexes in System.Text.Json ArrayConverter
|
||||||
|
* Added fallback for unparsable value in System.Text.Json NumberStringConverter
|
||||||
|
* Added Authenticated property on base client and shared client
|
||||||
|
* Added GetValues System.Text.Json implementation in message accessor
|
||||||
|
|
||||||
* Version 8.0.2 - 09 Oct 2024
|
* Version 8.0.2 - 09 Oct 2024
|
||||||
* Updated dependency versions, including System.Text.Json from 8.0.4 to 8.0.5 containing a vulnerability fix
|
* Updated dependency versions, including System.Text.Json from 8.0.4 to 8.0.5 containing a vulnerability fix
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -1964,8 +1964,9 @@ var balances = await restClient.HTX.SpotApi.SharedClient.GetBalancesAsync(new Ge
|
|||||||
// Needs authentication: True
|
// Needs authentication: True
|
||||||
// Required exchange specific parameters: [Int64] AccountId: Account id of the user | example: 123123123</code></pre>
|
// Required exchange specific parameters: [Int64] AccountId: Account id of the user | example: 123123123</code></pre>
|
||||||
<h4 id="shared_interfaces">Available Interfaces</h4>
|
<h4 id="shared_interfaces">Available Interfaces</h4>
|
||||||
|
<p>What interfaces are actually available and implemented on each exchange clients depends on what functionality is available in the specific API.</p>
|
||||||
|
|
||||||
<p>Available REST shared interfaces</p>
|
<p style="font-style: italic;">Available REST shared interfaces</p>
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<tr><th>Interface</th><th>Description</th></tr>
|
<tr><th>Interface</th><th>Description</th></tr>
|
||||||
<tr><td><code>IAssetsRestClient</code></td><td>For requesting withdrawal and deposit info for assets</td></tr>
|
<tr><td><code>IAssetsRestClient</code></td><td>For requesting withdrawal and deposit info for assets</td></tr>
|
||||||
@@ -1993,7 +1994,7 @@ var balances = await restClient.HTX.SpotApi.SharedClient.GetBalancesAsync(new Ge
|
|||||||
<tr><td><code>IPositionModeRestClient</code></td><td>For managing the position mode for the user</td></tr>
|
<tr><td><code>IPositionModeRestClient</code></td><td>For managing the position mode for the user</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>Available Socket shared interfaces</p>
|
<p style="font-style: italic;">Available Socket shared interfaces</p>
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<tr><th>Interface</th><th>Description</th></tr>
|
<tr><th>Interface</th><th>Description</th></tr>
|
||||||
<tr><td><code>IBookTickerSocketClient</code></td><td>For subscribing to book ticker (best bid/ask) updates for a symbol</td></tr>
|
<tr><td><code>IBookTickerSocketClient</code></td><td>For subscribing to book ticker (best bid/ask) updates for a symbol</td></tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user