Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Jul 15, 2021
1 parent 2d501f8 commit 6e9dfc0
Show file tree
Hide file tree
Showing 32 changed files with 145 additions and 137 deletions.
6 changes: 0 additions & 6 deletions Kraken.Net.UnitTests/KrakenClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Logging;
using CryptoExchange.Net.Objects;
using Kraken.Net.Objects;
using Kraken.Net.UnitTests.TestImplementations;
using System.Threading.Tasks;
Expand Down
4 changes: 2 additions & 2 deletions Kraken.Net/Converters/ExtendedDictionaryConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Kraken.Net.Converters
{
internal class ExtendedDictionaryConverter<T>: JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
var data = (KrakenDictionaryResult<T>) value;
writer.WriteStartObject();
Expand All @@ -20,7 +20,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
writer.WriteEndObject();
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var obj = JObject.Load(reader);
var inner = obj.First;
Expand Down
1 change: 0 additions & 1 deletion Kraken.Net/Interfaces/IKrakenSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Sockets;
using Kraken.Net.Objects;
using Kraken.Net.Objects.Socket;

namespace Kraken.Net.Interfaces
{
Expand Down
37 changes: 30 additions & 7 deletions Kraken.Net/Kraken.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions Kraken.Net/KrakenClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -35,11 +34,11 @@ public class KrakenClient: RestClient, IKrakenClient, IExchangeClient
/// <summary>
/// Event triggered when an order is placed via this client
/// </summary>
public event Action<ICommonOrderId> OnOrderPlaced;
public event Action<ICommonOrderId>? OnOrderPlaced;
/// <summary>
/// Event triggered when an order is cancelled via this client
/// </summary>
public event Action<ICommonOrderId> OnOrderCanceled;
public event Action<ICommonOrderId>? OnOrderCanceled;

#region ctor
/// <summary>
Expand Down Expand Up @@ -372,7 +371,7 @@ public async Task<WebCallResult<Dictionary<string, KrakenPosition>>> GetOpenPosi
return await Execute<Dictionary<string, KrakenPosition>>(GetUri("0/private/OpenPositions"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false);
}

//// <summary>
/// <summary>
/// Get ledger entries info
/// </summary>
/// <param name="assets">Filter list by asset names</param>
Expand Down Expand Up @@ -776,7 +775,12 @@ private async Task<WebCallResult<T>> Execute<T>(Uri url, HttpMethod method, Canc
return result.As<T>(result.Data.Result);
}


/// <summary>
/// Get the name of a symbol for Kraken based on the base and quote asset
/// </summary>
/// <param name="baseAsset"></param>
/// <param name="quoteAsset"></param>
/// <returns></returns>
public string GetSymbolName(string baseAsset, string quoteAsset) => (baseAsset + quoteAsset).ToUpperInvariant();

private static KlineInterval GetKlineIntervalFromTimespan(TimeSpan timeSpan)
Expand Down
7 changes: 6 additions & 1 deletion Kraken.Net/KrakenSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using System.Threading.Tasks;
using CryptoExchange.Net;
using CryptoExchange.Net.Logging;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Sockets;
using Kraken.Net.Converters;
Expand Down Expand Up @@ -74,6 +73,12 @@ public async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(
return await SubscribeAsync(new KrakenSubscribeRequest("ticker", NextId(), symbol), null, false, internalHandler).ConfigureAwait(false);
}

/// <summary>
/// Subscribe to ticker updates
/// </summary>
/// <param name="symbols">Symbols to subscribe to</param>
/// <param name="handler">Data handler</param>
/// <returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns>
public async Task<CallResult<UpdateSubscription>> SubscribeToTickerUpdatesAsync(string[] symbols, Action<DataEvent<KrakenStreamTick>> handler)
{
foreach(var symbol in symbols)
Expand Down
6 changes: 2 additions & 4 deletions Kraken.Net/KrakenSymbolOrderBook.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -10,7 +9,6 @@
using Force.Crc32;
using Kraken.Net.Interfaces;
using Kraken.Net.Objects;
using Kraken.Net.Objects.Socket;
using Microsoft.Extensions.Logging;

namespace Kraken.Net
Expand Down Expand Up @@ -66,7 +64,7 @@ private void ProcessUpdate(DataEvent<KrakenStreamOrderBook> data)
else
{
UpdateOrderBook(data.Data.Bids, data.Data.Asks);
AddChecksum((int)data.Data.Checksum);
AddChecksum((int)data.Data.Checksum!);
}
}

Expand Down Expand Up @@ -99,7 +97,7 @@ protected override bool DoChecksum(int checksum)
return true;
}

private string ToChecksumString(string value)
private static string ToChecksumString(string value)
{
return value.Replace(".", "").TrimStart('0');
}
Expand Down
4 changes: 2 additions & 2 deletions Kraken.Net/Objects/KrakenAssetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public class KrakenAssetInfo
/// Alternative name
/// </summary>
[JsonProperty("altname")]
public string AlternateName { get; set; } = "";
public string AlternateName { get; set; } = string.Empty;
/// <summary>
/// Class of the asset
/// </summary>
[JsonProperty("aclass")]
public string AssetClass { get; set; } = "";
public string AssetClass { get; set; } = string.Empty;
/// <summary>
/// Decimal precision of the asset
/// </summary>
Expand Down
7 changes: 2 additions & 5 deletions Kraken.Net/Objects/KrakenBalance.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using CryptoExchange.Net.ExchangeInterfaces;
using CryptoExchange.Net.ExchangeInterfaces;

namespace Kraken.Net.Objects
{
Expand All @@ -13,7 +10,7 @@ public class KrakenBalance: ICommonBalance
/// <summary>
/// Asset
/// </summary>
public string Asset { get; set; }
public string Asset { get; set; } = string.Empty;
/// <summary>
/// Balance
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions Kraken.Net/Objects/KrakenCancelResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using CryptoExchange.Net.Attributes;

namespace Kraken.Net.Objects
Expand All @@ -16,6 +17,6 @@ public class KrakenCancelResult
/// Pending cancellation orders
/// </summary>
[JsonOptionalProperty]
public IEnumerable<long> Pending { get; set; } = new List<long>();
public IEnumerable<long> Pending { get; set; } = Array.Empty<long>();
}
}
2 changes: 1 addition & 1 deletion Kraken.Net/Objects/KrakenDepositAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class KrakenDepositAddress
/// <summary>
/// The actual address
/// </summary>
public string Address { get; set; } = "";
public string Address { get; set; } = string.Empty;
/// <summary>
/// The expire time of the address
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Kraken.Net/Objects/KrakenDepositMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class KrakenDepositMethod
/// <summary>
/// Name of the method
/// </summary>
public string Method { get; set; } = "";
public string Method { get; set; } = string.Empty;
/// <summary>
/// Deposit limit (max) of the method
/// </summary>
public string Limit { get; set; } = "";
public string Limit { get; set; } = string.Empty;
/// <summary>
/// The deposit fee for the method
/// </summary>
Expand Down
14 changes: 7 additions & 7 deletions Kraken.Net/Objects/KrakenDepositStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ public class KrakenDepositStatus
/// <summary>
/// The name of the deposit method
/// </summary>
public string Method { get; set; } = "";
public string Method { get; set; } = string.Empty;
/// <summary>
/// The class of the asset
/// </summary>
[JsonProperty("aclass")]
public string AssetClass { get; set; } = "";
public string AssetClass { get; set; } = string.Empty;
/// <summary>
/// The asset name
/// </summary>
public string Asset { get; set; } = "";
public string Asset { get; set; } = string.Empty;
/// <summary>
/// Reference id
/// </summary>
[JsonProperty("refid")]
public string ReferenceId { get; set; } = "";
public string ReferenceId { get; set; } = string.Empty;
/// <summary>
/// Transaction id
/// </summary>
[JsonProperty("txid")]
public string TransactionId { get; set; } = "";
public string TransactionId { get; set; } = string.Empty;
/// <summary>
/// Info about the transaction
/// </summary>
[JsonProperty("info")]
public string TransactionInfo { get; set; } = "";
public string TransactionInfo { get; set; } = string.Empty;
/// <summary>
/// The amount involved in the deposit
/// </summary>
Expand All @@ -54,7 +54,7 @@ public class KrakenDepositStatus
/// <summary>
/// Status of the transaction
/// </summary>
public string Status { get; set; } = "";
public string Status { get; set; } = string.Empty;

}
}
6 changes: 3 additions & 3 deletions Kraken.Net/Objects/KrakenLedgerEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class KrakenLedgerEntry
/// Reference id
/// </summary>
[JsonProperty("refid")]
public string ReferenceId { get; set; } = "";
public string ReferenceId { get; set; } = string.Empty;
/// <summary>
/// Timestamp
/// </summary>
Expand All @@ -30,12 +30,12 @@ public class KrakenLedgerEntry
/// Class of the asset
/// </summary>
[JsonProperty("aclass")]
public string AssetClass { get; set; } = "";
public string AssetClass { get; set; } = string.Empty;

/// <summary>
/// Name of the asset
/// </summary>
public string Asset { get; set; } = "";
public string Asset { get; set; } = string.Empty;
/// <summary>
/// The quantity of the entry
/// </summary>
Expand Down
Loading

0 comments on commit 6e9dfc0

Please sign in to comment.