diff --git a/ByBit.Net/Bybit.Net.csproj b/ByBit.Net/Bybit.Net.csproj index 0e1959a6..2420e155 100644 --- a/ByBit.Net/Bybit.Net.csproj +++ b/ByBit.Net/Bybit.Net.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;netstandard2.1 enable @@ -48,7 +48,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ByBit.Net/Clients/V5/BybitRestClientApiTrading.cs b/ByBit.Net/Clients/V5/BybitRestClientApiTrading.cs index 3b5c8438..ef426ad2 100644 --- a/ByBit.Net/Clients/V5/BybitRestClientApiTrading.cs +++ b/ByBit.Net/Clients/V5/BybitRestClientApiTrading.cs @@ -732,7 +732,7 @@ public async Task SetTradingStopAsync( #region Purchase Leverage Token /// - public async Task> PurchaseLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default) + public async Task> PurchaseLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default) { var parameters = new Dictionary() { @@ -742,7 +742,7 @@ public async Task> PurchaseLeverageToken parameters.AddOptionalParameter("serialNo", clientOrderId); - return await _baseClient.SendRequestAsync(_baseClient.GetUrl("v5/position/spot-lever-token/purchase"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); + return await _baseClient.SendRequestAsync(_baseClient.GetUrl("v5/spot-lever-token/purchase"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); } #endregion @@ -750,7 +750,7 @@ public async Task> PurchaseLeverageToken #region Redeem Leverage Token /// - public async Task> RedeemLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default) + public async Task> RedeemLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default) { var parameters = new Dictionary() { @@ -760,7 +760,7 @@ public async Task> RedeemLeverageTokenAs parameters.AddOptionalParameter("serialNo", clientOrderId); - return await _baseClient.SendRequestAsync(_baseClient.GetUrl("v5/position/spot-lever-token/redeem"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); + return await _baseClient.SendRequestAsync(_baseClient.GetUrl("v5/spot-lever-token/redeem"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); } #endregion @@ -779,7 +779,7 @@ public async Task>> GetLeve parameters.AddOptionalParameter("orderId", orderId); parameters.AddOptionalParameter("ltCoin", token); - var result = await _baseClient.SendRequestAsync>(_baseClient.GetUrl("v5/position/spot-lever-token/order-record"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); + var result = await _baseClient.SendRequestAsync>(_baseClient.GetUrl("v5/spot-lever-token/order-record"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); if (!result) return result.As>(default); diff --git a/ByBit.Net/Interfaces/Clients/V5/IBybitRestClientApiTrading.cs b/ByBit.Net/Interfaces/Clients/V5/IBybitRestClientApiTrading.cs index a19e3627..dd0932de 100644 --- a/ByBit.Net/Interfaces/Clients/V5/IBybitRestClientApiTrading.cs +++ b/ByBit.Net/Interfaces/Clients/V5/IBybitRestClientApiTrading.cs @@ -392,7 +392,7 @@ Task>>> EditMultip /// Custom order id /// Cancellation token /// - Task> PurchaseLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default); + Task> PurchaseLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default); /// /// Redeem a leverage token @@ -403,7 +403,7 @@ Task>>> EditMultip /// Custom order id /// Cancellation token /// - Task> RedeemLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default); + Task> RedeemLeverageTokenAsync(string token, decimal quantity, string? clientOrderId = null, CancellationToken ct = default); /// /// Get leverage token order history diff --git a/ByBit.Net/Objects/Models/V5/BybitApiKeyInfo.cs b/ByBit.Net/Objects/Models/V5/BybitApiKeyInfo.cs index 0c3ef052..cb1c30cd 100644 --- a/ByBit.Net/Objects/Models/V5/BybitApiKeyInfo.cs +++ b/ByBit.Net/Objects/Models/V5/BybitApiKeyInfo.cs @@ -110,6 +110,12 @@ public class BybitApiKeyInfo /// [JsonProperty("kycRegion")] public string? KycRegion { get; set; } + + /// + /// The type of api key. 1:personal, 2:connected to the third-party app + /// + [JsonProperty("type")] + public int ApiKeyType { get; set; } /// /// Permissions /// @@ -157,5 +163,9 @@ public class BybitPermissions /// NFT permissions /// public IEnumerable NFT { get; set; } = Array.Empty(); + /// + /// Affiliate permissions + /// + public IEnumerable Affiliate { get; set; } = Array.Empty(); } } diff --git a/ByBit.Net/Objects/Models/V5/BybitBorrowHistory.cs b/ByBit.Net/Objects/Models/V5/BybitBorrowHistory.cs index b1bf819f..3d83f5c0 100644 --- a/ByBit.Net/Objects/Models/V5/BybitBorrowHistory.cs +++ b/ByBit.Net/Objects/Models/V5/BybitBorrowHistory.cs @@ -33,7 +33,7 @@ public class BybitBorrowHistory /// /// Cost exemption /// - public decimal CostExcemption { get; set; } + public decimal CostExemption { get; set; } /// /// Total borrow quantity /// diff --git a/ByBit.Net/Objects/Models/V5/BybitCollateralInfo.cs b/ByBit.Net/Objects/Models/V5/BybitCollateralInfo.cs index f2a89fce..d12ebcfc 100644 --- a/ByBit.Net/Objects/Models/V5/BybitCollateralInfo.cs +++ b/ByBit.Net/Objects/Models/V5/BybitCollateralInfo.cs @@ -28,6 +28,11 @@ public class BybitCollateralInfo [JsonProperty("freeBorrowingAmount")] public decimal? FreeBorrowAmount { get; set; } /// + /// The maximum limit for interest-free borrowing + /// + [JsonProperty("freeBorrowingLimit")] + public decimal? FreeBorrowingLimit { get; set; } + /// /// Borrow amount /// [JsonProperty("borrowAmount")] @@ -48,9 +53,19 @@ public class BybitCollateralInfo [JsonProperty("marginCollateral")] public bool MarginCollateral { get; set; } /// + /// Whether the collateral is turned on by user + /// + [JsonProperty("collateralSwitch")] + public bool CollateralSwitch { get; set; } + /// /// Collateral ratio /// [JsonProperty("collateralRatio")] public decimal CollateralRatio { get; set; } + /// + /// Borrow usage rate + /// + [JsonProperty("borrowUsageRate")] + public decimal BorrowUsageRate { get; set; } } } diff --git a/ByBit.Net/Objects/Models/V5/BybitDeliveryRecord.cs b/ByBit.Net/Objects/Models/V5/BybitDeliveryRecord.cs index 3f35e882..0492c8c7 100644 --- a/ByBit.Net/Objects/Models/V5/BybitDeliveryRecord.cs +++ b/ByBit.Net/Objects/Models/V5/BybitDeliveryRecord.cs @@ -43,6 +43,7 @@ public class BybitDeliveryRecord /// /// Realized profit and loss /// + [JsonProperty("deliveryRpl")] public decimal RealizedPnl { get; set; } } } diff --git a/ByBit.Net/Objects/Models/V5/BybitGreeks.cs b/ByBit.Net/Objects/Models/V5/BybitGreeks.cs index 0bfb3df3..d0dee137 100644 --- a/ByBit.Net/Objects/Models/V5/BybitGreeks.cs +++ b/ByBit.Net/Objects/Models/V5/BybitGreeks.cs @@ -1,4 +1,6 @@ -namespace Bybit.Net.Objects.Models.V5 +using Newtonsoft.Json; + +namespace Bybit.Net.Objects.Models.V5 { /// /// Greeks @@ -8,6 +10,7 @@ public class BybitGreeks /// /// Asset /// + [JsonProperty("baseCoin")] public string BaseAsset { get; set; } = string.Empty; /// /// Delta diff --git a/ByBit.Net/Objects/Models/V5/BybitLeverageTokenRecord.cs b/ByBit.Net/Objects/Models/V5/BybitLeverageTokenRecord.cs index c3f09767..64956de9 100644 --- a/ByBit.Net/Objects/Models/V5/BybitLeverageTokenRecord.cs +++ b/ByBit.Net/Objects/Models/V5/BybitLeverageTokenRecord.cs @@ -33,12 +33,7 @@ public class BybitLeverageTokenRecord /// Purchase amount /// [JsonProperty("amount")] - public decimal Quantity { get; set; } - /// - /// Purchase id - /// - [JsonProperty("purchaseId")] - public string PurchaseId { get; set; } = string.Empty; + public decimal? Quantity { get; set; } /// /// Serial number /// @@ -50,4 +45,28 @@ public class BybitLeverageTokenRecord [JsonProperty("valueCoin")] public string QuoteAsset { get; set; } = string.Empty; } + + /// + /// Purchase record + /// + public class BybitLeverageTokenPurchase : BybitLeverageTokenRecord + { + /// + /// Purchase id + /// + [JsonProperty("purchaseId")] + public string PurchaseId { get; set; } = string.Empty; + } + + /// + /// Purchase record + /// + public class BybitLeverageTokenRedemption : BybitLeverageTokenRecord + { + /// + /// Redeem id + /// + [JsonProperty("redeemId")] + public string RedeemId { get; set; } = string.Empty; + } } diff --git a/ByBit.Net/Objects/Models/V5/BybitLeveragedTokenNav.cs b/ByBit.Net/Objects/Models/V5/BybitLeveragedTokenNav.cs index 10c36bb4..b9426c10 100644 --- a/ByBit.Net/Objects/Models/V5/BybitLeveragedTokenNav.cs +++ b/ByBit.Net/Objects/Models/V5/BybitLeveragedTokenNav.cs @@ -12,7 +12,8 @@ public class BybitLeveragedTokenNav /// /// Timestamp /// - [JsonConverter(typeof(EnumConverter))] + [JsonConverter(typeof(DateTimeConverter))] + [JsonProperty("time")] public DateTime Timestamp { get; set; } /// /// Symbol diff --git a/ByBit.Net/Objects/Models/V5/BybitOptionTicker.cs b/ByBit.Net/Objects/Models/V5/BybitOptionTicker.cs index 14a18ef8..55e08002 100644 --- a/ByBit.Net/Objects/Models/V5/BybitOptionTicker.cs +++ b/ByBit.Net/Objects/Models/V5/BybitOptionTicker.cs @@ -24,7 +24,7 @@ public class BybitOptionTicker /// /// Best bid IV /// - [JsonProperty("bid1lv")] + [JsonProperty("bid1Iv")] public decimal BestBidIv { get; set; } /// /// Best ask price @@ -39,7 +39,7 @@ public class BybitOptionTicker /// /// Best ask IV /// - [JsonProperty("ask1lv")] + [JsonProperty("ask1Iv")] public decimal BestAskIv { get; set; } /// /// Last trade price diff --git a/ByBit.Net/Objects/Models/V5/BybitOrder.cs b/ByBit.Net/Objects/Models/V5/BybitOrder.cs index 9509e488..0731ddd9 100644 --- a/ByBit.Net/Objects/Models/V5/BybitOrder.cs +++ b/ByBit.Net/Objects/Models/V5/BybitOrder.cs @@ -220,5 +220,16 @@ public class BybitOrder /// [JsonProperty("smpOrderId")] public string? SelfMatchPreventionOrderId { get; set; } + /// + /// Take profit/stop loss mode + /// + [JsonConverter(typeof(EnumConverter))] + [JsonProperty("tpslMode")] + public StopLossTakeProfitMode? TpSlMode { get; set; } + /// + /// Place type (option only) + /// + [JsonProperty("placeType")] + public string? PlaceType { get; set; } } } diff --git a/ByBit.Net/Objects/Models/V5/BybitOrderbook.cs b/ByBit.Net/Objects/Models/V5/BybitOrderbook.cs index 3f912bcf..a2442c0c 100644 --- a/ByBit.Net/Objects/Models/V5/BybitOrderbook.cs +++ b/ByBit.Net/Objects/Models/V5/BybitOrderbook.cs @@ -37,6 +37,11 @@ public class BybitOrderbook /// [JsonProperty("u")] public int UpdateId { get; set; } + /// + /// Cross sequence + /// + [JsonProperty("seq")] + public long? Sequence { get; set; } } /// diff --git a/ByBit.Net/Objects/Models/V5/BybitPosition.cs b/ByBit.Net/Objects/Models/V5/BybitPosition.cs index 45722c9d..2e7fba13 100644 --- a/ByBit.Net/Objects/Models/V5/BybitPosition.cs +++ b/ByBit.Net/Objects/Models/V5/BybitPosition.cs @@ -11,6 +11,12 @@ namespace Bybit.Net.Objects.Models.V5 /// public class BybitPosition { + /// + /// Category + /// + [JsonProperty("category")] + [JsonConverter(typeof(EnumConverter))] + public Category Category { get; set; } /// /// Position mode /// diff --git a/ByBit.Net/Objects/Models/V5/BybitPositionUpdate.cs b/ByBit.Net/Objects/Models/V5/BybitPositionUpdate.cs index 32b7c0f7..0e9e4fb0 100644 --- a/ByBit.Net/Objects/Models/V5/BybitPositionUpdate.cs +++ b/ByBit.Net/Objects/Models/V5/BybitPositionUpdate.cs @@ -9,10 +9,5 @@ namespace Bybit.Net.Objects.Models.V5 /// public class BybitPositionUpdate : BybitPosition { - /// - /// Category - /// - [JsonConverter(typeof(EnumConverter))] - public Category Category { get; set; } } } diff --git a/ByBit.Net/Objects/Models/V5/BybitUserTrade.cs b/ByBit.Net/Objects/Models/V5/BybitUserTrade.cs index 74d456b7..69264623 100644 --- a/ByBit.Net/Objects/Models/V5/BybitUserTrade.cs +++ b/ByBit.Net/Objects/Models/V5/BybitUserTrade.cs @@ -94,6 +94,10 @@ public class BybitUserTrade /// public bool IsMaker { get; set; } /// + /// Whether to borrow. Unified spot only + /// + public bool? IsLeverage { get; set; } + /// /// Spot trading fee asset /// [JsonProperty("feeCurrency")] diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/AddOrReduceMargin.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/AddOrReduceMargin.txt new file mode 100644 index 00000000..21d31dad --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/AddOrReduceMargin.txt @@ -0,0 +1,34 @@ +POST +/v5/position/add-margin +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "inverse", + "symbol": "ETHUSD", + "positionIdx": 0, + "riskId": 11, + "riskLimitValue": "500", + "size": "200", + "positionValue": "0.11033265", + "avgPrice": "1812.70004844", + "liqPrice": "1550.80", + "bustPrice": "1544.20", + "markPrice": "1812.90", + "leverage": "12", + "autoAddMargin": 0, + "positionStatus": "Normal", + "positionIM": "0.01926611", + "positionMM": "0", + "unrealisedPnl": "0.00001217", + "cumRealisedPnl": "-0.04618929", + "stopLoss": "0.00", + "takeProfit": "0.00", + "trailingStop": "0.00", + "createdTime": "1672737740039", + "updatedTime": "1684234363788" + }, + "retExtInfo": {}, + "time": 1684234363789 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/CancelWithdrawal.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/CancelWithdrawal.txt new file mode 100644 index 00000000..80e46c31 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/CancelWithdrawal.txt @@ -0,0 +1,12 @@ +POST +/v5/asset/withdraw/cancel +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "status": 1 + }, + "retExtInfo": {}, + "time": 1672197228408 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/DeleteApiKey.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/DeleteApiKey.txt new file mode 100644 index 00000000..fe2bb2e0 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/DeleteApiKey.txt @@ -0,0 +1,10 @@ +POST +/v5/user/delete-api +true +{ + "retCode": 0, + "retMsg": "", + "result": {}, + "retExtInfo": {}, + "time": 1676431577675 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/EditApiKey.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/EditApiKey.txt new file mode 100644 index 00000000..0b275c2d --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/EditApiKey.txt @@ -0,0 +1,48 @@ +POST +/v5/user/update-api +true +{ + "retCode": 0, + "retMsg": "", + "result": { + "id": "13770661", + "note": "xxxxx", + "apiKey": "xxxxx", + "readOnly": 0, + "secret": "", + "permissions": { + "ContractTrade": [ + "Order", + "Position" + ], + "Spot": [ + "SpotTrade" + ], + "Wallet": [ + "AccountTransfer", + "SubMemberTransfer" + ], + "Options": [ + "OptionsTrade" + ], + "Derivatives": [ + "DerivativesTrade" + ], + "CopyTrading": [ + "CopyTrading" + ], + "BlockTrade": [], + "Exchange": [ + "ExchangeHistory" + ], + "NFT": [ + "NFTQueryProductList" + ] + }, + "ips": [ + "*" + ] + }, + "retExtInfo": {}, + "time": 1676431265427 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetAccountTypes.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetAccountTypes.txt new file mode 100644 index 00000000..4a34f949 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetAccountTypes.txt @@ -0,0 +1,22 @@ +GET +/v5/user/get-member-type +true +{ + "retCode": 0, + "retMsg": "", + "result": { + "accounts": [ + { + "uid": "533285", + "accountType": [ + "SPOT", + "UNIFIED", + "FUND", + "CONTRACT" + ] + } + ] + }, + "retExtInfo": {}, + "time": 1686884974151 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetApiKeyInfo.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetApiKeyInfo.txt new file mode 100644 index 00000000..4d4d6ff0 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetApiKeyInfo.txt @@ -0,0 +1,57 @@ +GET +/v5/user/query-api +true +{ + "retCode": 0, + "retMsg": "", + "result": { + "id": "13770661", + "note": "readwrite api key", + "apiKey": "XXXXXX", + "readOnly": 0, + "secret": "", + "permissions": { + "ContractTrade": [ + "Order", + "Position" + ], + "Spot": [ + "SpotTrade" + ], + "Wallet": [ + "AccountTransfer", + "SubMemberTransfer" + ], + "Options": [ + "OptionsTrade" + ], + "Derivatives": [], + "CopyTrading": [], + "BlockTrade": [], + "Exchange": [], + "NFT": [], + "Affiliate": [] + }, + "ips": [ + "*" + ], + "type": 1, + "deadlineDay": 66, + "expiredAt": "2023-12-22T07:20:25Z", + "createdAt": "2022-10-16T02:24:40Z", + "unified": 0, + "uta": 0, + "userID": 24617703, + "inviterID": 0, + "vipLevel": "No VIP", + "mktMakerLevel": "0", + "affiliateID": 0, + "rsaPublicKey": "", + "isMaster": true, + "parentUid": "0", + "kycLevel": "LEVEL_DEFAULT", + "kycRegion": "" + }, + "retExtInfo": {}, + "time": 1697525990798 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetAssetGreeks.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetAssetGreeks.txt new file mode 100644 index 00000000..18245c24 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetAssetGreeks.txt @@ -0,0 +1,20 @@ +GET +/v5/asset/coin-greeks +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "baseCoin": "BTC", + "totalDelta": "0.00004001", + "totalGamma": "-0.00000009", + "totalVega": "-0.00039689", + "totalTheta": "0.01243824" + } + ] + }, + "retExtInfo": {}, + "time": 1672287887942 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetAssetInfo.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetAssetInfo.txt new file mode 100644 index 00000000..4fb615e0 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetAssetInfo.txt @@ -0,0 +1,44 @@ +GET +/v5/asset/coin/query-info +true +{ + "retCode": 0, + "retMsg": "", + "result": { + "rows": [ + { + "name": "ETH", + "coin": "ETH", + "remainAmount": "1020000", + "chains": [ + { + "chainType": "ETH", + "confirmation": "10000", + "withdrawFee": "0.005", + "depositMin": "0.01", + "withdrawMin": "0.02", + "chain": "ETH", + "chainDeposit": "1", + "chainWithdraw": "1", + "minAccuracy": "8", + "withdrawPercentageFee": "0.022" + }, + { + "chainType": "Arbitrum One", + "confirmation": "10", + "withdrawFee": "0.01", + "depositMin": "0.001", + "withdrawMin": "0.1", + "chain": "ARBI", + "chainDeposit": "1", + "chainWithdraw": "1", + "minAccuracy": "8", + "withdrawPercentageFee": "0" + } + ] + } + ] + }, + "retExtInfo": {}, + "time": 1677478088215 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetBalances.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBalances.txt new file mode 100644 index 00000000..4419ea31 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBalances.txt @@ -0,0 +1,48 @@ +GET +/v5/account/wallet-balance +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "totalEquity": "3.31216591", + "accountIMRate": "0", + "totalMarginBalance": "3.00326056", + "totalInitialMargin": "0", + "accountType": "UNIFIED", + "totalAvailableBalance": "3.00326056", + "accountMMRate": "0", + "totalPerpUPL": "0", + "totalWalletBalance": "3.00326056", + "accountLTV": "0", + "totalMaintenanceMargin": "0", + "coin": [ + { + "availableToBorrow": "3", + "bonus": "0", + "accruedInterest": "0", + "availableToWithdraw": "0", + "totalOrderIM": "0", + "equity": "0", + "totalPositionMM": "0", + "usdValue": "0", + "spotHedgingQty": "0.01592413", + "unrealisedPnl": "0", + "collateralSwitch": true, + "borrowAmount": "0.0", + "totalPositionIM": "0", + "walletBalance": "0", + "cumRealisedPnl": "0", + "locked": "0", + "marginCollateral": true, + "coin": "BTC" + } + ] + } + ] + }, + "retExtInfo": {}, + "time": 1690872862481 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetBorrowHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBorrowHistory.txt new file mode 100644 index 00000000..ccc5961a --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBorrowHistory.txt @@ -0,0 +1,25 @@ +GET +/v5/account/borrow-history +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "nextPageCursor": "2671153%3A1%2C2671153%3A1", + "list": [ + { + "borrowAmount": "1.06333265702840778", + "costExemption": "0", + "freeBorrowedAmount": "0", + "createdTime": 1697439900204, + "InterestBearingBorrowSize": "1.06333265702840778", + "currency": "BTC", + "unrealisedLoss": "0", + "hourlyBorrowRate": "0.000001216904", + "borrowCost": "0.00000129" + } + ] + }, + "retExtInfo": {}, + "time": 1697442206478 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetBrokerAccountInfo.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBrokerAccountInfo.txt new file mode 100644 index 00000000..bed3d97b --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBrokerAccountInfo.txt @@ -0,0 +1,22 @@ +GET +/v5/broker/account-info +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "subAcctQty": "2", + "maxSubAcctQty": "20", + "baseFeeRebateRate": { + "spot": "10.0%", + "derivatives": "10.0%" + }, + "markupFeeRebateRate": { + "spot": "6.00%", + "derivatives": "9.00%" + }, + "ts": "1701395633402" + }, + "retExtInfo": {}, + "time": 1701395633403 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetBrokerEarnings.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBrokerEarnings.txt new file mode 100644 index 00000000..0fa7ee3e --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetBrokerEarnings.txt @@ -0,0 +1,52 @@ +GET +/v5/broker/earnings-info +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "totalEarningCat": { + "spot": [], + "derivatives": [ + { + "coin": "USDT", + "earning": "0.00027844" + } + ], + "options": [], + "total": [ + { + "coin": "USDT", + "earning": "0.00027844" + } + ] + }, + "details": [ + { + "userId": "117894077", + "bizType": "DERIVATIVES", + "symbol": "DOGEUSDT", + "coin": "USDT", + "earning": "0.00016166", + "markupEarning": "0.000032332", + "baseFeeEarning": "0.000129328", + "orderId": "ec2132f2-a7e0-4a0c-9219-9f3cbcd8e878", + "execTime": "1701275846033" + }, + { + "userId": "117894077", + "bizType": "DERIVATIVES", + "symbol": "TRXUSDT", + "coin": "USDT", + "earning": "0.00011678", + "markupEarning": "0.000023356", + "baseFeeEarning": "0.000093424", + "orderId": "28b29c2b-ba14-450e-9ce7-3cee0c1fa6da", + "execTime": "1701245285017" + } + ], + "nextPageCursor": "" + }, + "retExtInfo": {}, + "time": 1701398193964 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetCollateralInfo.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetCollateralInfo.txt new file mode 100644 index 00000000..10088b65 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetCollateralInfo.txt @@ -0,0 +1,28 @@ +GET +/v5/account/collateral-info +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "availableToBorrow": "3", + "freeBorrowingAmount": "", + "freeBorrowAmount": "0", + "maxBorrowingAmount": "3", + "hourlyBorrowRate": "0.00000147", + "borrowUsageRate": "0", + "collateralSwitch": true, + "borrowAmount": "0", + "borrowable": true, + "currency": "BTC", + "marginCollateral": true, + "freeBorrowingLimit": "0", + "collateralRatio": "0.95" + } + ] + }, + "retExtInfo": {}, + "time": 1691565901952 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetDelayedWithdrawQuantity.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetDelayedWithdrawQuantity.txt new file mode 100644 index 00000000..4afa32a1 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetDelayedWithdrawQuantity.txt @@ -0,0 +1,24 @@ +GET +/v5/asset/withdraw/withdrawable-amount +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "limitAmountUsd": "52853.5551", + "withdrawableAmount": { + "FUND": { + "coin": "USDT", + "withdrawableAmount": "11135.0596", + "availableBalance": "11135.0596" + }, + "SPOT": { + "coin": "USDT", + "withdrawableAmount": "0", + "availableBalance": "0" + } + } + }, + "retExtInfo": {}, + "time": 1677565632151 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetFeeRate.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetFeeRate.txt new file mode 100644 index 00000000..11233ad3 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetFeeRate.txt @@ -0,0 +1,18 @@ +GET +/v5/account/fee-rate +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "symbol": "ETHUSDT", + "takerFeeRate": "0.0006", + "makerFeeRate": "0.0001" + } + ] + }, + "retExtInfo": {}, + "time": 1676360412576 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetMarginAccountInfo.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetMarginAccountInfo.txt new file mode 100644 index 00000000..a2bc592d --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetMarginAccountInfo.txt @@ -0,0 +1,17 @@ +GET +/v5/account/info +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "marginMode": "REGULAR_MARGIN", + "updatedTime": "1697078946000", + "unifiedMarginStatus": 4, + "dcpStatus": "OFF", + "timeWindow": 10, + "smpGroup": 0, + "isMasterTrader": false, + "spotHedgingStatus": "OFF" + } +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetSpotMarginData.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetSpotMarginData.txt new file mode 100644 index 00000000..fe011762 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetSpotMarginData.txt @@ -0,0 +1,25 @@ +GET +/v5/spot-margin-trade/data +false +{ + "retCode": 0, + "retMsg": "success", + "result": { + "vipCoinList": [ + { + "list": [ + { + "borrowable": true, + "collateralRatio": "0.95", + "currency": "BTC", + "hourlyBorrowRate": "0.0000015021220000", + "liquidationOrder": "11", + "marginCollateral": true, + "maxBorrowingAmount": "3" + } + ], + "vipLevel": "No VIP" + } + ] + } +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetSpotMarginStatusAndLeverage.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetSpotMarginStatusAndLeverage.txt new file mode 100644 index 00000000..046f2fb1 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetSpotMarginStatusAndLeverage.txt @@ -0,0 +1,14 @@ +GET +/v5/spot-margin-trade/state +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "spotLeverage": "10", + "spotMarginMode": "1", + "effectiveLeverage": "1" + }, + "retExtInfo": {}, + "time": 1692696841231 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetTransactionHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetTransactionHistory.txt new file mode 100644 index 00000000..3c228e06 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetTransactionHistory.txt @@ -0,0 +1,80 @@ +GET +/v5/account/transaction-log +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "nextPageCursor": "21963%3A1%2C14954%3A1", + "list": [ + { + "id": "592324_XRPUSDT_161440249321", + "symbol": "XRPUSDT", + "side": "Buy", + "funding": "-0.003676", + "orderLinkId": "", + "orderId": "1672128000-8-592324-1-2", + "fee": "0.00000000", + "change": "-0.003676", + "cashFlow": "0", + "transactionTime": "1672128000000", + "type": "SETTLEMENT", + "feeRate": "0.0001", + "bonusChange": "", + "size": "100", + "qty": "100", + "cashBalance": "5086.55825002", + "currency": "USDT", + "category": "linear", + "tradePrice": "0.3676", + "tradeId": "534c0003-4bf7-486f-aa02-78cee36825e4" + }, + { + "id": "592324_XRPUSDT_161440249321", + "symbol": "XRPUSDT", + "side": "Buy", + "funding": "", + "orderLinkId": "linear-order", + "orderId": "592b7e41-78fd-42e2-9aa3-91e1835ef3e1", + "fee": "0.01908720", + "change": "-0.0190872", + "cashFlow": "0", + "transactionTime": "1672121182224", + "type": "TRADE", + "feeRate": "0.0006", + "bonusChange": "-0.1430544", + "size": "100", + "qty": "88", + "cashBalance": "5086.56192602", + "currency": "USDT", + "category": "linear", + "tradePrice": "0.3615", + "tradeId": "5184f079-88ec-54c7-8774-5173cafd2b4e" + }, + { + "id": "592324_XRPUSDT_161407743011", + "symbol": "XRPUSDT", + "side": "Buy", + "funding": "", + "orderLinkId": "linear-order", + "orderId": "592b7e41-78fd-42e2-9aa3-91e1835ef3e1", + "fee": "0.00260280", + "change": "-0.0026028", + "cashFlow": "0", + "transactionTime": "1672121182224", + "type": "TRADE", + "feeRate": "0.0006", + "bonusChange": "", + "size": "12", + "qty": "12", + "cashBalance": "5086.58101322", + "currency": "USDT", + "category": "linear", + "tradePrice": "0.3615", + "tradeId": "8569c10f-5061-5891-81c4-a54929847eb3" + } + ] + }, + "retExtInfo": {}, + "time": 1672132481405 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/GetWithdrawals.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/GetWithdrawals.txt new file mode 100644 index 00000000..c2c1fbd2 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/GetWithdrawals.txt @@ -0,0 +1,42 @@ +GET +/v5/asset/withdraw/query-record +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "rows": [ + { + "coin": "USDT", + "chain": "ETH", + "amount": "77", + "txID": "", + "status": "SecurityCheck", + "toAddress": "0x99ced129603abc771c0dabe935c326ff6c86645d", + "tag": "", + "withdrawFee": "10", + "createTime": "1670922217000", + "updateTime": "1670922217000", + "withdrawId": "9976", + "withdrawType": 0 + }, + { + "coin": "USDT", + "chain": "internalAddressChain", + "amount": "20.1234", + "txID": "", + "status": "success", + "toAddress": "999805", + "tag": "", + "withdrawFee": "0", + "createTime": "1698889833000", + "updateTime": "1698889846000", + "withdrawId": "13310", + "withdrawType": 1 + } + ], + "nextPageCursor": "eyJtaW5JRCI6OTgwMSwibWF4SUQiOjk5NzZ9" + }, + "retExtInfo": {}, + "time": 1672194949928 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/RepayLiabilities.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/RepayLiabilities.txt new file mode 100644 index 00000000..3068cd43 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/RepayLiabilities.txt @@ -0,0 +1,21 @@ +POST +/v5/account/quick-repayment +true +{ + "retCode": 0, + "retMsg": "SUCCESS", + "result": { + "list": [ + { + "coin": "BTC", + "repaymentQty": "0.10549670" + }, + { + "coin": "ETH", + "repaymentQty": "2.27768114" + } + ] + }, + "retExtInfo": {}, + "time": 1701848610941 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetAutoAddMargin.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetAutoAddMargin.txt new file mode 100644 index 00000000..96d9b8b0 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetAutoAddMargin.txt @@ -0,0 +1,10 @@ +POST +/v5/position/set-auto-add-margin +true +{ + "retCode": 0, + "retMsg": "OK", + "result": {}, + "retExtInfo": {}, + "time": 1675255135069 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetCollateralAsset.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetCollateralAsset.txt new file mode 100644 index 00000000..826cfcea --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetCollateralAsset.txt @@ -0,0 +1,10 @@ +POST +/v5/account/set-collateral-switch +true +{ + "retCode": 0, + "retMsg": "SUCCESS", + "result": {}, + "retExtInfo": {}, + "time": 1690515818656 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetLeverage.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetLeverage.txt new file mode 100644 index 00000000..56d5a3aa --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetLeverage.txt @@ -0,0 +1,10 @@ +POST +/v5/position/set-leverage +true +{ + "retCode": 0, + "retMsg": "OK", + "result": {}, + "retExtInfo": {}, + "time": 1672281607343 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetMarginMode.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetMarginMode.txt new file mode 100644 index 00000000..4668eaea --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetMarginMode.txt @@ -0,0 +1,15 @@ +POST +/v5/account/set-margin-mode +true +{ + "retCode": 3400045, + "retMsg": "Set margin mode failed", + "result": { + "reasons": [ + { + "reasonCode": "3400000", + "reasonMsg": "Equity needs to be equal to or greater than 1000 USDC" + } + ] + } +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetMultipleCollateralAssets.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetMultipleCollateralAssets.txt new file mode 100644 index 00000000..b0838839 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetMultipleCollateralAssets.txt @@ -0,0 +1,29 @@ +POST +/v5/account/set-collateral-switch-batch +true +{ + "retCode": 0, + "retMsg": "SUCCESS", + "result": { + "list": [ + { + "coin": "MATIC", + "collateralSwitch": "OFF" + }, + { + "coin": "BTC", + "collateralSwitch": "OFF" + }, + { + "coin": "ETH", + "collateralSwitch": "OFF" + }, + { + "coin": "SOL", + "collateralSwitch": "OFF" + } + ] + }, + "retExtInfo": {}, + "time": 1704782042913 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetRiskLimit.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetRiskLimit.txt new file mode 100644 index 00000000..3354369a --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetRiskLimit.txt @@ -0,0 +1,14 @@ +POST +/v5/position/set-risk-limit +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "riskId": 4, + "riskLimitValue": "8000000", + "category": "linear" + }, + "retExtInfo": {}, + "time": 1672282270571 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotHedgingMode.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotHedgingMode.txt new file mode 100644 index 00000000..b2ff0def --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotHedgingMode.txt @@ -0,0 +1,7 @@ +POST +/v5/account/set-hedging-mode +true +{ + "retCode": 0, + "retMsg": "SUCCESS" +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotMarginLeverage.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotMarginLeverage.txt new file mode 100644 index 00000000..feecb831 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotMarginLeverage.txt @@ -0,0 +1,10 @@ +POST +/v5/spot-margin-trade/set-leverage +true +{ + "retCode": 0, + "retMsg": "OK", + "result": {}, + "retExtInfo": {}, + "time": 1672710944282 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotMarginTradeMode.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotMarginTradeMode.txt new file mode 100644 index 00000000..4247b829 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetSpotMarginTradeMode.txt @@ -0,0 +1,12 @@ +POST +/v5/spot-margin-trade/switch-mode +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "spotMarginMode": "0" + }, + "retExtInfo": {}, + "time": 1672297795542 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SetTakeProfitStopLossMode.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SetTakeProfitStopLossMode.txt new file mode 100644 index 00000000..bfef8f70 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SetTakeProfitStopLossMode.txt @@ -0,0 +1,12 @@ +POST +/v5/position/set-tpsl-mode +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "tpSlMode": "Full" + }, + "retExtInfo": {}, + "time": 1672279322666 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SwitchCrossIsolatedMargin.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SwitchCrossIsolatedMargin.txt new file mode 100644 index 00000000..7a83e5c6 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SwitchCrossIsolatedMargin.txt @@ -0,0 +1,10 @@ +POST +/v5/position/switch-isolated +true +{ + "retCode": 0, + "retMsg": "OK", + "result": {}, + "retExtInfo": {}, + "time": 1675248433635 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/SwitchPositionMode.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/SwitchPositionMode.txt new file mode 100644 index 00000000..61b0911e --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/SwitchPositionMode.txt @@ -0,0 +1,10 @@ +POST +/v5/position/switch-mode +true +{ + "retCode": 0, + "retMsg": "OK", + "result": {}, + "retExtInfo": {}, + "time": 1675249072814 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Account/Withdraw.txt b/Bybit.UnitTests/Endpoints/V5Api/Account/Withdraw.txt new file mode 100644 index 00000000..413a0740 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Account/Withdraw.txt @@ -0,0 +1,12 @@ +POST +/v5/asset/withdraw/create +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "id": "10195" + }, + "retExtInfo": {}, + "time": 1672196571239 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetAnnouncements.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetAnnouncements.txt new file mode 100644 index 00000000..a726f774 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetAnnouncements.txt @@ -0,0 +1,30 @@ +GET +/v5/announcements/index +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "total": 735, + "list": [ + { + "title": "New Listing: Arbitrum (ARB) — Deposit, Trade and Stake ARB to Share a 400,000 USDT Prize Pool!", + "description": "Bybit is excited to announce the listing of ARB on our trading platform!", + "type": { + "title": "New Listings", + "key": "new_crypto" + }, + "tags": [ + "Spot", + "Spot Listings" + ], + "url": "https://announcements.bybit.com/en-US/article/new-listing-arbitrum-arb-deposit-trade-and-stake-arb-to-share-a-400-000-usdt-prize-pool--bltf662314c211a8616/", + "dateTimestamp": 1679045608000, + "startDateTimestamp": 1679045608000, + "endDateTimestamp": 1679045608000 + } + ] + }, + "retExtInfo": {}, + "time": 1679415136117 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetDeliveryPrice.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetDeliveryPrice.txt new file mode 100644 index 00000000..8258bfb1 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetDeliveryPrice.txt @@ -0,0 +1,20 @@ +GET +/v5/market/delivery-price +false +{ + "retCode": 0, + "retMsg": "success", + "result": { + "category": "option", + "nextPageCursor": "", + "list": [ + { + "symbol": "ETH-26DEC22-1400-C", + "deliveryPrice": "1220.728594450", + "deliveryTime": "1672041600000" + } + ] + }, + "retExtInfo": {}, + "time": 1672055336993 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetFundingRateHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetFundingRateHistory.txt new file mode 100644 index 00000000..6cd645f4 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetFundingRateHistory.txt @@ -0,0 +1,19 @@ +GET +/v5/market/funding/history +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "linear", + "list": [ + { + "symbol": "ETHPERP", + "fundingRate": "0.0001", + "fundingRateTimestamp": "1672041600000" + } + ] + }, + "retExtInfo": {}, + "time": 1672051897447 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetHistoricalVolatility.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetHistoricalVolatility.txt new file mode 100644 index 00000000..e386afbc --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetHistoricalVolatility.txt @@ -0,0 +1,15 @@ +GET +/v5/market/historical-volatility +false +{ + "retCode": 0, + "retMsg": "SUCCESS", + "category": "option", + "result": [ + { + "period": 30, + "value": "0.45024716", + "time": "1672052400000" + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetIndexPriceKlines.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetIndexPriceKlines.txt new file mode 100644 index 00000000..da5367f8 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetIndexPriceKlines.txt @@ -0,0 +1,29 @@ +GET +/v5/market/index-price-kline +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "symbol": "BTCUSDZ22", + "category": "inverse", + "list": [ + [ + "1670608800000", + "17167.00", + "17167.00", + "17161.90", + "17163.07" + ], + [ + "1670608740000", + "17166.54", + "17167.69", + "17165.42", + "17167.00" + ] + ] + }, + "retExtInfo": {}, + "time": 1672026471128 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetInsurance.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetInsurance.txt new file mode 100644 index 00000000..2ece7bf1 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetInsurance.txt @@ -0,0 +1,44 @@ +GET +/v5/market/insurance +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "updatedTime": "1714003200000", + "list": [ + { + "coin": "USDT", + "symbols": "MERLUSDT,10000000AIDOGEUSDT,ZEUSUSDT", + "balance": "902178.57602476", + "value": "901898.0963091522" + }, + { + "coin": "USDT", + "symbols": "SOLUSDT,OMNIUSDT,ALGOUSDT", + "balance": "14454.51626125", + "value": "14449.515598975464" + }, + { + "coin": "USDT", + "symbols": "XLMUSDT,WUSDT", + "balance": "23.45018235", + "value": "22.992864174376344" + }, + { + "coin": "USDT", + "symbols": "AGIUSDT,WIFUSDT", + "balance": "10002", + "value": "9998.896846613574" + }, + { + "coin": "USDT", + "symbols": "", + "balance": "10148045273.618073", + "value": "10144896808.587431" + } + ] + }, + "retExtInfo": {}, + "time": 1714028451228 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetKlines.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetKlines.txt new file mode 100644 index 00000000..e42a976b --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetKlines.txt @@ -0,0 +1,42 @@ +GET +/v5/market/kline +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "symbol": "BTCUSD", + "category": "inverse", + "list": [ + [ + "1670608800000", + "17071", + "17073", + "17027", + "17055.5", + "268611", + "15.74462667" + ], + [ + "1670605200000", + "17071.5", + "17071.5", + "17061", + "17071", + "4177", + "0.24469757" + ], + [ + "1670601600000", + "17086.5", + "17088", + "16978", + "17071.5", + "6356", + "0.37288112" + ] + ] + }, + "retExtInfo": {}, + "time": 1672025956592 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLeverageTokenMarket.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLeverageTokenMarket.txt new file mode 100644 index 00000000..d1d72f83 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLeverageTokenMarket.txt @@ -0,0 +1,17 @@ +GET +/v5/spot-lever-token/reference +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "basket": "-132.460000082171973364", + "circulation": "30097.901900052619091704", + "leverage": "-2.666924651755770729", + "ltCoin": "BTC3S", + "nav": "27.692082719770373048", + "navTime": "1672991679858" + }, + "retExtInfo": {}, + "time": 1672991679937 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLeverageTokens.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLeverageTokens.txt new file mode 100644 index 00000000..2eeb83e0 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLeverageTokens.txt @@ -0,0 +1,33 @@ +GET +/v5/spot-lever-token/info +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "fundFee": "299.70622821", + "fundFeeTime": "1672992000000", + "ltCoin": "BTC3L", + "ltName": "3X Long", + "ltStatus": "1", + "manageFeeRate": "0.00005", + "manageFeeTime": "1673053200000", + "maxPurchase": "10000", + "maxPurchaseDaily": "200000", + "maxRedeem": "14434", + "maxRedeemDaily": "2100000", + "minPurchase": "100", + "minRedeem": "144", + "netValue": "0.376482201140738147", + "purchaseFeeRate": "0.0005", + "redeemFeeRate": "0.0005", + "total": "5000000", + "value": "49464463114.022994974075443169" + } + ] + }, + "retExtInfo": {}, + "time": 1672991427073 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLinearInverseSymbols.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLinearInverseSymbols.txt new file mode 100644 index 00000000..9f0843a6 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLinearInverseSymbols.txt @@ -0,0 +1,50 @@ +GET +/v5/market/instruments-info +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "linear", + "list": [ + { + "symbol": "BTCUSDT", + "contractType": "LinearPerpetual", + "status": "Trading", + "baseCoin": "BTC", + "quoteCoin": "USDT", + "launchTime": "1585526400000", + "deliveryTime": "0", + "deliveryFeeRate": "", + "priceScale": "2", + "leverageFilter": { + "minLeverage": "1", + "maxLeverage": "100.00", + "leverageStep": "0.01" + }, + "priceFilter": { + "minPrice": "0.10", + "maxPrice": "199999.80", + "tickSize": "0.10" + }, + "lotSizeFilter": { + "maxOrderQty": "100.000", + "maxMktOrderQty": "100.000", + "minOrderQty": "0.001", + "qtyStep": "0.001", + "postOnlyMaxOrderQty": "1000.000", + "minNotionalValue": "5" + }, + "unifiedMarginTrade": true, + "fundingInterval": 480, + "settleCoin": "USDT", + "copyTrading": "both", + "upperFundingRate": "0.00375", + "lowerFundingRate": "-0.00375" + } + ], + "nextPageCursor": "" + }, + "retExtInfo": {}, + "time": 1707186451514 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLinearInverseTickers.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLinearInverseTickers.txt new file mode 100644 index 00000000..2166132b --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLinearInverseTickers.txt @@ -0,0 +1,40 @@ +GET +/v5/market/tickers +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "inverse", + "list": [ + { + "symbol": "BTCUSD", + "lastPrice": "16597.00", + "indexPrice": "16598.54", + "markPrice": "16596.00", + "prevPrice24h": "16464.50", + "price24hPcnt": "0.008047", + "highPrice24h": "30912.50", + "lowPrice24h": "15700.00", + "prevPrice1h": "16595.50", + "openInterest": "373504107", + "openInterestValue": "22505.67", + "turnover24h": "2352.94950046", + "volume24h": "49337318", + "fundingRate": "-0.001034", + "nextFundingTime": "1672387200000", + "predictedDeliveryPrice": "", + "basisRate": "", + "deliveryFeeRate": "", + "deliveryTime": "0", + "ask1Size": "1", + "bid1Price": "16596.00", + "ask1Price": "16597.50", + "bid1Size": "1", + "basis": "" + } + ] + }, + "retExtInfo": {}, + "time": 1672376496682 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLongShortRatio.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLongShortRatio.txt new file mode 100644 index 00000000..81aae22f --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetLongShortRatio.txt @@ -0,0 +1,19 @@ +GET +/v5/market/account-ratio +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "symbol": "BTCUSDT", + "buyRatio": "0.5777", + "sellRatio": "0.4223", + "timestamp": "1695772800000" + } + ] + }, + "retExtInfo": {}, + "time": 1695785131028 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetMarkPriceKlines.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetMarkPriceKlines.txt new file mode 100644 index 00000000..71738f0a --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetMarkPriceKlines.txt @@ -0,0 +1,22 @@ +GET +/v5/market/mark-price-kline +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "symbol": "BTCUSDT", + "category": "linear", + "list": [ + [ + "1670608800000", + "17164.16", + "17164.16", + "17121.5", + "17131.64" + ] + ] + }, + "retExtInfo": {}, + "time": 1672026361839 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOpenInterest.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOpenInterest.txt new file mode 100644 index 00000000..15da2e3b --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOpenInterest.txt @@ -0,0 +1,24 @@ +GET +/v5/market/open-interest +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "symbol": "BTCUSD", + "category": "inverse", + "list": [ + { + "openInterest": "461134384.00000000", + "timestamp": "1669571400000" + }, + { + "openInterest": "461134292.00000000", + "timestamp": "1669571100000" + } + ], + "nextPageCursor": "" + }, + "retExtInfo": {}, + "time": 1672053548579 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOptionSymbols.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOptionSymbols.txt new file mode 100644 index 00000000..5f482de4 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOptionSymbols.txt @@ -0,0 +1,36 @@ +GET +/v5/market/instruments-info +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "option", + "nextPageCursor": "", + "list": [ + { + "symbol": "ETH-3JAN23-1250-P", + "status": "Trading", + "baseCoin": "ETH", + "quoteCoin": "USD", + "settleCoin": "USDC", + "optionsType": "Put", + "launchTime": "1672560000000", + "deliveryTime": "1672732800000", + "deliveryFeeRate": "0.00015", + "priceFilter": { + "minPrice": "0.1", + "maxPrice": "10000000", + "tickSize": "0.1" + }, + "lotSizeFilter": { + "maxOrderQty": "1500", + "minOrderQty": "0.1", + "qtyStep": "0.1" + } + } + ] + }, + "retExtInfo": {}, + "time": 1672712537130 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOptionTickers.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOptionTickers.txt new file mode 100644 index 00000000..9cda2568 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOptionTickers.txt @@ -0,0 +1,41 @@ +GET +/v5/market/tickers +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "option", + "list": [ + { + "symbol": "BTC-30DEC22-18000-C", + "bid1Price": "0", + "bid1Size": "0", + "bid1Iv": "0", + "ask1Price": "435", + "ask1Size": "0.66", + "ask1Iv": "5", + "lastPrice": "435", + "highPrice24h": "435", + "lowPrice24h": "165", + "markPrice": "0.00000009", + "indexPrice": "16600.55", + "markIv": "0.7567", + "underlyingPrice": "16590.42", + "openInterest": "6.3", + "turnover24h": "2482.73", + "volume24h": "0.15", + "totalVolume": "99", + "totalTurnover": "1967653", + "delta": "0.00000001", + "gamma": "0.00000001", + "vega": "0.00000004", + "theta": "-0.00000152", + "predictedDeliveryPrice": "0", + "change24h": "86" + } + ] + }, + "retExtInfo": {}, + "time": 1672376592395 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOrderbook.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOrderbook.txt new file mode 100644 index 00000000..254381f5 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetOrderbook.txt @@ -0,0 +1,27 @@ +GET +/v5/market/orderbook +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "s": "BTCUSDT", + "b": [ + [ + "62710.2", + "5.52" + ] + ], + "a": [ + [ + "62710.3", + "0.01" + ] + ], + "ts": 1709199771584, + "u": 243781, + "seq": 3887177875 + }, + "retExtInfo": {}, + "time": 1709199771643 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetPremiumIndexPriceKlines.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetPremiumIndexPriceKlines.txt new file mode 100644 index 00000000..58c949a4 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetPremiumIndexPriceKlines.txt @@ -0,0 +1,29 @@ +GET +/v5/market/premium-index-price-kline +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "symbol": "BTCUSDT", + "category": "linear", + "list": [ + [ + "1652486400000", + "-0.000587", + "-0.000344", + "-0.000480", + "-0.000344" + ], + [ + "1652400000000", + "-0.000989", + "-0.000561", + "-0.000587", + "-0.000587" + ] + ] + }, + "retExtInfo": {}, + "time": 1672765216291 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetRiskLimit.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetRiskLimit.txt new file mode 100644 index 00000000..df6ee09a --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetRiskLimit.txt @@ -0,0 +1,23 @@ +GET +/v5/market/risk-limit +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "inverse", + "list": [ + { + "id": 1, + "symbol": "BTCUSD", + "riskLimitValue": "150", + "maintenanceMargin": "0.5", + "initialMargin": "1", + "isLowestRisk": 1, + "maxLeverage": "100.00" + } + ] + }, + "retExtInfo": {}, + "time": 1672054488010 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetSpotSymbols.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetSpotSymbols.txt new file mode 100644 index 00000000..c60d0c15 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetSpotSymbols.txt @@ -0,0 +1,37 @@ +GET +/v5/market/instruments-info +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "spot", + "list": [ + { + "symbol": "BTCUSDT", + "baseCoin": "BTC", + "quoteCoin": "USDT", + "innovation": "0", + "status": "Trading", + "marginTrading": "both", + "lotSizeFilter": { + "basePrecision": "0.000001", + "quotePrecision": "0.00000001", + "minOrderQty": "0.000048", + "maxOrderQty": "71.73956243", + "minOrderAmt": "1", + "maxOrderAmt": "2000000" + }, + "priceFilter": { + "tickSize": "0.01" + }, + "riskParameters": { + "limitParameter": "0.05", + "marketParameter": "0.05" + } + } + ] + }, + "retExtInfo": {}, + "time": 1672712468011 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetSpotTickers.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetSpotTickers.txt new file mode 100644 index 00000000..7a7b409c --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetSpotTickers.txt @@ -0,0 +1,29 @@ +GET +/v5/market/tickers +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "spot", + "list": [ + { + "symbol": "BTCUSDT", + "bid1Price": "20517.96", + "bid1Size": "2", + "ask1Price": "20527.77", + "ask1Size": "1.862172", + "lastPrice": "20533.13", + "prevPrice24h": "20393.48", + "price24hPcnt": "0.0068", + "highPrice24h": "21128.12", + "lowPrice24h": "20318.89", + "turnover24h": "243765620.65899866", + "volume24h": "11801.27771", + "usdIndexPrice": "20784.12009279" + } + ] + }, + "retExtInfo": {}, + "time": 1673859087947 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetTradeHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetTradeHistory.txt new file mode 100644 index 00000000..5439ae97 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/ExchangeData/GetTradeHistory.txt @@ -0,0 +1,23 @@ +GET +/v5/market/recent-trade +false +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "category": "spot", + "list": [ + { + "execId": "2100000000007764263", + "symbol": "BTCUSDT", + "price": "16618.49", + "size": "0.00012", + "side": "Buy", + "time": "1672052955758", + "isBlockTrade": false + } + ] + }, + "retExtInfo": {}, + "time": 1672053054358 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelAllOrder.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelAllOrder.txt new file mode 100644 index 00000000..b47ca626 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelAllOrder.txt @@ -0,0 +1,22 @@ +POST +/v5/order/cancel-all +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "orderId": "1616024329462743808", + "orderLinkId": "1616024329462743809" + }, + { + "orderId": "1616024287544869632", + "orderLinkId": "1616024287544869633" + } + ], + "success": "1" + }, + "retExtInfo": {}, + "time": 1707381118116 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelMultipleOrders.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelMultipleOrders.txt new file mode 100644 index 00000000..766375a0 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelMultipleOrders.txt @@ -0,0 +1,36 @@ +POST +/v5/order/cancel-batch +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "category": "spot", + "symbol": "BTCUSDT", + "orderId": "1666800494330512128", + "orderLinkId": "spot-btc-03" + }, + { + "category": "spot", + "symbol": "ATOMUSDT", + "orderId": "", + "orderLinkId": "1666800494330512129" + } + ] + }, + "retExtInfo": { + "list": [ + { + "code": 0, + "msg": "OK" + }, + { + "code": 170213, + "msg": "Order does not exist." + } + ] + }, + "time": 1713434299047 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelOrder.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelOrder.txt new file mode 100644 index 00000000..39d8213b --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/CancelOrder.txt @@ -0,0 +1,13 @@ +POST +/v5/order/cancel +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "orderId": "c6f055d9-7f21-4079-913d-e6523a9cfffa", + "orderLinkId": "linear-004" + }, + "retExtInfo": {}, + "time": 1672217377164 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/EditMultipleOrders.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/EditMultipleOrders.txt new file mode 100644 index 00000000..3ec73ae5 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/EditMultipleOrders.txt @@ -0,0 +1,36 @@ +POST +/v5/order/amend-batch +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "category": "option", + "symbol": "ETH-30DEC22-500-C", + "orderId": "b551f227-7059-4fb5-a6a6-699c04dbd2f2", + "orderLinkId": "" + }, + { + "category": "option", + "symbol": "ETH-30DEC22-700-C", + "orderId": "fa6a595f-1a57-483f-b9d3-30e9c8235a52", + "orderLinkId": "" + } + ] + }, + "retExtInfo": { + "list": [ + { + "code": 0, + "msg": "OK" + }, + { + "code": 0, + "msg": "OK" + } + ] + }, + "time": 1672222808060 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/EditOrder.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/EditOrder.txt new file mode 100644 index 00000000..ce879727 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/EditOrder.txt @@ -0,0 +1,13 @@ +POST +/v5/order/amend +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "orderId": "c6f055d9-7f21-4079-913d-e6523a9cfffa", + "orderLinkId": "linear-004" + }, + "retExtInfo": {}, + "time": 1672217093461 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetAssetExchangeHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetAssetExchangeHistory.txt new file mode 100644 index 00000000..a4a9a72e --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetAssetExchangeHistory.txt @@ -0,0 +1,23 @@ +GET +/v5/asset/exchange/order-record +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "orderBody": [ + { + "fromCoin": "BTC", + "fromAmount": "0.100000000000000000", + "toCoin": "ETH", + "toAmount": "1.385866230000000000", + "exchangeRate": "13.858662380000000000", + "createdTime": "1672197760", + "exchangeTxId": "145102533285208544812654440448" + } + ], + "nextPageCursor": "173341:1672197760" + }, + "retExtInfo": {}, + "time": 1672990464021 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetBorrowQuota.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetBorrowQuota.txt new file mode 100644 index 00000000..ccc12504 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetBorrowQuota.txt @@ -0,0 +1,18 @@ +GET +/v5/order/spot-borrow-check +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "symbol": "BTCUSDT", + "maxTradeQty": "6.6065", + "side": "Buy", + "spotMaxTradeAmount": "9004.75628594", + "maxTradeAmount": "218014.01330797", + "borrowCoin": "USDT", + "spotMaxTradeQty": "0.2728" + }, + "retExtInfo": {}, + "time": 1698895841534 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetClosedProfitLoss.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetClosedProfitLoss.txt new file mode 100644 index 00000000..61e65f83 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetClosedProfitLoss.txt @@ -0,0 +1,34 @@ +GET +/v5/position/closed-pnl +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "nextPageCursor": "5a373bfe-188d-4913-9c81-d57ab5be8068%3A1672214887231423699%2C5a373bfe-188d-4913-9c81-d57ab5be8068%3A1672214887231423699", + "category": "linear", + "list": [ + { + "symbol": "ETHPERP", + "orderType": "Market", + "leverage": "3", + "updatedTime": "1672214887236", + "side": "Sell", + "orderId": "5a373bfe-188d-4913-9c81-d57ab5be8068", + "closedPnl": "-47.4065323", + "avgEntryPrice": "1194.97516667", + "qty": "3", + "cumEntryValue": "3584.9255", + "createdTime": "1672214887231423699", + "orderPrice": "1122.95", + "closedSize": "3", + "avgExitPrice": "1180.59833333", + "execType": "Trade", + "fillCount": "4", + "cumExitValue": "3541.795" + } + ] + }, + "retExtInfo": {}, + "time": 1672284129153 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetDeliveryHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetDeliveryHistory.txt new file mode 100644 index 00000000..663ae356 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetDeliveryHistory.txt @@ -0,0 +1,25 @@ +GET +/v5/asset/delivery-record +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "nextPageCursor": "132791%3A0%2C132791%3A0", + "category": "option", + "list": [ + { + "symbol": "BTC-29DEC22-16000-P", + "side": "Buy", + "deliveryTime": 1672300800860, + "strike": "16000", + "fee": "0.00000000", + "position": "0.01", + "deliveryPrice": "16541.86369547", + "deliveryRpl": "3.5" + } + ] + }, + "retExtInfo": {}, + "time": 1672362116184 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetLeverageTokenOrderHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetLeverageTokenOrderHistory.txt new file mode 100644 index 00000000..963c1ea7 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetLeverageTokenOrderHistory.txt @@ -0,0 +1,26 @@ +GET +/v5/spot-lever-token/order-record +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "list": [ + { + "amount": "222.90757477", + "fee": "0", + "ltCoin": "EOS3L", + "ltOrderStatus": "1", + "ltOrderType": "1", + "orderId": "2611", + "orderTime": "1672737465000", + "serialNo": "pruchase-002", + "updateTime": "1672737478000", + "value": "95.13860435", + "valueCoin": "USDT" + } + ] + }, + "retExtInfo": {}, + "time": 1672294446137 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetOrderHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetOrderHistory.txt new file mode 100644 index 00000000..5d4454c1 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetOrderHistory.txt @@ -0,0 +1,58 @@ +GET +/v5/order/history +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "orderId": "14bad3a1-6454-43d8-bcf2-5345896cf74d", + "orderLinkId": "YLxaWKMiHU", + "blockTradeId": "", + "symbol": "BTCUSDT", + "price": "26864.40", + "qty": "0.003", + "side": "Buy", + "isLeverage": "", + "positionIdx": 1, + "orderStatus": "Cancelled", + "cancelType": "UNKNOWN", + "rejectReason": "EC_PostOnlyWillTakeLiquidity", + "avgPrice": "0", + "leavesQty": "0.000", + "leavesValue": "0", + "cumExecQty": "0.000", + "cumExecValue": "0", + "cumExecFee": "0", + "timeInForce": "PostOnly", + "orderType": "Limit", + "stopOrderType": "UNKNOWN", + "orderIv": "", + "triggerPrice": "0.00", + "takeProfit": "0.00", + "stopLoss": "0.00", + "tpTriggerBy": "UNKNOWN", + "slTriggerBy": "UNKNOWN", + "triggerDirection": 0, + "triggerBy": "UNKNOWN", + "lastPriceOnCreated": "0.00", + "reduceOnly": false, + "closeOnTrigger": false, + "smpType": "None", + "smpGroup": 0, + "smpOrderId": "", + "tpslMode": "", + "tpLimitPrice": "", + "slLimitPrice": "", + "placeType": "", + "createdTime": "1684476068369", + "updatedTime": "1684476068372" + } + ], + "nextPageCursor": "page_token%3D39380%26", + "category": "linear" + }, + "retExtInfo": {}, + "time": 1684766282976 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetOrders.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetOrders.txt new file mode 100644 index 00000000..20dac607 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetOrders.txt @@ -0,0 +1,58 @@ +GET +/v5/order/realtime +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "orderId": "fd4300ae-7847-404e-b947-b46980a4d140", + "orderLinkId": "test-000005", + "blockTradeId": "", + "symbol": "ETHUSDT", + "price": "1600.00", + "qty": "0.10", + "side": "Buy", + "isLeverage": "", + "positionIdx": 1, + "orderStatus": "New", + "cancelType": "UNKNOWN", + "rejectReason": "EC_NoError", + "avgPrice": "0", + "leavesQty": "0.10", + "leavesValue": "160", + "cumExecQty": "0.00", + "cumExecValue": "0", + "cumExecFee": "0", + "timeInForce": "GTC", + "orderType": "Limit", + "stopOrderType": "UNKNOWN", + "orderIv": "", + "triggerPrice": "0.00", + "takeProfit": "2500.00", + "stopLoss": "1500.00", + "tpTriggerBy": "LastPrice", + "slTriggerBy": "LastPrice", + "triggerDirection": 0, + "triggerBy": "UNKNOWN", + "lastPriceOnCreated": "", + "reduceOnly": false, + "closeOnTrigger": false, + "smpType": "None", + "smpGroup": 0, + "smpOrderId": "", + "tpslMode": "Full", + "tpLimitPrice": "", + "slLimitPrice": "", + "placeType": "", + "createdTime": "1684738540559", + "updatedTime": "1684738540561" + } + ], + "nextPageCursor": "page_args%3Dfd4300ae-7847-404e-b947-b46980a4d140%26symbol%3D6%26", + "category": "linear" + }, + "retExtInfo": {}, + "time": 1684765770483 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetPositions.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetPositions.txt new file mode 100644 index 00000000..04505418 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetPositions.txt @@ -0,0 +1,50 @@ +GET +/v5/position/list +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "positionIdx": 0, + "riskId": 1, + "riskLimitValue": "150", + "symbol": "BTCUSD", + "side": "Sell", + "size": "300", + "avgPrice": "27464.50441675", + "positionValue": "0.01092319", + "tradeMode": 0, + "positionStatus": "Normal", + "autoAddMargin": 1, + "adlRankIndicator": 2, + "leverage": "10", + "positionBalance": "0.00139186", + "markPrice": "28224.50", + "liqPrice": "", + "bustPrice": "999999.00", + "positionMM": "0.0000015", + "positionIM": "0.00010923", + "tpslMode": "Full", + "takeProfit": "0.00", + "stopLoss": "0.00", + "trailingStop": "0.00", + "unrealisedPnl": "-0.00029413", + "curRealisedPnl": "0.00013123", + "cumRealisedPnl": "-0.00096902", + "seq": 5723621632, + "isReduceOnly": false, + "mmrSysUpdateTime": "", + "leverageSysUpdatedTime": "", + "sessionAvgPrice": "", + "createdTime": "1676538056258", + "updatedTime": "1697673600012" + } + ], + "nextPageCursor": "", + "category": "inverse" + }, + "retExtInfo": {}, + "time": 1697684980172 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetSettlementHistory.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetSettlementHistory.txt new file mode 100644 index 00000000..054e7fab --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetSettlementHistory.txt @@ -0,0 +1,24 @@ +GET +/v5/asset/settlement-record +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "nextPageCursor": "116952%3A1%2C116952%3A1", + "category": "linear", + "list": [ + { + "realisedPnl": "-71.28", + "symbol": "BTCPERP", + "side": "Buy", + "markPrice": "16620", + "size": "1.5", + "createdTime": "1672214400000", + "sessionAvgPrice": "16620" + } + ] + }, + "retExtInfo": {}, + "time": 1672284884285 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/GetUserTrades.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetUserTrades.txt new file mode 100644 index 00000000..8ccfa4f2 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/GetUserTrades.txt @@ -0,0 +1,44 @@ +GET +/v5/execution/list +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "nextPageCursor": "132766%3A2%2C132766%3A2", + "category": "linear", + "list": [ + { + "symbol": "ETHPERP", + "orderType": "Market", + "underlyingPrice": "", + "orderLinkId": "", + "side": "Buy", + "indexPrice": "", + "orderId": "8c065341-7b52-4ca9-ac2c-37e31ac55c94", + "stopOrderType": "UNKNOWN", + "leavesQty": "0", + "execTime": "1672282722429", + "feeCurrency": "", + "isMaker": false, + "execFee": "0.071409", + "feeRate": "0.0006", + "execId": "e0cbe81d-0f18-5866-9415-cf319b5dab3b", + "tradeIv": "", + "blockTradeId": "", + "markPrice": "1183.54", + "execPrice": "1190.15", + "markIv": "", + "orderQty": "0.1", + "orderPrice": "1236.9", + "execValue": "119.015", + "execType": "Trade", + "execQty": "0.1", + "closedSize": "", + "seq": 4688002127 + } + ] + }, + "retExtInfo": {}, + "time": 1672283754510 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/PlaceMultipleOrders.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/PlaceMultipleOrders.txt new file mode 100644 index 00000000..a3beecfc --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/PlaceMultipleOrders.txt @@ -0,0 +1,38 @@ +POST +/v5/order/create-batch +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "list": [ + { + "category": "spot", + "symbol": "BTCUSDT", + "orderId": "1666800494330512128", + "orderLinkId": "spot-btc-03", + "createAt": "1713434102752" + }, + { + "category": "spot", + "symbol": "ATOMUSDT", + "orderId": "1666800494330512129", + "orderLinkId": "spot-atom-03", + "createAt": "1713434102752" + } + ] + }, + "retExtInfo": { + "list": [ + { + "code": 0, + "msg": "OK" + }, + { + "code": 0, + "msg": "OK" + } + ] + }, + "time": 1713434102753 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/PlaceOrder.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/PlaceOrder.txt new file mode 100644 index 00000000..c268c450 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/PlaceOrder.txt @@ -0,0 +1,13 @@ +POST +/v5/order/create +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "orderId": "1321003749386327552", + "orderLinkId": "spot-test-postonly" + }, + "retExtInfo": {}, + "time": 1672211918471 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/PurchaseLeverageToken.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/PurchaseLeverageToken.txt new file mode 100644 index 00000000..8202b862 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/PurchaseLeverageToken.txt @@ -0,0 +1,19 @@ +POST +/v5/spot-lever-token/purchase +true +{ + "retCode": 0, + "retMsg": "success", + "result": { + "amount": "200", + "execAmt": "", + "execQty": "", + "ltCoin": "EOS3L", + "ltOrderStatus": "2", + "purchaseId": "2611", + "serialNo": "purchase-001", + "valueCoin": "USDT" + }, + "retExtInfo": {}, + "time": 1672293867729 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/RedeemLeverageToken.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/RedeemLeverageToken.txt new file mode 100644 index 00000000..fcc081be --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/RedeemLeverageToken.txt @@ -0,0 +1,19 @@ +POST +/v5/spot-lever-token/redeem +true +{ + "retCode": 0, + "retMsg": "OK", + "result": { + "execAmt": "", + "execQty": "150", + "ltCoin": "EOS3L", + "ltOrderStatus": "2", + "quantity": "", + "redeemId": "2619", + "serialNo": "redeem-001", + "valueCoin": "EOS3L" + }, + "retExtInfo": {}, + "time": 1672296417363 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/SetDisconnectCancelAll.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/SetDisconnectCancelAll.txt new file mode 100644 index 00000000..97e9d55a --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/SetDisconnectCancelAll.txt @@ -0,0 +1,7 @@ +POST +/v5/order/disconnected-cancel-all +true +{ + "retCode": 0, + "retMsg": "success" +} \ No newline at end of file diff --git a/Bybit.UnitTests/Endpoints/V5Api/Trading/SetTradingStop.txt b/Bybit.UnitTests/Endpoints/V5Api/Trading/SetTradingStop.txt new file mode 100644 index 00000000..8a4789a6 --- /dev/null +++ b/Bybit.UnitTests/Endpoints/V5Api/Trading/SetTradingStop.txt @@ -0,0 +1,10 @@ +POST +/v5/position/trading-stop +true +{ + "retCode": 0, + "retMsg": "OK", + "result": {}, + "retExtInfo": {}, + "time": 1672283125359 +} \ No newline at end of file diff --git a/Bybit.UnitTests/JsonSocketTests.cs b/Bybit.UnitTests/JsonSocketTests.cs deleted file mode 100644 index 44dab86d..00000000 --- a/Bybit.UnitTests/JsonSocketTests.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Bybit.Net.Interfaces.Clients; -using Bybit.Net.Objects.Models.CopyTrading; -using Bybit.Net.Objects.Models.Derivatives.UnifiedMargin; -using Bybit.Net.Objects.Models.Socket; -using Bybit.Net.Objects.Models.Socket.Derivatives; -using Bybit.Net.Objects.Models.Socket.Derivatives.Contract; -using Bybit.Net.Objects.Models.Socket.Derivatives.UnifiedMargin; -using Bybit.Net.Objects.Models.Socket.Spot; -using Bybit.Net.Objects.Models.Spot.v3; -using Bybit.Net.UnitTests; -using Newtonsoft.Json; -using NUnit.Framework; - -namespace Bybit.UnitTests -{ - internal class JsonSocketTests - { - [Test] - public async Task ValidateKlineUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Spot/Socket/KlineUpdate.txt"); - } - - [Test] - public async Task ValidateOrderBookUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Spot/Socket/OrderBookUpdate.txt", new List { "v" }); - } - - [Test] - public async Task ValidateBookPriceV3UpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Spot/Socket/BookPriceUpdateV3.txt"); - } - - [Test] - public async Task ValidateTickerUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Spot/Socket/TickerUpdate.txt", new List { "m" }); - } - - [Test] - public async Task ValidateAccountInfoUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Spot/Socket/AccountInfoUpdate.txt"); - } - - [Test] - public async Task ValidateOrderUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Spot/Socket/OrderUpdate.txt"); - } - - [Test] - public async Task ValidateUserTradeUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Spot/Socket/UserTradeUpdate.txt"); - } - - [Test] - public async Task ValidateCopyBalanceUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/CopyTrading/Socket/BalanceUpdate.txt"); - await TestFileToObject>(@"JsonResponses/CopyTrading/Socket/PositionUpdate.txt"); - await TestFileToObject>(@"JsonResponses/CopyTrading/Socket/OrderUpdate.txt"); - await TestFileToObject>(@"JsonResponses/CopyTrading/Socket/TradeUpdate.txt"); - } - - [Test] - public async Task ValidateDerivativesKlineUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/PublicSocket/KlineUpdate.txt"); - } - - [Test] - public async Task ValidateDerivativesTradeUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/PublicSocket/TradeUpdate.txt"); - } - - [Test] - public async Task ValidateContractBalanceUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/Contract/Socket/BalanceUpdate.txt"); - } - - [Test] - public async Task ValidateContractPositionUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/Contract/Socket/PositionUpdate.txt"); - } - - [Test] - public async Task ValidateContractUserTradeUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/Contract/Socket/UserTradeUpdate.txt"); - } - - [Test] - public async Task ValidateContractOrderUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/Contract/Socket/OrderUpdate.txt"); - } - - [Test] - public async Task ValidateUMBalanceUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Derivatives/UnifiedMargin/Socket/BalanceUpdate.txt"); - } - - [Test] - public async Task ValidateUMPositionUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/UnifiedMargin/Socket/PositionUpdate.txt"); - } - - [Test] - public async Task ValidateUMUserTradeUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/UnifiedMargin/Socket/UserTradeUpdate.txt"); - } - - [Test] - public async Task ValidateUMOrderUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/UnifiedMargin/Socket/OrderUpdate.txt"); - } - - [Test] - public async Task ValidateUMGreeksUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Derivatives/UnifiedMargin/Socket/GreeksUpdate.txt"); - } - - private static async Task TestFileToObject(string filePath, List ignoreProperties = null) - { - var listener = new EnumValueTraceListener(); - Trace.Listeners.Add(listener); - var path = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName; - string json; - try - { - var file = File.OpenRead(Path.Combine(path, filePath)); - using var reader = new StreamReader(file); - json = await reader.ReadToEndAsync(); - } - catch (FileNotFoundException) - { - throw; - } - - var result = JsonConvert.DeserializeObject(json); - JsonToObjectComparer.ProcessData("", result, json, ignoreProperties: new Dictionary> - { - { "", ignoreProperties ?? new List() } - }); - Trace.Listeners.Remove(listener); - } - } - - internal class EnumValueTraceListener : TraceListener - { - public override void Write(string message) - { - if (message.Contains("Cannot map")) - throw new Exception("Enum value error: " + message); - } - - public override void WriteLine(string message) - { - if (message.Contains("Cannot map")) - throw new Exception("Enum value error: " + message); - } - } -} diff --git a/Bybit.UnitTests/JsonTests.cs b/Bybit.UnitTests/JsonTests.cs index 43e784f1..c00760a1 100644 --- a/Bybit.UnitTests/JsonTests.cs +++ b/Bybit.UnitTests/JsonTests.cs @@ -155,58 +155,5 @@ await _comparer.ProcessSubject("Derivatives/Contract/Account", c => c.Derivative ); } - [Test] - public async Task ValidateV5TradingCalls() - { - await _comparer.ProcessSubject("V5/Trading", c => c.V5Api.Trading, - useNestedJsonPropertyForCompare: new Dictionary - { - { "GetLeverageTokenOrderHistoryAsync", "list" } - }, - ignoreProperties: new Dictionary> - { - }, - useNestedJsonPropertyForAllCompare: new List { "result" } - ); - } - - [Test] - public async Task ValidateV5AccountCalls() - { - await _comparer.ProcessSubject("V5/Account", c => c.V5Api.Account, - useNestedJsonPropertyForCompare: new Dictionary - { - { "GetAccountTypesAsync", "accounts" } - }, - ignoreProperties: new Dictionary> - { - { "AddOrReduceMarginAsync", new List{ "category" } } - }, - useNestedJsonPropertyForAllCompare: new List { "result" } - ); - } - - [Test] - public async Task ValidateV5SubAccountCalls() - { - await _comparer.ProcessSubject("V5/SubAccount", c => c.V5Api.SubAccount, - useNestedJsonPropertyForCompare: new Dictionary - { - { "GetSubAccountsAsync", "subMembers" } - }, - useNestedJsonPropertyForAllCompare: new List { "result" } - ); - } - - [Test] - public async Task ValidateV5ExchangeDataCalls() - { - await _comparer.ProcessSubject("V5/ExchangeData", c => c.V5Api.ExchangeData, - useNestedJsonPropertyForCompare: new Dictionary { - }, - ignoreProperties: new Dictionary> { }, - useNestedJsonPropertyForAllCompare: new List { "result" } - ); - } } } diff --git a/Bybit.UnitTests/JsonToObjectComparer.cs b/Bybit.UnitTests/JsonToObjectComparer.cs index f7c768c9..7969fcc2 100644 --- a/Bybit.UnitTests/JsonToObjectComparer.cs +++ b/Bybit.UnitTests/JsonToObjectComparer.cs @@ -434,5 +434,19 @@ private static void CheckValues(string method, string property, JValue jsonValue throw; } } + internal class EnumValueTraceListener : TraceListener + { + public override void Write(string message) + { + if (message.Contains("Cannot map")) + throw new Exception("Enum value error: " + message); + } + + public override void WriteLine(string message) + { + if (message.Contains("Cannot map")) + throw new Exception("Enum value error: " + message); + } + } } } diff --git a/Bybit.UnitTests/RestRequestTests.cs b/Bybit.UnitTests/RestRequestTests.cs new file mode 100644 index 00000000..1a7fded2 --- /dev/null +++ b/Bybit.UnitTests/RestRequestTests.cs @@ -0,0 +1,131 @@ +using NUnit.Framework; +using System.Threading.Tasks; +using CryptoExchange.Net.Authentication; +using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Testing; +using System.Collections.Generic; +using Bybit.Net.Clients; +using System.Linq; +using Bybit.Net.Objects.Models.V5; + +namespace Bybit.Net.UnitTests +{ + [TestFixture] + public class RestRequestTests + { + [Test] + public async Task ValidateSpotAccountCalls() + { + var client = new BybitRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/V5Api/Account", "https://api.bybit.com", IsAuthenticated, "result", stjCompare: false); + await tester.ValidateAsync(client => client.V5Api.Account.SetLeverageAsync(Enums.Category.Option, "ETHUSDT", 1, 1), "SetLeverage"); + await tester.ValidateAsync(client => client.V5Api.Account.SetCollateralAssetAsync("ETH", true), "SetCollateralAsset"); + await tester.ValidateAsync(client => client.V5Api.Account.SetMultipleCollateralAssetsAsync(new[] { new BybitSetCollateralAssetRequest { Asset = "ETH", UseForCollateral = true} }), "SetMultipleCollateralAssets"); + await tester.ValidateAsync(client => client.V5Api.Account.SwitchCrossIsolatedMarginAsync(Enums.Category.Option, "ETHUSDT", Enums.TradeMode.Isolated, 1, 1), "SwitchCrossIsolatedMargin"); + await tester.ValidateAsync(client => client.V5Api.Account.SetTakeProfitStopLossModeAsync(Enums.Category.Option, "ETHUSDT", Enums.StopLossTakeProfitMode.Full), "SetTakeProfitStopLossMode"); + await tester.ValidateAsync(client => client.V5Api.Account.SwitchPositionModeAsync(Enums.Category.Option, Enums.V5.PositionMode.MergedSingle), "SwitchPositionMode"); + await tester.ValidateAsync(client => client.V5Api.Account.SetRiskLimitAsync(Enums.Category.Option, "ETHUSDT", 1), "SetRiskLimit"); + await tester.ValidateAsync(client => client.V5Api.Account.SetAutoAddMarginAsync(Enums.Category.Option, "ETHUSDT", true), "SetAutoAddMargin"); + await tester.ValidateAsync(client => client.V5Api.Account.GetBalancesAsync(Enums.AccountType.Option), "GetBalances"); + await tester.ValidateAsync(client => client.V5Api.Account.GetBorrowHistoryAsync("ETH"), "GetBorrowHistory"); + await tester.ValidateAsync(client => client.V5Api.Account.GetCollateralInfoAsync("ETH"), "GetCollateralInfo"); + await tester.ValidateAsync(client => client.V5Api.Account.GetAssetGreeksAsync("ETH"), "GetAssetGreeks"); + await tester.ValidateAsync(client => client.V5Api.Account.GetFeeRateAsync(Enums.Category.Inverse), "GetFeeRate"); + await tester.ValidateAsync(client => client.V5Api.Account.GetMarginAccountInfoAsync(), "GetMarginAccountInfo", ignoreProperties: new List { "spotHedgingStatus" }); + await tester.ValidateAsync(client => client.V5Api.Account.GetTransactionHistoryAsync(), "GetTransactionHistory"); + //await tester.ValidateAsync(client => client.V5Api.Account.SetMarginModeAsync(Enums.MarginMode.PortfolioMargin), "SetMarginMode"); + await tester.ValidateAsync(client => client.V5Api.Account.GetAssetInfoAsync(), "GetAssetInfo", ignoreProperties: new List { "chainDeposit", "chainWithdraw" }); + await tester.ValidateAsync(client => client.V5Api.Account.GetWithdrawalsAsync(), "GetWithdrawals", skipResponseValidation: true); + await tester.ValidateAsync(client => client.V5Api.Account.GetDelayedWithdrawQuantityAsync("ETH"), "GetDelayedWithdrawQuantity"); + await tester.ValidateAsync(client => client.V5Api.Account.WithdrawAsync("ETH", "ERC20", "123", 1), "Withdraw"); + await tester.ValidateAsync(client => client.V5Api.Account.CancelWithdrawalAsync("123"), "CancelWithdrawal"); + await tester.ValidateAsync(client => client.V5Api.Account.GetApiKeyInfoAsync(), "GetApiKeyInfo"); + await tester.ValidateAsync(client => client.V5Api.Account.EditApiKeyAsync(), "EditApiKey"); + await tester.ValidateAsync(client => client.V5Api.Account.DeleteApiKeyAsync(), "DeleteApiKey"); + await tester.ValidateAsync(client => client.V5Api.Account.GetAccountTypesAsync(), "GetAccountTypes", "result.accounts"); + await tester.ValidateAsync(client => client.V5Api.Account.AddOrReduceMarginAsync(Enums.Category.Option, "ETHUSDT", 1), "AddOrReduceMargin"); + await tester.ValidateAsync(client => client.V5Api.Account.SetSpotMarginLeverageAsync(1), "SetSpotMarginLeverage"); + await tester.ValidateAsync(client => client.V5Api.Account.GetSpotMarginStatusAndLeverageAsync(), "GetSpotMarginStatusAndLeverage", ignoreProperties: new List { "spotMarginMode" }); + await tester.ValidateAsync(client => client.V5Api.Account.SetSpotMarginTradeModeAsync(true), "SetSpotMarginTradeMode"); + await tester.ValidateAsync(client => client.V5Api.Account.GetSpotMarginDataAsync(), "GetSpotMarginData", "result.vipCoinList"); + await tester.ValidateAsync(client => client.V5Api.Account.GetBrokerAccountInfoAsync(), "GetBrokerAccountInfo"); + await tester.ValidateAsync(client => client.V5Api.Account.GetBrokerEarningsAsync(), "GetBrokerEarnings"); + await tester.ValidateAsync(client => client.V5Api.Account.SetSpotHedgingModeAsync(true), "SetSpotHedgingMode"); + await tester.ValidateAsync(client => client.V5Api.Account.RepayLiabilitiesAsync(), "RepayLiabilities", "result.list"); + } + + [Test] + public async Task ValidateSpotExchangeDataCalls() + { + var client = new BybitRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/V5Api/ExchangeData", "https://api.bybit.com", IsAuthenticated, "result", stjCompare: false); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetAnnouncementsAsync("en-Us"), "GetAnnouncements"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetKlinesAsync(Enums.Category.Spot, "ETHUSDT", Enums.KlineInterval.OneDay), "GetKlines"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetMarkPriceKlinesAsync(Enums.Category.Spot, "ETHUSDT", Enums.KlineInterval.OneDay), "GetMarkPriceKlines"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetIndexPriceKlinesAsync(Enums.Category.Spot, "ETHUSDT", Enums.KlineInterval.OneDay), "GetIndexPriceKlines"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetPremiumIndexPriceKlinesAsync(Enums.Category.Spot, "ETHUSDT", Enums.KlineInterval.OneDay), "GetPremiumIndexPriceKlines"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetSpotSymbolsAsync(), "GetSpotSymbols"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetOptionSymbolsAsync(), "GetOptionSymbols"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetLinearInverseSymbolsAsync(Enums.Category.Inverse), "GetLinearInverseSymbols", ignoreProperties: new List { "postOnlyMaxOrderQty" }); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetOrderbookAsync(Enums.Category.Spot, "ETHUSDT"), "GetOrderbook"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetSpotTickersAsync("ETHUSDT"), "GetSpotTickers"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetOptionTickersAsync("ETHUSDT"), "GetOptionTickers"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetLinearInverseTickersAsync(Enums.Category.Inverse, "ETHUSDT"), "GetLinearInverseTickers"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetFundingRateHistoryAsync(Enums.Category.Inverse, "ETHUSDT"), "GetFundingRateHistory"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetTradeHistoryAsync(Enums.Category.Inverse, "ETHUSDT"), "GetTradeHistory"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetOpenInterestAsync(Enums.Category.Inverse, "ETHUSDT", Enums.OpenInterestInterval.OneDay), "GetOpenInterest"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetHistoricalVolatilityAsync(Enums.Category.Option, "ETHUSDT"), "GetHistoricalVolatility"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetInsuranceAsync(), "GetInsurance"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetRiskLimitAsync(Enums.Category.Inverse), "GetRiskLimit"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetDeliveryPriceAsync(Enums.Category.Inverse), "GetDeliveryPrice"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetLeverageTokensAsync(), "GetLeverageTokens", nestedJsonProperty: "result.list"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetLeverageTokenMarketAsync("ETHUSDT"), "GetLeverageTokenMarket"); + await tester.ValidateAsync(client => client.V5Api.ExchangeData.GetLongShortRatioAsync(Enums.Category.Option, "ETHUSDT", Enums.DataPeriod.OneDay), "GetLongShortRatio", nestedJsonProperty: "result.list"); + } + + [Test] + public async Task ValidateSpotTradingCalls() + { + var client = new BybitRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/V5Api/Trading", "https://api.bybit.com", IsAuthenticated, "result", stjCompare: false); + await tester.ValidateAsync(client => client.V5Api.Trading.PlaceOrderAsync(Enums.Category.Option, "ETHUSDT", Enums.OrderSide.Buy, Enums.NewOrderType.Market, 1), "PlaceOrder"); + await tester.ValidateAsync(client => client.V5Api.Trading.PlaceMultipleOrdersAsync(Enums.Category.Option, new[] { new BybitPlaceOrderRequest() }), "PlaceMultipleOrders", skipResponseValidation: true); + await tester.ValidateAsync(client => client.V5Api.Trading.EditOrderAsync(Enums.Category.Option, "ETHUSDT"), "EditOrder"); + await tester.ValidateAsync(client => client.V5Api.Trading.EditMultipleOrdersAsync(Enums.Category.Option, new[] { new BybitEditOrderRequest() }), "EditMultipleOrders", skipResponseValidation: true); + await tester.ValidateAsync(client => client.V5Api.Trading.CancelOrderAsync(Enums.Category.Option, "ETHUSDT", "234"), "CancelOrder"); + await tester.ValidateAsync(client => client.V5Api.Trading.CancelMultipleOrdersAsync(Enums.Category.Option, new[] { new BybitCancelOrderRequest() }), "CancelMultipleOrders", skipResponseValidation: true); + await tester.ValidateAsync(client => client.V5Api.Trading.GetOrdersAsync(Enums.Category.Option, "ETHUSDT"), "GetOrders"); + await tester.ValidateAsync(client => client.V5Api.Trading.CancelAllOrderAsync(Enums.Category.Option, "ETHUSDT"), "CancelAllOrder", ignoreProperties: new List { "success" }); + await tester.ValidateAsync(client => client.V5Api.Trading.GetOrderHistoryAsync(Enums.Category.Option, "ETHUSDT"), "GetOrderHistory"); + await tester.ValidateAsync(client => client.V5Api.Trading.GetBorrowQuotaAsync(Enums.Category.Spot, "ETHUSDT", Enums.OrderSide.Buy), "GetBorrowQuota"); + await tester.ValidateAsync(client => client.V5Api.Trading.SetDisconnectCancelAllAsync(10), "SetDisconnectCancelAll"); + await tester.ValidateAsync(client => client.V5Api.Trading.GetUserTradesAsync(Enums.Category.Option), "GetUserTrades"); + await tester.ValidateAsync(client => client.V5Api.Trading.GetPositionsAsync(Enums.Category.Option), "GetPositions", ignoreProperties: new List { "mmrSysUpdateTime" }); + await tester.ValidateAsync(client => client.V5Api.Trading.GetAssetExchangeHistoryAsync(), "GetAssetExchangeHistory", "result.orderBody"); + await tester.ValidateAsync(client => client.V5Api.Trading.GetDeliveryHistoryAsync(Enums.Category.Option), "GetDeliveryHistory"); + await tester.ValidateAsync(client => client.V5Api.Trading.GetSettlementHistoryAsync(Enums.Category.Option), "GetSettlementHistory"); + await tester.ValidateAsync(client => client.V5Api.Trading.GetClosedProfitLossAsync(Enums.Category.Option), "GetClosedProfitLoss"); + await tester.ValidateAsync(client => client.V5Api.Trading.SetTradingStopAsync(Enums.Category.Option, "ETHUSDT", Enums.V5.PositionIdx.OneWayMode, 1), "SetTradingStop"); + await tester.ValidateAsync(client => client.V5Api.Trading.PurchaseLeverageTokenAsync("123", 1), "PurchaseLeverageToken"); + await tester.ValidateAsync(client => client.V5Api.Trading.RedeemLeverageTokenAsync("123", 1), "RedeemLeverageToken"); + await tester.ValidateAsync(client => client.V5Api.Trading.GetLeverageTokenOrderHistoryAsync("123"), "GetLeverageTokenOrderHistory", "result.list"); + } + + private bool IsAuthenticated(WebCallResult result) + { + return result.RequestHeaders.Any(r => r.Key == "X-BAPI-SIGN"); + } + } +} diff --git a/Bybit.UnitTests/SocketSubscriptionTests.cs b/Bybit.UnitTests/SocketSubscriptionTests.cs new file mode 100644 index 00000000..fafc6400 --- /dev/null +++ b/Bybit.UnitTests/SocketSubscriptionTests.cs @@ -0,0 +1,70 @@ +using Bybit.Net.Clients; +using Bybit.Net.Objects.Models.V5; +using CryptoExchange.Net.Testing; +using NUnit.Framework; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Bybit.Net.UnitTests +{ + [TestFixture] + public class SocketSubscriptionTests + { + [Test] + public async Task ValidateSpotSubscriptions() + { + var client = new BybitSocketClient(opts => + { + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new SocketSubscriptionValidator(client, "Subscriptions/V5/Spot", "https://api.binance.com", "data", stjCompare: false); + await tester.ValidateAsync((client, handler) => client.V5SpotApi.SubscribeToTickerUpdatesAsync("BTCUSDT", handler), "Ticker"); + await tester.ValidateAsync>((client, handler) => client.V5SpotApi.SubscribeToLeveragedTokenKlineUpdatesAsync("BTCUSDT", Enums.KlineInterval.OneMonth, handler), "LeveragedKline"); + await tester.ValidateAsync((client, handler) => client.V5SpotApi.SubscribeToLeveragedTokenTickerUpdatesAsync("BTCUSDT", handler), "LeveragedTicker"); + await tester.ValidateAsync((client, handler) => client.V5SpotApi.SubscribeToLeveragedTokenNavUpdatesAsync("BTCUSDT", handler), "LeveragedNav"); + await tester.ValidateAsync>((client, handler) => client.V5SpotApi.SubscribeToTradeUpdatesAsync("BTCUSDT", handler), "Trades"); + } + + [Test] + public async Task ValidateOptionSubscriptions() + { + var client = new BybitSocketClient(opts => + { + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new SocketSubscriptionValidator(client, "Subscriptions/V5/Option", "https://api.binance.com", "data", stjCompare: false); + await tester.ValidateAsync((client, handler) => client.V5OptionsApi.SubscribeToTickerUpdatesAsync("BTC", handler), "Ticker"); + await tester.ValidateAsync>((client, handler) => client.V5OptionsApi.SubscribeToTradeUpdatesAsync("BTC", handler), "Trades"); + await tester.ValidateAsync((client, handler) => client.V5OptionsApi.SubscribeToOrderbookUpdatesAsync("BTCUSDT", 25, handler), "Book"); + await tester.ValidateAsync>((client, handler) => client.V5OptionsApi.SubscribeToKlineUpdatesAsync("BTCUSDT", Enums.KlineInterval.OneMonth, handler), "Klines"); + await tester.ValidateAsync((client, handler) => client.V5OptionsApi.SubscribeToLiquidationUpdatesAsync("BTCUSDT", handler), "Liquidations"); + } + + [Test] + public async Task ValidateLinearSubscriptions() + { + var client = new BybitSocketClient(opts => + { + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new SocketSubscriptionValidator(client, "Subscriptions/V5/Linear", "https://api.binance.com", "data", stjCompare: false); + await tester.ValidateAsync((client, handler) => client.V5LinearApi.SubscribeToTickerUpdatesAsync("BTCUSDT", handler), "Ticker"); + await tester.ValidateAsync>((client, handler) => client.V5LinearApi.SubscribeToTradeUpdatesAsync("BTCUSDT", handler), "Trades"); + } + + [Test] + public async Task ValidatePrivateSubscriptions() + { + var client = new BybitSocketClient(opts => + { + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new SocketSubscriptionValidator(client, "Subscriptions/V5/Private", "https://api.binance.com", "data", stjCompare: false); + await tester.ValidateAsync>((client, handler) => client.V5PrivateApi.SubscribeToPositionUpdatesAsync(handler), "Position", ignoreProperties: new List { "entryPrice" }); + await tester.ValidateAsync>((client, handler) => client.V5PrivateApi.SubscribeToUserTradeUpdatesAsync(handler), "UserTrades"); + await tester.ValidateAsync>((client, handler) => client.V5PrivateApi.SubscribeToOrderUpdatesAsync(handler), "Order"); + await tester.ValidateAsync>((client, handler) => client.V5PrivateApi.SubscribeToWalletUpdatesAsync(handler), "Balance"); + await tester.ValidateAsync>((client, handler) => client.V5PrivateApi.SubscribeToGreekUpdatesAsync(handler), "Greeks"); + } + } +} diff --git a/Bybit.UnitTests/Subscriptions/V5/Linear/Ticker.txt b/Bybit.UnitTests/Subscriptions/V5/Linear/Ticker.txt new file mode 100644 index 00000000..990fae8c --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Linear/Ticker.txt @@ -0,0 +1,31 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "kline_lt.M.BTCUSDT" ] } +< { "success": true, "ret_msg": "", "conn_id": "3cd84cb1-4d06-4a05-930a-2efe5fc70f0f", "req_id": "|1|", "op": "subscribe" } += +{ + "topic": "tickers.BTCUSDT", + "type": "snapshot", + "data": { + "symbol": "BTCUSDT", + "tickDirection": "PlusTick", + "price24hPcnt": "0.017103", + "lastPrice": "17216.00", + "prevPrice24h": "16926.50", + "highPrice24h": "17281.50", + "lowPrice24h": "16915.00", + "prevPrice1h": "17238.00", + "markPrice": "17217.33", + "indexPrice": "17227.36", + "openInterest": "68744.761", + "openInterestValue": "1183601235.91", + "turnover24h": "1570383121.943499", + "volume24h": "91705.276", + "nextFundingTime": "1673280000000", + "fundingRate": "-0.000212", + "bid1Price": "17215.50", + "bid1Size": "84.489", + "ask1Price": "17216.00", + "ask1Size": "83.020" + }, + "cs": 24987956059, + "ts": 1673272861686 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Linear/Trades.txt b/Bybit.UnitTests/Subscriptions/V5/Linear/Trades.txt new file mode 100644 index 00000000..6a148856 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Linear/Trades.txt @@ -0,0 +1,20 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "publicTrade.BTCUSDT" ] } +< { "success": true, "ret_msg": "", "conn_id": "3cd84cb1-4d06-4a05-930a-2efe5fc70f0f", "req_id": "|1|", "op": "subscribe" } += +{ + "topic": "publicTrade.BTCUSDT", + "type": "snapshot", + "ts": 1672304486868, + "data": [ + { + "T": 1672304486865, + "s": "BTCUSDT", + "S": "Buy", + "v": "0.001", + "p": "16578.50", + "L": "PlusTick", + "i": "20f43950-d8dd-5b31-9112-a178eb6023af", + "BT": false + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Option/Book.txt b/Bybit.UnitTests/Subscriptions/V5/Option/Book.txt new file mode 100644 index 00000000..c8f45d8a --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Option/Book.txt @@ -0,0 +1,34 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "orderbook.25.BTCUSDT" ] } +< { "success": true, "conn_id": "aa01fbfffe80af37-00000001-000b37b9-7147f432704fd28c-00e1c172", "data": { "failTopics": [], "successTopics": [ "tickers.BTC" ] }, "type": "COMMAND_RESP" } += +{ + "topic": "orderbook.25.BTCUSDT", + "type": "snapshot", + "ts": 1672304484978, + "data": { + "s": "BTCUSDT", + "b": [ + [ + "16493.50", + "0.006" + ], + [ + "16493.00", + "0.100" + ] + ], + "a": [ + [ + "16611.00", + "0.029" + ], + [ + "16612.00", + "0.213" + ] + ], + "u": 18521288, + "seq": 7961638724 + }, + "cts": 1672304484976 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Option/Klines.txt b/Bybit.UnitTests/Subscriptions/V5/Option/Klines.txt new file mode 100644 index 00000000..0f9da19a --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Option/Klines.txt @@ -0,0 +1,23 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "kline.M.BTCUSDT" ] } +< { "success": true, "conn_id": "aa01fbfffe80af37-00000001-000b37b9-7147f432704fd28c-00e1c172", "data": { "failTopics": [], "successTopics": [ "tickers.BTC" ] }, "type": "COMMAND_RESP" } += +{ + "topic": "kline.M.BTCUSDT", + "data": [ + { + "start": 1672324800000, + "end": 1672325099999, + "interval": "5", + "open": "16649.5", + "close": "16677", + "high": "16677", + "low": "16608", + "volume": "2.081", + "turnover": "34666.4005", + "confirm": false, + "timestamp": 1672324988882 + } + ], + "ts": 1672324988882, + "type": "snapshot" +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Option/Liquidations.txt b/Bybit.UnitTests/Subscriptions/V5/Option/Liquidations.txt new file mode 100644 index 00000000..82de2d86 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Option/Liquidations.txt @@ -0,0 +1,15 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "liquidation.BTCUSDT" ] } +< { "success": true, "conn_id": "aa01fbfffe80af37-00000001-000b37b9-7147f432704fd28c-00e1c172", "data": { "failTopics": [], "successTopics": [ "tickers.BTC" ] }, "type": "COMMAND_RESP" } += +{ + "topic": "liquidation.BTCUSDT", + "type": "snapshot", + "ts": 1703485237953, + "data": { + "updatedTime": 1703485237953, + "symbol": "BTCUSDT", + "side": "Sell", + "size": "0.003", + "price": "43511.70" + } +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Option/Ticker.txt b/Bybit.UnitTests/Subscriptions/V5/Option/Ticker.txt new file mode 100644 index 00000000..4f6da893 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Option/Ticker.txt @@ -0,0 +1,36 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "kline_lt.M.BTCUSDT" ] } +< { "success": true, "conn_id": "aa01fbfffe80af37-00000001-000b37b9-7147f432704fd28c-00e1c172", "data": { "failTopics": [], "successTopics": [ "tickers.BTC" ] }, "type": "COMMAND_RESP" } += +{ + "id": "tickers.BTC-6JAN23-17500-C-2480334983-1672917511074", + "topic": "tickers.BTC", + "ts": 1672917511074, + "data": { + "symbol": "BTC-6JAN23-17500-C", + "bidPrice": "0", + "bidSize": "0", + "bidIv": "0", + "askPrice": "10", + "askSize": "5.1", + "askIv": "0.514", + "lastPrice": "10", + "highPrice24h": "25", + "lowPrice24h": "5", + "markPrice": "7.86976724", + "indexPrice": "16823.73", + "markPriceIv": "0.4896", + "underlyingPrice": "16815.1", + "openInterest": "49.85", + "turnover24h": "446802.8473", + "volume24h": "26.55", + "totalVolume": "86", + "totalTurnover": "1437431", + "delta": "0.047831", + "gamma": "0.00021453", + "vega": "0.81351067", + "theta": "-19.9115368", + "predictedDeliveryPrice": "0", + "change24h": "-0.33333334" + }, + "type": "snapshot" +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Option/Trades.txt b/Bybit.UnitTests/Subscriptions/V5/Option/Trades.txt new file mode 100644 index 00000000..42280997 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Option/Trades.txt @@ -0,0 +1,20 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "publicTrade.BTC" ] } +< { "success": true, "conn_id": "aa01fbfffe80af37-00000001-000b37b9-7147f432704fd28c-00e1c172", "data": { "failTopics": [], "successTopics": [ "tickers.BTC" ] }, "type": "COMMAND_RESP" } += +{ + "topic": "publicTrade.BTC", + "type": "snapshot", + "ts": 1672304486868, + "data": [ + { + "T": 1672304486865, + "s": "BTCUSDT", + "S": "Buy", + "v": "0.001", + "p": "16578.50", + "L": "PlusTick", + "i": "20f43950-d8dd-5b31-9112-a178eb6023af", + "BT": false + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Private/Balance.txt b/Bybit.UnitTests/Subscriptions/V5/Private/Balance.txt new file mode 100644 index 00000000..923dba7e --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Private/Balance.txt @@ -0,0 +1,47 @@ +> { "req_id": "|5|", "op": "auth", "args": [ "|4|", "|2|", "|3|" ] } +< { "success": true, "ret_msg": "", "op": "auth", "conn_id": "cejreaspqfh3sjdnldmg-p", "req_id": "|5|" } +> { "req_id": "|1|", "op": "subscribe", "args": [ "wallet" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "id": "592324d2bce751-ad38-48eb-8f42-4671d1fb4d4e", + "topic": "wallet", + "creationTime": 1700034722104, + "data": [ + { + "accountIMRate": "0", + "accountMMRate": "0", + "totalEquity": "10262.91335023", + "totalWalletBalance": "9684.46297164", + "totalMarginBalance": "9684.46297164", + "totalAvailableBalance": "9556.6056555", + "totalPerpUPL": "0", + "totalInitialMargin": "0", + "totalMaintenanceMargin": "0", + "coin": [ + { + "coin": "BTC", + "equity": "0.00102964", + "usdValue": "36.70759517", + "walletBalance": "0.00102964", + "availableToWithdraw": "0.00102964", + "availableToBorrow": "", + "borrowAmount": "0", + "accruedInterest": "0", + "totalOrderIM": "", + "totalPositionIM": "", + "totalPositionMM": "", + "unrealisedPnl": "0", + "cumRealisedPnl": "-0.00000973", + "bonus": "0", + "collateralSwitch": true, + "marginCollateral": true, + "locked": "0", + "spotHedgingQty": "0.01592413" + } + ], + "accountLTV": "0", + "accountType": "UNIFIED" + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Private/Greeks.txt b/Bybit.UnitTests/Subscriptions/V5/Private/Greeks.txt new file mode 100644 index 00000000..26c4bead --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Private/Greeks.txt @@ -0,0 +1,19 @@ +> { "req_id": "|5|", "op": "auth", "args": [ "|4|", "|2|", "|3|" ] } +< { "success": true, "ret_msg": "", "op": "auth", "conn_id": "cejreaspqfh3sjdnldmg-p", "req_id": "|5|" } +> { "req_id": "|1|", "op": "subscribe", "args": [ "greeks" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "id": "592324fa945a30-2603-49a5-b865-21668c29f2a6", + "topic": "greeks", + "creationTime": 1672364262482, + "data": [ + { + "baseCoin": "ETH", + "totalDelta": "0.06999986", + "totalGamma": "-0.00000001", + "totalVega": "-0.00000024", + "totalTheta": "0.00001314" + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Private/Order.txt b/Bybit.UnitTests/Subscriptions/V5/Private/Order.txt new file mode 100644 index 00000000..c830f6fe --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Private/Order.txt @@ -0,0 +1,56 @@ +> { "req_id": "|5|", "op": "auth", "args": [ "|4|", "|2|", "|3|" ] } +< { "success": true, "ret_msg": "", "op": "auth", "conn_id": "cejreaspqfh3sjdnldmg-p", "req_id": "|5|" } +> { "req_id": "|1|", "op": "subscribe", "args": [ "order" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "id": "5923240c6880ab-c59f-420b-9adb-3639adc9dd90", + "topic": "order", + "creationTime": 1672364262474, + "data": [ + { + "symbol": "ETH-30DEC22-1400-C", + "orderId": "5cf98598-39a7-459e-97bf-76ca765ee020", + "side": "Sell", + "orderType": "Market", + "cancelType": "UNKNOWN", + "price": "72.5", + "qty": "1", + "orderIv": "", + "timeInForce": "IOC", + "orderStatus": "Filled", + "orderLinkId": "", + "lastPriceOnCreated": "", + "reduceOnly": false, + "leavesQty": "", + "leavesValue": "", + "cumExecQty": "1", + "cumExecValue": "75", + "avgPrice": "75", + "blockTradeId": "", + "positionIdx": 0, + "cumExecFee": "0.358635", + "createdTime": "1672364262444", + "updatedTime": "1672364262457", + "rejectReason": "EC_NoError", + "stopOrderType": "", + "tpslMode": "", + "triggerPrice": "", + "takeProfit": "", + "stopLoss": "", + "tpTriggerBy": "", + "slTriggerBy": "", + "tpLimitPrice": "", + "slLimitPrice": "", + "triggerDirection": 0, + "triggerBy": "", + "closeOnTrigger": false, + "category": "option", + "placeType": "price", + "smpType": "None", + "smpGroup": 0, + "smpOrderId": "", + "feeCurrency": "" + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Private/Position.txt b/Bybit.UnitTests/Subscriptions/V5/Private/Position.txt new file mode 100644 index 00000000..865dfaf2 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Private/Position.txt @@ -0,0 +1,48 @@ +> { "req_id": "|5|", "op": "auth", "args": [ "|4|", "|2|", "|3|" ] } +< { "success": true, "ret_msg": "", "op": "auth", "conn_id": "cejreaspqfh3sjdnldmg-p", "req_id": "|5|" } +> { "req_id": "|1|", "op": "subscribe", "args": [ "position" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "id": "1003076014fb7eedb-c7e6-45d6-a8c1-270f0169171a", + "topic": "position", + "creationTime": 1697682317044, + "data": [ + { + "positionIdx": 2, + "tradeMode": 0, + "riskId": 1, + "riskLimitValue": "2000000", + "symbol": "BTCUSDT", + "side": "", + "size": "0", + "entryPrice": "0", + "leverage": "10", + "positionValue": "0", + "positionBalance": "0", + "markPrice": "28184.5", + "positionIM": "0", + "positionMM": "0", + "takeProfit": "0", + "stopLoss": "0", + "trailingStop": "0", + "unrealisedPnl": "0", + "curRealisedPnl": "1.26", + "cumRealisedPnl": "-25.06579337", + "sessionAvgPrice": "0", + "createdTime": "1694402496913", + "updatedTime": "1697682317038", + "tpslMode": "Full", + "liqPrice": "0", + "bustPrice": "", + "category": "linear", + "positionStatus": "Normal", + "adlRankIndicator": 0, + "autoAddMargin": 0, + "leverageSysUpdatedTime": "", + "mmrSysUpdatedTime": "", + "seq": 8327597863, + "isReduceOnly": false + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Private/UserTrades.txt b/Bybit.UnitTests/Subscriptions/V5/Private/UserTrades.txt new file mode 100644 index 00000000..ce83ef71 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Private/UserTrades.txt @@ -0,0 +1,42 @@ +> { "req_id": "|5|", "op": "auth", "args": [ "|4|", "|2|", "|3|" ] } +< { "success": true, "ret_msg": "", "op": "auth", "conn_id": "cejreaspqfh3sjdnldmg-p", "req_id": "|5|" } +> { "req_id": "|1|", "op": "subscribe", "args": [ "execution" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "id": "592324803b2785-26fa-4214-9963-bdd4727f07be", + "topic": "execution", + "creationTime": 1672364174455, + "data": [ + { + "category": "linear", + "symbol": "XRPUSDT", + "execFee": "0.005061", + "execId": "7e2ae69c-4edf-5800-a352-893d52b446aa", + "execPrice": "0.3374", + "execQty": "25", + "execType": "Trade", + "execValue": "8.435", + "isMaker": false, + "feeRate": "0.0006", + "tradeIv": "", + "markIv": "", + "blockTradeId": "", + "markPrice": "0.3391", + "indexPrice": "", + "underlyingPrice": "", + "leavesQty": "0", + "orderId": "f6e324ff-99c2-4e89-9739-3086e47f9381", + "orderLinkId": "", + "orderPrice": "0.3207", + "orderQty": "25", + "orderType": "Market", + "stopOrderType": "UNKNOWN", + "side": "Sell", + "execTime": "1672364174443", + "isLeverage": "0", + "closedSize": "", + "seq": 4688002127 + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedKline.txt b/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedKline.txt new file mode 100644 index 00000000..d9c192ce --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedKline.txt @@ -0,0 +1,21 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "kline_lt.M.BTCUSDT" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "type": "snapshot", + "topic": "kline_lt.M.BTCUSDT", + "data": [ + { + "start": 1672325100000, + "end": 1672325399999, + "interval": "5", + "open": "0.416039541212402799", + "close": "0.41477848043290448", + "high": "0.416039541212402799", + "low": "0.409734237314911206", + "confirm": false, + "timestamp": 1672325322393 + } + ], + "ts": 1672325322393 +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedNav.txt b/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedNav.txt new file mode 100644 index 00000000..96a2cfd9 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedNav.txt @@ -0,0 +1,18 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "lt.BTCUSDT" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "topic": "lt.BTCUSDT", + "ts": 1672325446847, + "type": "snapshot", + "data": { + "symbol": "EOS3LUSDT", + "time": 1672325564554, + "nav": "0.413517419653406162", + "basketPosition": "1.261060779498318641", + "leverage": "2.656197506416192150", + "basketLoan": "-0.684866519289629374", + "circulation": "72767.309468460367138199", + "basket": "91764.000000292013277472" + } +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedTicker.txt b/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedTicker.txt new file mode 100644 index 00000000..73fa0460 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Spot/LeveragedTicker.txt @@ -0,0 +1,16 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "tickers_lt.BTCUSDT" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "topic": "tickers_lt.BTCUSDT", + "ts": 1672325446847, + "type": "snapshot", + "data": { + "symbol": "EOS3LUSDT", + "lastPrice": "0.41477848043290448", + "highPrice24h": "0.435285472510871305", + "lowPrice24h": "0.394601507960931382", + "prevPrice24h": "0.431502290172376349", + "price24hPcnt": "-0.0388" + } +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Spot/Ticker.txt b/Bybit.UnitTests/Subscriptions/V5/Spot/Ticker.txt new file mode 100644 index 00000000..cdde4131 --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Spot/Ticker.txt @@ -0,0 +1,20 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "tickers.BTCUSDT" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "topic": "tickers.BTCUSDT", + "ts": 1673853746003, + "type": "snapshot", + "cs": 2588407389, + "data": { + "symbol": "BTCUSDT", + "lastPrice": "21109.77", + "highPrice24h": "21426.99", + "lowPrice24h": "20575", + "prevPrice24h": "20704.93", + "volume24h": "6780.866843", + "turnover24h": "141946527.22907118", + "price24hPcnt": "0.0196", + "usdIndexPrice": "21120.2400136" + } +} \ No newline at end of file diff --git a/Bybit.UnitTests/Subscriptions/V5/Spot/Trades.txt b/Bybit.UnitTests/Subscriptions/V5/Spot/Trades.txt new file mode 100644 index 00000000..cf272d5b --- /dev/null +++ b/Bybit.UnitTests/Subscriptions/V5/Spot/Trades.txt @@ -0,0 +1,20 @@ +> { "req_id": "|1|", "op": "subscribe", "args": [ "publicTrade.BTCUSDT" ] } +< { "success": true, "ret_msg": "subscribe", "conn_id": "2324d924-aa4d-45b0-a858-7b8be29ab52b", "req_id": "|1|", "op": "subscribe" } += +{ + "topic": "publicTrade.BTCUSDT", + "type": "snapshot", + "ts": 1672304486868, + "data": [ + { + "T": 1672304486865, + "s": "BTCUSDT", + "S": "Buy", + "v": "0.001", + "p": "16578.50", + "L": "PlusTick", + "i": "20f43950-d8dd-5b31-9112-a178eb6023af", + "BT": false + } + ] +} \ No newline at end of file diff --git a/Bybit.UnitTests/TestHelpers.cs b/Bybit.UnitTests/TestHelpers.cs index ac233cdf..7ad3c24d 100644 --- a/Bybit.UnitTests/TestHelpers.cs +++ b/Bybit.UnitTests/TestHelpers.cs @@ -18,46 +18,6 @@ namespace Bybit.UnitTests { public class TestHelpers { - [ExcludeFromCodeCoverage] - public static bool PublicInstancePropertiesEqual(T self, T to, params string[] ignore) where T : class - { - if (self != null && to != null) - { - var type = self.GetType(); - var ignoreList = new List(ignore); - foreach (var pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) - { - if (ignoreList.Contains(pi.Name)) - { - continue; - } - - var selfValue = type.GetProperty(pi.Name).GetValue(self, null); - var toValue = type.GetProperty(pi.Name).GetValue(to, null); - - if (pi.PropertyType.IsClass && !pi.PropertyType.Module.ScopeName.Equals("System.Private.CoreLib.dll")) - { - // Check of "CommonLanguageRuntimeLibrary" is needed because string is also a class - if (PublicInstancePropertiesEqual(selfValue, toValue, ignore)) - { - continue; - } - - return false; - } - - if (selfValue != toValue && (selfValue == null || !selfValue.Equals(toValue))) - { - return false; - } - } - - return true; - } - - return self == to; - } - public static BybitRestClient CreateClient(Action options = null) { BybitRestClient client;