@@ -54,30 +54,50 @@ Example
5454``` java
5555import com.bitmart.api.Call ;
5656import com.bitmart.api.CloudContext ;
57+ import com.bitmart.api.common.CloudException ;
58+ import com.bitmart.api.common.CloudResponse ;
59+ import com.bitmart.api.request.spot.pub.market.* ;
5760
58- public class TestSpotMarket {
61+ public class Market {
5962
60- public static void main (String [] args ) {
63+ public static void main (String [] args ) throws CloudException {
6164 Call call = new Call (new CloudContext ());
62-
65+
6366 // Get Ticker of a Trading Pair (V3)
64- call. callCloud(new V3TickerRequest (). setSymbol(" BTC_USDT" ));
65-
67+ CloudResponse cloudResponse = call. callCloud(new V3TickerRequest (). setSymbol(" BTC_USDT" ));
68+ System . out. println(cloudResponse. getResponseContent());
69+
6670 // Get Ticker of All Pairs (V3)
67- call. callCloud(new V3TickersRequest ());
68-
71+ cloudResponse = call. callCloud(new V3TickersRequest ());
72+ System . out. println(cloudResponse. getResponseContent());
73+
6974 // Get Depth (V3)
70- call. callCloud(new V3DepthRequest (). setSymbol(" BTC_USDT" ). setLimit(10 ));
71-
72- }
75+ cloudResponse = call. callCloud(new V3DepthRequest (). setSymbol(" BTC_USDT" ). setLimit(10 ));
76+ System . out. println(cloudResponse. getResponseContent());
7377
78+ // Get Latest K-Line (V3)
79+ cloudResponse = call. callCloud(new V3HistoryKlineRequest (). setSymbol(" BTC_USDT" ));
80+ System . out. println(cloudResponse. getResponseContent());
81+
82+ // Get History K-Line (V3)
83+ cloudResponse = call. callCloud(new V3LatestKlineRequest (). setSymbol(" BTC_USDT" ));
84+ System . out. println(cloudResponse. getResponseContent());
85+
86+ // Get Recent Trades (V3)
87+ cloudResponse = call. callCloud(new V3TradeRequest (). setSymbol(" BTC_USDT" ));
88+ System . out. println(cloudResponse. getResponseContent());
89+ }
7490}
7591```
7692
7793#### Spot Trade API Example
7894``` java
7995import com.bitmart.api.Call ;
8096import com.bitmart.api.CloudContext ;
97+ import com.bitmart.api.common.CloudException ;
98+ import com.bitmart.api.common.CloudResponse ;
99+ import com.bitmart.api.key.CloudKey ;
100+ import com.bitmart.api.request.spot.prv.SubmitOrderRequest ;
81101
82102public class TestSpotTrading {
83103
@@ -88,15 +108,18 @@ public class TestSpotTrading {
88108 public static void main (String [] args ) {
89109 CloudContext cloudContext = new CloudContext (new CloudKey (API_KEY , API_SECRET , API_MEMO ));
90110 Call call = new Call (cloudContext);
91-
92- CloudResponse cloudResponse = call. callCloud(new SubmitOrderRequest ()
93- .setSide(" sell" )
94- .setType(" limit" )
95- .setSymbol(" BTC_USDT" )
96- .setPrice(" 800000" )
97- .setSize(" 100" ));
98-
99- System . out. println(cloudResponse);
111+ try {
112+ CloudResponse cloudResponse = call. callCloud(new SubmitOrderRequest ()
113+ .setSide(" sell" )
114+ .setType(" limit" )
115+ .setSymbol(" BTC_USDT" )
116+ .setPrice(" 800000" )
117+ .setSize(" 100" ));
118+ System . out. println(cloudResponse);
119+
120+ } catch (CloudException e) {
121+ System . out. println(" Error:" + e. getMessage());
122+ }
100123 }
101124
102125}
@@ -188,23 +211,38 @@ public class TestWebSocket {
188211``` java
189212import com.bitmart.api.Call ;
190213import com.bitmart.api.CloudContext ;
214+ import com.bitmart.api.common.CloudException ;
215+ import com.bitmart.api.common.CloudResponse ;
216+ import com.bitmart.api.request.contract.pub.DepthRequest ;
217+ import com.bitmart.api.request.contract.pub.DetailsRequest ;
218+ import com.bitmart.api.request.contract.pub.FundingRateRequest ;
219+ import com.bitmart.api.request.contract.pub.OpenInterestRequest ;
220+ import com.bitmart.api.request.spot.pub.market.V3TradeRequest ;
191221
192222public class TestFuturesMarket {
193223
194224 public static void main (String [] args ) {
195225 Call call = new Call (new CloudContext ());
196-
226+
197227 // Get Contract Details
198- call. callCloud(new DetailsRequest (). setSymbol(" ETHUSDT" ));
199-
228+ CloudResponse cloudResponse = call. callCloud(new DetailsRequest (). setSymbol(" ETHUSDT" ));
229+ System . out. println(cloudResponse. getResponseContent());
230+
200231 // Get Market Depth
201- call. callCloud(new DepthRequest (). setSymbol(" ETHUSDT" ));
202-
232+ cloudResponse = call. callCloud(new DepthRequest (). setSymbol(" ETHUSDT" ));
233+ System . out. println(cloudResponse. getResponseContent());
234+
203235 // Get Futures Open Interest
204- call. callCloud(new OpenInterestRequest (). setSymbol(" ETHUSDT" ));
205-
236+ cloudResponse = call. callCloud(new OpenInterestRequest (). setSymbol(" ETHUSDT" ));
237+ System . out. println(cloudResponse. getResponseContent());
238+
206239 // Get Current Funding Rate
207- call. callCloud(new FundingRateRequest (). setSymbol(" ETHUSDT" ));
240+ cloudResponse = call. callCloud(new FundingRateRequest (). setSymbol(" ETHUSDT" ));
241+ System . out. println(cloudResponse. getResponseContent());
242+
243+ // Get Recent Trades (V3)
244+ cloudResponse = call. callCloud(new V3TradeRequest (). setSymbol(" BTC_USDT" ));
245+ System . out. println(cloudResponse. getResponseContent());
208246 }
209247
210248}
@@ -213,6 +251,13 @@ public class TestFuturesMarket {
213251#### Futures API Example
214252
215253``` java
254+ import com.bitmart.api.Call ;
255+ import com.bitmart.api.CloudContext ;
256+ import com.bitmart.api.common.CloudException ;
257+ import com.bitmart.api.common.CloudResponse ;
258+ import com.bitmart.api.key.CloudKey ;
259+ import com.bitmart.api.request.contract.prv.SubmitOrderRequest ;
260+
216261public class TestFuturesTrading {
217262
218263 private static String API_KEY = " YOUR ACCESS KEY" ;
@@ -223,16 +268,20 @@ public class TestFuturesTrading {
223268 CloudContext cloudContext = new CloudContext (new CloudKey (API_KEY , API_SECRET , API_MEMO ));
224269 Call call = new Call (cloudContext);
225270
226- final CloudResponse cloudResponse = call. callCloud(new SubmitOrderRequest ()
227- .setSymbol(" ETHUSDT" )
228- .setType(" limit" )
229- .setSide(4 )
230- .setLeverage(" 1" )
231- .setOpen_type(" isolated" )
232- .setSize(1000 )
233- .setPrice(" 200000" ));
234-
235- System . out. println(cloudResponse);
271+ try {
272+ CloudResponse cloudResponse = call. callCloud(new SubmitOrderRequest ()
273+ .setSymbol(" ETHUSDT" )
274+ .setType(" limit" )
275+ .setSide(4 )
276+ .setLeverage(" 1" )
277+ .setOpenType(" isolated" )
278+ .setSize(1000 )
279+ .setPrice(" 200000" ));
280+ System . out. println(cloudResponse);
281+
282+ } catch (CloudException e) {
283+ System . out. println(" Error:" + e. getMessage());
284+ }
236285 }
237286
238287}
@@ -334,6 +383,39 @@ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
334383
335384If you prefer to not use a logger and suppress the ` SLF4J ` messages instead, you can refer to ` slf4j-nop ` .
336385
386+ #### Here is an example using logback-classic
387+
388+ Taking Maven project as an example,
389+ you should introduce the log package in the ` pom.xml ` file, as follows:
390+
391+ ``` xml
392+ <dependency >
393+ <groupId >ch.qos.logback</groupId >
394+ <artifactId >logback-classic</artifactId >
395+ <version >1.2.11</version >
396+ </dependency >
397+ ```
398+
399+ Then add ` logback.xml ` to your project ` resource directory ` , after completion you will not encounter SLF4J prompt output.
400+
401+
402+ ``` xml
403+ <configuration >
404+
405+ <appender name =" STDOUT" class =" ch.qos.logback.core.ConsoleAppender" >
406+ <encoder >
407+ <pattern >%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern >
408+ </encoder >
409+ </appender >
410+
411+ <root level =" INFO" >
412+ <appender-ref ref =" STDOUT" />
413+ </root >
414+
415+ </configuration >
416+ ```
417+
418+
337419
338420### Timeout
339421After initializing the CloudContext, you can set the OkHttpClient timeout.
0 commit comments