Skip to content

Commit 9585ba9

Browse files
authored
[Bybit] Changed bybit exchange names (#802)
* Implementation of Bybit V5 unified API Implemented main private and public methods, some public (candles and orderbook) and private WebSockets. A decision was made to split spot, inverse, linear, and option branches into different APIs because: 1) market symbols intersect, 2) there are no any method to get all the markets (all orders, all positions) from different branches in one call. Branches behave as separate exchanges. * [Bybit] Changed bybit exchange names Added custom names instead of generic Bybit that was used previously, to get bybit exchange branches by name in ExchangeAPI.GetExchangeAPIAsync<>(). Also minor refactoring.
1 parent eb51abd commit 9585ba9

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

src/ExchangeSharp/API/Exchanges/Bybit/ExchangeBybitInverseAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace ExchangeSharp
77
{
8-
[ApiName(ExchangeName.Bybit)]
98
public class ExchangeBybitInverseAPI : ExchangeBybitV5Base
109
{
1110
protected override MarketCategory MarketCategory => MarketCategory.Inverse;
@@ -18,4 +17,5 @@ public ExchangeBybitInverseAPI(bool isUnifiedAccount)
1817
IsUnifiedAccount = isUnifiedAccount;
1918
}
2019
}
20+
public partial class ExchangeName { public const string BybitInverse = "BybitInverse"; }
2121
}

src/ExchangeSharp/API/Exchanges/Bybit/ExchangeBybitLinearAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace ExchangeSharp
77
{
8-
[ApiName(ExchangeName.Bybit)]
98
public class ExchangeBybitLinearAPI : ExchangeBybitV5Base
109
{
1110
protected override MarketCategory MarketCategory => MarketCategory.Linear;
@@ -18,4 +17,5 @@ public ExchangeBybitLinearAPI(bool isUnifiedAccount)
1817
IsUnifiedAccount = isUnifiedAccount;
1918
}
2019
}
20+
public partial class ExchangeName { public const string BybitLinear = "BybitLinear"; }
2121
}

src/ExchangeSharp/API/Exchanges/Bybit/ExchangeBybitOptionAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace ExchangeSharp
77
{
8-
[ApiName(ExchangeName.Bybit)]
98
public class ExchangeBybitOptionAPI : ExchangeBybitV5Base
109
{
1110
protected override MarketCategory MarketCategory => MarketCategory.Option;
@@ -18,4 +17,5 @@ public ExchangeBybitOptionAPI(bool isUnifiedAccount)
1817
IsUnifiedAccount = isUnifiedAccount;
1918
}
2019
}
20+
public partial class ExchangeName { public const string BybitOption = "BybitOption"; }
2121
}

src/ExchangeSharp/API/Exchanges/Bybit/ExchangeBybitSpotAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace ExchangeSharp
77
{
8-
[ApiName(ExchangeName.Bybit)]
98
public class ExchangeBybitSpotAPI : ExchangeBybitV5Base
109
{
1110
protected override MarketCategory MarketCategory => MarketCategory.Spot;
@@ -18,4 +17,5 @@ public ExchangeBybitSpotAPI(bool isUnified)
1817
IsUnifiedAccount = isUnified;
1918
}
2019
}
20+
public partial class ExchangeName { public const string BybitSpot = "BybitSpot"; }
2121
}

src/ExchangeSharp/API/Exchanges/Bybit/ExchangeBybitV5Base.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(strin
160160
string url = "/v5/market/kline";
161161
int maxLimit = 200;
162162
limit ??= maxLimit;
163-
if (limit.Value > maxLimit) { limit = maxLimit; }
163+
if (limit.Value > maxLimit)
164+
{
165+
limit = maxLimit;
166+
}
164167
List<MarketCandle> candles = new List<MarketCandle>();
165168
string periodString = PeriodSecondsToString(periodSeconds);
166169
if (startDate == null)
@@ -244,7 +247,10 @@ protected override async Task<Dictionary<string, decimal>> OnGetAmountsAvailable
244247
Dictionary<string, decimal> amounts = new Dictionary<string, decimal>(StringComparer.OrdinalIgnoreCase);
245248

246249
var accountBalances = result["list"].FirstOrDefault(i => i["accountType"].ToStringInvariant() == accType);
247-
if (accountBalances == null) return amounts;
250+
if (accountBalances == null)
251+
{
252+
return amounts;
253+
}
248254
if (IsUnifiedAccount.Value)
249255
{
250256
// All assets that can be used as collateral, converted to USD, will be here
@@ -253,7 +259,6 @@ protected override async Task<Dictionary<string, decimal>> OnGetAmountsAvailable
253259
string balanceKey = accType == "SPOT" ? "free" : "availableToWithdraw";
254260
foreach (var coin in accountBalances["coin"])
255261
{
256-
257262
decimal amount = coin[balanceKey].ConvertInvariant<decimal>();
258263
if (amount > 0m)
259264
{

src/ExchangeSharp/Model/ExchangeOrderBook.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public ExchangeOrderPrice(BinaryReader reader)
6868
public sealed class ExchangeOrderBook
6969
{
7070
/// <summary>
71-
/// Needed to distinguish between fool book and deltas
71+
/// Needed to distinguish between full book and deltas
7272
/// </summary>
7373
public bool IsFromSnapshot { get; set; }
7474
public string ExchangeName { get; set; }

0 commit comments

Comments
 (0)