Skip to content

Commit 40fac2f

Browse files
authored
Change volume data type in MarketCandle (#837)
Change volume data type in MarketCandle from double to decimal.
1 parent 1729aaf commit 40fac2f

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

src/ExchangeSharp/API/Exchanges/BitBank/ExchangeBitBankAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(
121121
HighPrice = data[1].ConvertInvariant<decimal>(),
122122
LowPrice = data[2].ConvertInvariant<decimal>(),
123123
ClosePrice = data[3].ConvertInvariant<decimal>(),
124-
BaseCurrencyVolume = data[4].ConvertInvariant<double>(),
124+
BaseCurrencyVolume = data[4].ConvertInvariant<decimal>(),
125125
Timestamp = timestamp,
126126
};
127127
result.Add(candle);

src/ExchangeSharp/API/Exchanges/Digifinex/ExchangeDigifinexAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(
330330
Timestamp = CryptoUtility.UnixTimeStampToDateTimeSeconds(
331331
x[0].ConvertInvariant<long>()
332332
),
333-
BaseCurrencyVolume = x[1].ConvertInvariant<double>(),
333+
BaseCurrencyVolume = x[1].ConvertInvariant<decimal>(),
334334
ClosePrice = x[2].ConvertInvariant<decimal>(),
335335
HighPrice = x[3].ConvertInvariant<decimal>(),
336336
LowPrice = x[4].ConvertInvariant<decimal>(),

src/ExchangeSharp/API/Exchanges/GateIo/ExchangeGateIoAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(
305305
candleToken[0],
306306
TimestampType.UnixSeconds
307307
),
308-
BaseCurrencyVolume = candleToken[1].ConvertInvariant<double>(),
308+
BaseCurrencyVolume = candleToken[1].ConvertInvariant<decimal>(),
309309
ClosePrice = candleToken[2].ConvertInvariant<decimal>(),
310310
ExchangeName = Name,
311311
HighPrice = candleToken[3].ConvertInvariant<decimal>(),

src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(
371371
{ "symbol", marketSymbol },
372372
{ "type", periodString }
373373
};
374-
374+
375375
if (startDate != null)
376376
{
377377
payload.Add("startAt", (long)startDate.Value.UnixTimestampFromDateTimeSeconds());
@@ -406,8 +406,8 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(
406406
ClosePrice = token[i][2].ConvertInvariant<decimal>(),
407407
HighPrice = token[i][3].ConvertInvariant<decimal>(),
408408
LowPrice = token[i][4].ConvertInvariant<decimal>(),
409-
BaseCurrencyVolume = token[i][5].ConvertInvariant<double>(),
410-
QuoteCurrencyVolume = token[i][6].ConvertInvariant<double>()
409+
BaseCurrencyVolume = token[i][5].ConvertInvariant<decimal>(),
410+
QuoteCurrencyVolume = token[i][6].ConvertInvariant<decimal>()
411411
}
412412
);
413413
}

src/ExchangeSharp/API/Exchanges/LBank/ExchangeLBankAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private List<MarketCandle> ParseMarketCandle(JToken array)
305305
HighPrice = item[2].ConvertInvariant<decimal>(),
306306
LowPrice = item[3].ConvertInvariant<decimal>(),
307307
ClosePrice = item[4].ConvertInvariant<decimal>(),
308-
BaseCurrencyVolume = item[5].ConvertInvariant<double>()
308+
BaseCurrencyVolume = item[5].ConvertInvariant<decimal>()
309309
};
310310

311311
candles.Add(candle);

src/ExchangeSharp/API/Exchanges/NDAX/ExchangeNDAXAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(
399399
LowPrice = enumerable.ElementAt(2).Value<decimal>(),
400400
OpenPrice = enumerable.ElementAt(3).Value<decimal>(),
401401
ClosePrice = enumerable.ElementAt(4).Value<decimal>(),
402-
BaseCurrencyVolume = enumerable.ElementAt(5).Value<double>(),
402+
BaseCurrencyVolume = enumerable.ElementAt(5).Value<decimal>(),
403403
}
404404
)
405405
.Where(candle => !endDate.HasValue || candle.Timestamp <= endDate);

src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPIExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,8 +1096,8 @@ internal static MarketCandle ParseCandle(
10961096
out decimal baseVolume,
10971097
out decimal convertVolume
10981098
);
1099-
candle.BaseCurrencyVolume = (double)baseVolume;
1100-
candle.QuoteCurrencyVolume = (double)convertVolume;
1099+
candle.BaseCurrencyVolume = baseVolume;
1100+
candle.QuoteCurrencyVolume = convertVolume;
11011101
if (weightedAverageKey != null)
11021102
{
11031103
candle.WeightedAverage = token[weightedAverageKey].ConvertInvariant<decimal>();

src/ExchangeSharp/Model/MarketCandle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ public class MarketCandle
6666
/// <summary>
6767
/// Base currency volume (i.e. in BTC-USD, this would be BTC volume)
6868
/// </summary>
69-
public double BaseCurrencyVolume { get; set; }
69+
public decimal BaseCurrencyVolume { get; set; }
7070

7171
/// <summary>
7272
/// Quote currency volume (i.e. in BTC-USD, this would be USD volume)
7373
/// </summary>
74-
public double QuoteCurrencyVolume { get; set; }
74+
public decimal QuoteCurrencyVolume { get; set; }
7575

7676
/// <summary>
7777
/// The weighted average price if provided

src/ExchangeSharpConsole/Options/TestOption.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ await api.GetCandlesAsync(
224224
&& !string.IsNullOrWhiteSpace(candles[0].Name)
225225
&& candles[0].ExchangeName == api.Name
226226
&& candles[0].PeriodSeconds == 86400
227-
&& candles[0].BaseCurrencyVolume > 0.0
228-
&& candles[0].QuoteCurrencyVolume > 0.0
229-
&& candles[0].WeightedAverage >= 0m
227+
&& candles[0].BaseCurrencyVolume > 0
228+
&& candles[0].QuoteCurrencyVolume > 0
229+
&& candles[0].WeightedAverage >= 0
230230
);
231231

232232
Console.WriteLine($"OK ({candles.Length})");

tests/ExchangeSharpTests/ExchangeBitBankTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public async Task ShouldGetCandleStick()
131131
candle.HighPrice.Should().Be(1665719m);
132132
candle.LowPrice.Should().Be(1612861m);
133133
candle.ClosePrice.Should().Be(1629941);
134-
candle.BaseCurrencyVolume.Should().Be(5.8362);
134+
candle.BaseCurrencyVolume.Should().Be(5.8362m);
135135
candle.Timestamp
136136
.Should()
137137
.Be(DateTimeOffset.FromUnixTimeMilliseconds(1514160000000).DateTime);

0 commit comments

Comments
 (0)