9
9
using System . Linq ;
10
10
using BitMart . Net . Enums ;
11
11
using System . Drawing ;
12
+ using CryptoExchange . Net . Authentication ;
12
13
13
14
namespace BitMart . Net . UnitTests
14
15
{
@@ -21,9 +22,9 @@ public async Task ValidateSpotAccountDataCalls()
21
22
var client = new BitMartRestClient ( opts =>
22
23
{
23
24
opts . AutoTimestamp = false ;
24
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
25
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
25
26
} ) ;
26
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/Account" , "https://api-cloud.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
27
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/Account" , "https://api-cloud.bitmart.com" , IsAuthenticated ) ;
27
28
await tester . ValidateAsync ( client => client . SpotApi . Account . GetFundingBalancesAsync ( "123" ) , "GetFundingBalances" , nestedJsonProperty : "data.wallet" ) ;
28
29
await tester . ValidateAsync ( client => client . SpotApi . Account . GetSpotBalancesAsync ( ) , "GetSpotBalances" , nestedJsonProperty : "data.wallet" ) ;
29
30
await tester . ValidateAsync ( client => client . SpotApi . Account . GetDepositAddressAsync ( "123" ) , "GetDepositAddress" , nestedJsonProperty : "data" ) ;
@@ -42,9 +43,9 @@ public async Task ValidateSpotExchangeDataCalls()
42
43
var client = new BitMartRestClient ( opts =>
43
44
{
44
45
opts . AutoTimestamp = false ;
45
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
46
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
46
47
} ) ;
47
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/ExchangeData" , "https://api-cloud.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
48
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/ExchangeData" , "https://api-cloud.bitmart.com" , IsAuthenticated ) ;
48
49
await tester . ValidateAsync ( client => client . SpotApi . ExchangeData . GetTickerAsync ( "123" ) , "GetTicker" , nestedJsonProperty : "data" ) ;
49
50
await tester . ValidateAsync ( client => client . SpotApi . ExchangeData . GetAssetDepositWithdrawInfoAsync ( ) , "GetAssetDepositWithdrawInfo" , nestedJsonProperty : "data.currencies" ) ;
50
51
await tester . ValidateAsync ( client => client . SpotApi . ExchangeData . GetServerStatusAsync ( ) , "GetServerStatus" , nestedJsonProperty : "data.service" ) ;
@@ -60,9 +61,9 @@ public async Task ValidateSpotMarginDataCalls()
60
61
var client = new BitMartRestClient ( opts =>
61
62
{
62
63
opts . AutoTimestamp = false ;
63
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
64
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
64
65
} ) ;
65
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/Margin" , "https://api-cloud.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
66
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/Margin" , "https://api-cloud.bitmart.com" , IsAuthenticated ) ;
66
67
await tester . ValidateAsync ( client => client . SpotApi . Margin . BorrowAsync ( "123" , "123" , 0.1m ) , "Borrow" , nestedJsonProperty : "data" ) ;
67
68
await tester . ValidateAsync ( client => client . SpotApi . Margin . RepayAsync ( "123" , "123" , 0.1m ) , "Repay" , nestedJsonProperty : "data" ) ;
68
69
await tester . ValidateAsync ( client => client . SpotApi . Margin . GetBorrowHistoryAsync ( "123" ) , "GetBorrowHistory" , nestedJsonProperty : "data.records" ) ;
@@ -76,9 +77,9 @@ public async Task ValidateSpotSubAccountCalls()
76
77
var client = new BitMartRestClient ( opts =>
77
78
{
78
79
opts . AutoTimestamp = false ;
79
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
80
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
80
81
} ) ;
81
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/SubAccount" , "https://api-cloud.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
82
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/SubAccount" , "https://api-cloud.bitmart.com" , IsAuthenticated ) ;
82
83
await tester . ValidateAsync ( client => client . SpotApi . SubAccount . TransferSubToMainForMainAsync ( "123" , "123" , 0.1m , "123" ) , "TransferSubToMainForMain" ) ;
83
84
await tester . ValidateAsync ( client => client . SpotApi . SubAccount . TransferSubToMainForSubAsync ( "123" , "123" , 0.1m ) , "TransferSubToMainForSub" ) ;
84
85
await tester . ValidateAsync ( client => client . SpotApi . SubAccount . TransferMainToSubAccountAsync ( "123" , "123" , 0.1m , "123" ) , "TransferMainToSubAccount" ) ;
@@ -95,9 +96,9 @@ public async Task ValidateSpotTradingDataCalls()
95
96
var client = new BitMartRestClient ( opts =>
96
97
{
97
98
opts . AutoTimestamp = false ;
98
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
99
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
99
100
} ) ;
100
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/Trading" , "https://api-cloud.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
101
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/Spot/Trading" , "https://api-cloud.bitmart.com" , IsAuthenticated ) ;
101
102
await tester . ValidateAsync ( client => client . SpotApi . Trading . PlaceOrderAsync ( "123" , OrderSide . Buy , OrderType . Market ) , "PlaceOrder" , nestedJsonProperty : "data" ) ;
102
103
await tester . ValidateAsync ( client => client . SpotApi . Trading . CancelOrderAsync ( "123" ) , "CancelOrder" ) ;
103
104
await tester . ValidateAsync ( client => client . SpotApi . Trading . PlaceMarginOrderAsync ( "123" , OrderSide . Buy , OrderType . Market ) , "PlaceMarginOrder" , nestedJsonProperty : "data" ) ;
@@ -117,13 +118,15 @@ public async Task ValidateUsdFuturesAccountCalls()
117
118
var client = new BitMartRestClient ( opts =>
118
119
{
119
120
opts . AutoTimestamp = false ;
120
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
121
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
121
122
} ) ;
122
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/Account" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
123
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/Account" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated ) ;
123
124
//await tester.ValidateAsync(client => client.UsdFuturesApi.Account.GetBalancesAsync(), "GetBalances", nestedJsonProperty: "data");
124
125
await tester . ValidateAsync ( client => client . UsdFuturesApi . Account . GetTransferHistoryAsync ( ) , "GetTransferHistory" , nestedJsonProperty : "data.records" ) ;
125
126
await tester . ValidateAsync ( client => client . UsdFuturesApi . Account . TransferAsync ( "123" , 0.1m , FuturesTransferType . ContractToSpot ) , "Transfer" , nestedJsonProperty : "data" ) ;
126
127
await tester . ValidateAsync ( client => client . UsdFuturesApi . Account . SetLeverageAsync ( "123" , 0.1m , MarginType . CrossMargin ) , "SetLeverage" , nestedJsonProperty : "data" ) ;
128
+ await tester . ValidateAsync ( client => client . UsdFuturesApi . Account . GetPositionModeAsync ( ) , "GetPositionMode" , nestedJsonProperty : "data" ) ;
129
+ await tester . ValidateAsync ( client => client . UsdFuturesApi . Account . SetPositionModeAsync ( PositionMode . HedgeMode ) , "SetPositionMode" , nestedJsonProperty : "data" ) ;
127
130
}
128
131
129
132
[ Test ]
@@ -132,9 +135,9 @@ public async Task ValidateUsdFuturesExchangeDataCalls()
132
135
var client = new BitMartRestClient ( opts =>
133
136
{
134
137
opts . AutoTimestamp = false ;
135
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
138
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
136
139
} ) ;
137
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/ExchangeData" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
140
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/ExchangeData" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated ) ;
138
141
await tester . ValidateAsync ( client => client . UsdFuturesApi . ExchangeData . GetContractsAsync ( ) , "GetContracts" , nestedJsonProperty : "data.symbols" ) ;
139
142
await tester . ValidateAsync ( client => client . UsdFuturesApi . ExchangeData . GetOrderBookAsync ( "123" ) , "GetOrderBook" , nestedJsonProperty : "data" ) ;
140
143
await tester . ValidateAsync ( client => client . UsdFuturesApi . ExchangeData . GetOpenInterestAsync ( "123" ) , "GetOpenInterest" , nestedJsonProperty : "data" ) ;
@@ -149,9 +152,9 @@ public async Task ValidateUsdFuturesSubAccountCalls()
149
152
var client = new BitMartRestClient ( opts =>
150
153
{
151
154
opts . AutoTimestamp = false ;
152
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
155
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
153
156
} ) ;
154
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/SubAccount" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
157
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/SubAccount" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated ) ;
155
158
await tester . ValidateAsync ( client => client . UsdFuturesApi . SubAccount . TransferSubToMainForMainAsync ( "123" , 0.1m , "123" , "123" ) , "TransferSubToMainForMain" ) ;
156
159
await tester . ValidateAsync ( client => client . UsdFuturesApi . SubAccount . TransferMainToSubForMainAsync ( "123" , 0.1m , "123" , "123" ) , "TransferMainToSubForMain" ) ;
157
160
await tester . ValidateAsync ( client => client . UsdFuturesApi . SubAccount . TransferSubToMainForSubAsync ( "123" , 0.1m , "123" ) , "TransferSubToMainForSub" ) ;
@@ -166,9 +169,9 @@ public async Task ValidateUsdFuturesTradingCalls()
166
169
var client = new BitMartRestClient ( opts =>
167
170
{
168
171
opts . AutoTimestamp = false ;
169
- opts . ApiCredentials = new BitMartApiCredentials ( "123" , "456" , "XXX" ) ;
172
+ opts . ApiCredentials = new ApiCredentials ( "123" , "456" , "XXX" ) ;
170
173
} ) ;
171
- var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/Trading" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated , stjCompare : true ) ;
174
+ var tester = new RestRequestValidator < BitMartRestClient > ( client , "Endpoints/UsdFutures/Trading" , "https://api-cloud-v2.bitmart.com" , IsAuthenticated ) ;
172
175
await tester . ValidateAsync ( client => client . UsdFuturesApi . Trading . GetOrderAsync ( "123" , "123" ) , "GetOrder" , nestedJsonProperty : "data" ) ;
173
176
await tester . ValidateAsync ( client => client . UsdFuturesApi . Trading . GetClosedOrdersAsync ( "123" ) , "GetClosedOrders" , nestedJsonProperty : "data" ) ;
174
177
await tester . ValidateAsync ( client => client . UsdFuturesApi . Trading . GetOpenOrdersAsync ( ) , "GetOpenOrders" , nestedJsonProperty : "data" ) ;
@@ -186,6 +189,7 @@ public async Task ValidateUsdFuturesTradingCalls()
186
189
await tester . ValidateAsync ( client => client . UsdFuturesApi . Trading . EditTpSlOrderAsync ( "123" , 0.1m , TriggerPriceType . FairPrice , PlanCategory . PositionTpSl , OrderType . Market ) , "EditTpSlOrder" , nestedJsonProperty : "data" ) ;
187
190
await tester . ValidateAsync ( client => client . UsdFuturesApi . Trading . EditTriggerOrderAsync ( "123" , 0.1m , TriggerPriceType . FairPrice , OrderType . Market ) , "EditPlanOrder" , nestedJsonProperty : "data" ) ;
188
191
await tester . ValidateAsync ( client => client . UsdFuturesApi . Trading . EditPresetTriggerOrderAsync ( "123" , "123" , TriggerPriceType . FairPrice , TriggerPriceType . FairPrice , 0.1m , 0.1m ) , "EditPresetPlanOrder" , nestedJsonProperty : "data" ) ;
192
+ await tester . ValidateAsync ( client => client . UsdFuturesApi . Trading . CancelAllAfterAsync ( "ETHUSDT" , TimeSpan . Zero ) , "CancelAllAfter" , nestedJsonProperty : "data" ) ;
189
193
}
190
194
191
195
private bool IsAuthenticated ( WebCallResult result )
0 commit comments