Skip to content

Commit

Permalink
Updated CryptoExchange.Net version
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Jun 11, 2024
1 parent 63f6993 commit 8ba1b98
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Kucoin.Net/Kucoin.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>10.0</LangVersion>
Expand Down Expand Up @@ -49,7 +49,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.5.2" />
<PackageReference Include="CryptoExchange.Net" Version="7.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 7 additions & 7 deletions Kucoin.Net/KucoinAuthenticationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public override void AuthenticateRequest(
RestApiClient apiClient,
Uri uri,
HttpMethod method,
IDictionary<string, object> uriParams,
IDictionary<string, object> bodyParams,
IDictionary<string, object> uriParameters,
IDictionary<string, object> bodyParameters,
Dictionary<string, string> headers,
bool auth,
ArrayParametersSerialization arraySerialization,
HttpMethodParameterPosition parameterPosition,
RequestBodyFormat bodyFormat)
RequestBodyFormat requestBodyFormat)
{
if (!auth)
return;
Expand All @@ -47,7 +47,7 @@ public override void AuthenticateRequest(
brokerKey = apiClient is KucoinRestClientFuturesApi ? "9e08c05f-454d-4580-82af-2f4c7027fd00" : "f8ae62cb-2b3d-420c-8c98-e1c17dd4e30a";
}

uri = uri.SetParameters(uriParams, arraySerialization);
uri = uri.SetParameters(uriParameters, arraySerialization);
headers.Add("KC-API-KEY", _credentials.Key!.GetString());
headers.Add("KC-API-TIMESTAMP", GetMillisecondTimestamp(apiClient).ToString());
headers.Add("KC-API-PASSPHRASE", SignHMACSHA256(_credentials.PassPhrase.GetString(), SignOutputType.Base64));
Expand All @@ -56,9 +56,9 @@ public override void AuthenticateRequest(
string jsonContent = string.Empty;
if (parameterPosition == HttpMethodParameterPosition.InBody)
{
jsonContent = bodyParams.Count == 1 && bodyParams.First().Key == "<BODY>"
? JsonConvert.SerializeObject(bodyParams.First().Value)
: JsonConvert.SerializeObject(bodyParams);
jsonContent = bodyParameters.Count == 1 && bodyParameters.First().Key == "<BODY>"
? JsonConvert.SerializeObject(bodyParameters.First().Value)
: JsonConvert.SerializeObject(bodyParameters);
}

var signData = headers["KC-API-TIMESTAMP"] + method + Uri.UnescapeDataString(uri.PathAndQuery) + jsonContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public KucoinBalanceSubscription(
public override CallResult DoHandleMessage(SocketConnection connection, DataEvent<object> message)
{
if (message.Data is KucoinSocketUpdate<KucoinStreamOrderMarginUpdate> marginUpdate)
_onOrderMarginUpdate?.Invoke(message.As(marginUpdate.Data, marginUpdate.Topic, SocketUpdateType.Update));
_onOrderMarginUpdate?.Invoke(message.As(marginUpdate.Data, marginUpdate.Topic, null, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinStreamFuturesBalanceUpdate> balanceUpdate)
_onBalanceUpdate?.Invoke(message.As(balanceUpdate.Data, balanceUpdate.Topic, SocketUpdateType.Update));
_onBalanceUpdate?.Invoke(message.As(balanceUpdate.Data, balanceUpdate.Topic, null, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinStreamFuturesWithdrawableUpdate> withdrawableUpdate)
_onWithdrawableUpdate?.Invoke(message.As(withdrawableUpdate.Data, withdrawableUpdate.Topic, SocketUpdateType.Update));
_onWithdrawableUpdate?.Invoke(message.As(withdrawableUpdate.Data, withdrawableUpdate.Topic, null, SocketUpdateType.Update));

return new CallResult(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override CallResult DoHandleMessage(SocketConnection connection, DataEven
{
var data = (KucoinSocketUpdate<KucoinContractAnnouncement>)message.Data;
data.Data.Event = data.Subject;
_dataHandler.Invoke(message.As(data.Data, data.Topic, SocketUpdateType.Update));
_dataHandler.Invoke(message.As(data.Data, data.Topic, data.Data.Symbol, SocketUpdateType.Update));
return new CallResult(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public KucoinInstrumentSubscription(ILogger logger,List<string>? symbols, Action
public override CallResult DoHandleMessage(SocketConnection connection, DataEvent<object> message)
{
if (message.Data is KucoinSocketUpdate<KucoinStreamFuturesMarkIndexPrice> markUpdate)
_markIndexPriceHandler?.Invoke(message.As(markUpdate.Data, markUpdate.Topic, SocketUpdateType.Update));
_markIndexPriceHandler?.Invoke(message.As(markUpdate.Data, markUpdate.Topic, markUpdate.Topic.Split(new char[] { ':' }).Last(), SocketUpdateType.Update));

if (message.Data is KucoinSocketUpdate<KucoinStreamFuturesFundingRate> fundingUpdate)
_fundingRateHandler?.Invoke(message.As(fundingUpdate.Data, fundingUpdate.Topic, SocketUpdateType.Update));
_fundingRateHandler?.Invoke(message.As(fundingUpdate.Data, fundingUpdate.Topic, fundingUpdate.Topic.Split(new char[] { ':' }).Last(), SocketUpdateType.Update));
return new CallResult(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public KucoinMarginOrderSubscription(
public override CallResult DoHandleMessage(SocketConnection connection, DataEvent<object> message)
{
if (message.Data is KucoinSocketUpdate<KucoinMarginOrderDoneUpdate> matchUpdate)
_onOrderDone?.Invoke(message.As(matchUpdate.Data, matchUpdate.Topic, SocketUpdateType.Update));
_onOrderDone?.Invoke(message.As(matchUpdate.Data, matchUpdate.Topic, null, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinMarginOrderUpdate> orderUpdate)
{
if (string.Equals(orderUpdate.Subject, "order.open", StringComparison.Ordinal))
_onNewOrder?.Invoke(message.As(orderUpdate.Data, orderUpdate.Topic, SocketUpdateType.Update));
_onNewOrder?.Invoke(message.As(orderUpdate.Data, orderUpdate.Topic, null, SocketUpdateType.Update));
else
_onOrderData?.Invoke(message.As(orderUpdate.Data, orderUpdate.Topic, SocketUpdateType.Update));
_onOrderData?.Invoke(message.As(orderUpdate.Data, orderUpdate.Topic, null, SocketUpdateType.Update));
}

return new CallResult(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public KucoinMarginPositionSubscription(
public override CallResult DoHandleMessage(SocketConnection connection, DataEvent<object> message)
{
if (message.Data is KucoinSocketUpdate<KucoinMarginDebtRatioUpdate> debtUpdate)
_onDebtRatioChange?.Invoke(message.As(debtUpdate.Data, debtUpdate.Topic, SocketUpdateType.Update));
_onDebtRatioChange?.Invoke(message.As(debtUpdate.Data, debtUpdate.Topic, null, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinMarginPositionStatusUpdate> statusUpdate)
_onPositionStatusChange?.Invoke(message.As(statusUpdate.Data, statusUpdate.Topic, SocketUpdateType.Update));
_onPositionStatusChange?.Invoke(message.As(statusUpdate.Data, statusUpdate.Topic, null, SocketUpdateType.Update));

return new CallResult(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public KucoinOrderSubscription(
public override CallResult DoHandleMessage(SocketConnection connection, DataEvent<object> message)
{
if (message.Data is KucoinSocketUpdate<KucoinStreamOrderMatchUpdate> matchUpdate)
_onTradeData?.Invoke(message.As(matchUpdate.Data, matchUpdate.Topic, SocketUpdateType.Update));
_onTradeData?.Invoke(message.As(matchUpdate.Data, matchUpdate.Topic, matchUpdate.Data.Symbol, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinStreamOrderUpdate> orderUpdate)
_onOrderData?.Invoke(message.As(orderUpdate.Data, orderUpdate.Topic, SocketUpdateType.Update));
_onOrderData?.Invoke(message.As(orderUpdate.Data, orderUpdate.Topic, orderUpdate.Data.Symbol, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinStreamOrderNewUpdate> newOrderUpdate)
_onNewOrder?.Invoke(message.As(newOrderUpdate.Data, newOrderUpdate.Topic, SocketUpdateType.Update));
_onNewOrder?.Invoke(message.As(newOrderUpdate.Data, newOrderUpdate.Topic, newOrderUpdate.Data.Symbol, SocketUpdateType.Update));

return new CallResult(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public KucoinPositionSubscription(
public override CallResult DoHandleMessage(SocketConnection connection, DataEvent<object> message)
{
if (message.Data is KucoinSocketUpdate<KucoinPositionMarkPriceUpdate> markUpdate)
_onMarkPriceUpdate?.Invoke(message.As(markUpdate.Data, markUpdate.Topic, SocketUpdateType.Update));
_onMarkPriceUpdate?.Invoke(message.As(markUpdate.Data, markUpdate.Topic, null, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinPositionUpdate> positionUpdate)
_onPositionUpdate?.Invoke(message.As(positionUpdate.Data, positionUpdate.Topic, SocketUpdateType.Update));
_onPositionUpdate?.Invoke(message.As(positionUpdate.Data, positionUpdate.Topic, positionUpdate.Data.Symbol, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinPositionFundingSettlementUpdate> fundUpdate)
_onFundingSettlementUpdate?.Invoke(message.As(fundUpdate.Data, fundUpdate.Topic, SocketUpdateType.Update));
_onFundingSettlementUpdate?.Invoke(message.As(fundUpdate.Data, fundUpdate.Topic, null, SocketUpdateType.Update));
if (message.Data is KucoinSocketUpdate<KucoinPositionRiskAdjustResultUpdate> riskAdjust)
_onRiskAdjustUpdate?.Invoke(message.As(riskAdjust.Data, riskAdjust.Topic, SocketUpdateType.Update));
_onRiskAdjustUpdate?.Invoke(message.As(riskAdjust.Data, riskAdjust.Topic, null, SocketUpdateType.Update));

return new CallResult(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override CallResult DoHandleMessage(SocketConnection connection, DataEven
if (string.Equals(topic, "all", StringComparison.Ordinal))
topic = data.Subject;

_handler.Invoke(message.As(data.Data, topic, SocketUpdateType.Update));
_handler.Invoke(message.As(data.Data, data.Topic, topic, SocketUpdateType.Update));
return new CallResult(null);
}

Expand Down

0 comments on commit 8ba1b98

Please sign in to comment.