1 package org.oxerr.peatio.rest; 2 3 import java.io.IOException; 4 import java.math.BigDecimal; 5 import java.util.Map; 6 7 import javax.ws.rs.FormParam; 8 import javax.ws.rs.GET; 9 import javax.ws.rs.POST; 10 import javax.ws.rs.Path; 11 import javax.ws.rs.PathParam; 12 import javax.ws.rs.QueryParam; 13 14 import org.oxerr.peatio.rest.dto.Deposit; 15 import org.oxerr.peatio.rest.dto.Depth; 16 import org.oxerr.peatio.rest.dto.KWithPendingTrades; 17 import org.oxerr.peatio.rest.dto.Market; 18 import org.oxerr.peatio.rest.dto.MarketTicker; 19 import org.oxerr.peatio.rest.dto.Member; 20 import org.oxerr.peatio.rest.dto.Order; 21 import org.oxerr.peatio.rest.dto.OrderBook; 22 import org.oxerr.peatio.rest.dto.Trade; 23 24 import si.mazi.rescu.ParamsDigest; 25 import si.mazi.rescu.SynchronizedValueFactory; 26 27 @Path("/api/v2/") 28 public interface Peatio { 29 30 /** 31 * Get all available markets. 32 * 33 * @return all available markets. 34 * @throws PeatioException indicates peatio exchange exception. 35 * @throws IOException indicates I/O exception. 36 */ 37 @GET 38 @Path("markets.json") 39 Market[] getMarkets() throws PeatioException, IOException; 40 41 /** 42 * Get ticker of all markets. 43 * 44 * @return ticker of all markets. 45 * @throws PeatioException indicates peatio exchange exception. 46 * @throws IOException indicates I/O exception. 47 */ 48 @GET 49 @Path("tickers.json") 50 Map<String, MarketTicker> getTickers() 51 throws PeatioException, IOException; 52 53 /** 54 * Get ticker of specific market. 55 * 56 * @param market unique market id. It's always in the form of xxxyyy, 57 * where xxx is the base currency code, yyy is the quote currency code, 58 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 59 * @return the ticker of the specific market. 60 * @throws PeatioException indicates peatio exchange exception. 61 * @throws IOException indicates I/O exception. 62 */ 63 @GET 64 @Path("tickers/{market}.json") 65 MarketTicker getTicker( 66 @PathParam("market") String market) 67 throws PeatioException, IOException; 68 69 /** 70 * Get your profile and accounts info. 71 * 72 * @param accessKey access key. 73 * @param tonce tonce is an integer represents the milliseconds elapsed 74 * since Unix epoch. 75 * @param signature the signature of you request payload, generated 76 * using your secret key. 77 * @return your profile and accounts info. 78 * @throws PeatioException indicates peatio exchange exception. 79 * @throws IOException indicates I/O exception. 80 */ 81 @GET 82 @Path("members/me.json") 83 Member getMe( 84 @QueryParam("access_key") String accessKey, 85 @QueryParam("tonce") SynchronizedValueFactory<Long> tonce, 86 @QueryParam("signature") ParamsDigest signature) 87 throws PeatioException, IOException; 88 89 /** 90 * Get your deposits information. 91 * 92 * @param accessKey access key. 93 * @param tonce tonce is an integer represents the milliseconds elapsed 94 * since Unix epoch. 95 * @param signature the signature of your request payload, generated 96 * using your secret key. 97 * @param currency currency value. 98 * @return deposits information. 99 * @throws PeatioException indicates peatio exchange exception. 100 * @throws IOException indicates I/O exception. 101 */ 102 @GET 103 @Path("deposits.json") 104 Deposit[] getDeposits( 105 @QueryParam("access_key") String accessKey, 106 @QueryParam("tonce") SynchronizedValueFactory<Long> tonce, 107 @QueryParam("signature") ParamsDigest signature, 108 @QueryParam("currency") String currency) 109 throws PeatioException, IOException; 110 111 /** 112 * Get single deposit information. 113 * 114 * @param accessKey access key. 115 * @param tonce tonce is an integer represents the milliseconds elapsed 116 * since Unix epoch. 117 * @param signature the signature of your request payload, generated 118 * using your secret key. 119 * @param txid the transaction id. 120 * @return single deposit information. 121 * @throws PeatioException indicates peatio exchange exception. 122 * @throws IOException indicates I/O exception. 123 */ 124 @GET 125 @Path("deposit.json") 126 Deposit getDeposit( 127 @QueryParam("access_key") String accessKey, 128 @QueryParam("tonce") SynchronizedValueFactory<Long> tonce, 129 @QueryParam("signature") ParamsDigest signature, 130 @QueryParam("txid") String txid) 131 throws PeatioException, IOException; 132 133 /** 134 * Get your orders. 135 * 136 * @param accessKey access key. 137 * @param tonce tonce is an integer represents the milliseconds elaapsed 138 * since Unix epoch. 139 * @param signature the signature of your request payload, generated 140 * using your secret key. 141 * @param market unique market id. It's always in the form of xxxyyy, 142 * where xxx is the base currency code, yyy is the quote currency code, 143 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 144 * @param state filter order by state, default to 'wait'(active orders). 145 * @param limit limit the number of returned orders, default to 10. 146 * @param page specify the page of paginated results. 147 * @param orderBy if set, returned orders will be sorted in specific order, 148 * default to 'asc'. 149 * @return your orders. 150 * @throws PeatioException indicates peatio exchange exception. 151 * @throws IOException indicates I/O exception. 152 */ 153 @GET 154 @Path("orders.json") 155 Order[] getOrders( 156 @QueryParam("access_key") String accessKey, 157 @QueryParam("tonce") SynchronizedValueFactory<Long> tonce, 158 @QueryParam("signature") ParamsDigest signature, 159 @QueryParam("market") String market, 160 @QueryParam("state") String state, 161 @QueryParam("limit") Integer limit, 162 @QueryParam("page") Integer page, 163 @QueryParam("order_by") String orderBy) 164 throws PeatioException, IOException; 165 166 /** 167 * Create a sell/buy order. 168 * 169 * @param accessKey access key. 170 * @param tonce tonce is an integer represents the milliseconds elapsed 171 * since Unix epoch. 172 * @param signature the signature of your request payload, generated 173 * using your secret key. 174 * @param market unique market id. It's always in the form of xxxyyy, 175 * where xxx is the base currency code, yyy is the quote currency code, 176 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 177 * @param side either 'sell' or 'buy'. 178 * @param volume the amount user want to sell/buy. Ano order could be 179 * partially executed, e.g. an order sell 5 btc can be matched with 180 * a buy 3 btc order, left 2 btc to be sold; in this case the order's 181 * volume would be '5.0', its remaining_volume would be '2.0', its executed 182 * volume is '3.0'. 183 * @param price price for each unit. e.g. if you want to sell/buy 1 btc at 184 * 3000 CNY, the price is '3000.0'. 185 * @param ordType the order type. 186 * @return the order which created in this call. 187 * @throws PeatioException indicates peatio exchange exception. 188 * @throws IOException indicates I/O exception. 189 */ 190 @POST 191 @Path("orders.json") 192 Order placeOrder( 193 @FormParam("access_key") String accessKey, 194 @FormParam("tonce") SynchronizedValueFactory<Long> tonce, 195 @FormParam("signature") ParamsDigest signature, 196 @FormParam("market") String market, 197 @FormParam("side") String side, 198 @FormParam("volume") BigDecimal volume, 199 @FormParam("price") BigDecimal price, 200 @FormParam("ord_type") String ordType) 201 throws PeatioException, IOException; 202 203 /** 204 * Create multiple sell/buy orders. 205 * 206 * @param accessKey access key. 207 * @param tonce tonce is an integer represents the milliseconds elapsed 208 * since Unix epoch. 209 * @param signature the signature of your request payload, generated using 210 * your secret key. 211 * @param market unique market id. It's always in the form of xxxyyy, 212 * where xxx is the base currency code, yyy is the quote 213 * currency code, e.g. 'btccny'. All available markets can be 214 * found at {@link #getMarkets()}. 215 * @param sides either 'sell' or 'buy'. 216 * @param volumes the amount user want to sell/buy. Ano order could be 217 * partially executed, e.g. an order sell 5 btc can be matched with 218 * a buy 3 btc order, left 2 btc to be sold; in this case the order's 219 * volume would be '5.0', its remaining_volume would be '2.0', its executed 220 * volume is '3.0'. 221 * @param prices price for each unit. e.g. if you want to sell/buy 1 btc at 222 * 3000 CNY, the price is '3000.0'. 223 * @param ordTypes the order types. 224 * @return the orders which created in this call. 225 * @throws PeatioException indicates peatio exchange exception. 226 * @throws IOException indicates I/O exception. 227 */ 228 @POST 229 @Path("orders/multi.json") 230 Order[] placeMultiOrders( 231 @FormParam("access_key") String accessKey, 232 @FormParam("tonce") SynchronizedValueFactory<Long> tonce, 233 @FormParam("signature") ParamsDigest signature, 234 @FormParam("market") String market, 235 @FormParam("orders[side]") String[] sides, 236 @FormParam("orders[volume]") BigDecimal[] volumes, 237 @FormParam("orders[price]") BigDecimal[] prices, 238 @FormParam("orders[ord_type]") String[] ordTypes) 239 throws PeatioException, IOException; 240 241 /** 242 * Cancel all my orders. 243 * 244 * @param accessKey access key. 245 * @param tonce tonce is an integer represents the milliseconds elapsed 246 * since Unix epoch. 247 * @param signature the signature of your request payload. 248 * @return the orders which cancelled in this call. 249 * @throws PeatioException indicates peatio exchange exception. 250 * @throws IOException indicates I/O exception. 251 */ 252 @POST 253 @Path("orders/clear.json") 254 Order[] clear( 255 @FormParam("access_key") String accessKey, 256 @FormParam("tonce") SynchronizedValueFactory<Long> tonce, 257 @FormParam("signature") ParamsDigest signature) 258 throws PeatioException, IOException; 259 260 /** 261 * Get information of specified order. 262 * 263 * @param accessKey access key. 264 * @param tonce tonce is an integer represents the milliseconds elapsed 265 * since Unix epoch. 266 * @param signature the signature of your request payload, genereated 267 * using your secret key. 268 * @param id unique order id. 269 * @return order information of specified order. 270 * @throws PeatioException indicates peatio exchange exception. 271 * @throws IOException indicates I/O exception. 272 */ 273 @GET 274 @Path("order.json") 275 Order getOrder( 276 @QueryParam("access_key") String accessKey, 277 @QueryParam("tonce") SynchronizedValueFactory<Long> tonce, 278 @QueryParam("signature") ParamsDigest signature, 279 @QueryParam("id") long id) 280 throws PeatioException, IOException; 281 282 /** 283 * Cancel an order. 284 * 285 * @param accessKey access key. 286 * @param tonce tonce is an integer represents the milliseconds elapsed 287 * since Unix epoch. 288 * @param signature the signature of your request payload, generated 289 * using your secret key. 290 * @param id unique order id. 291 * @return the order has been deleted. 292 * The order state is the value before we deleting it. 293 * @throws PeatioException indicates peatio exchange exception. 294 * @throws IOException indicates I/O exception. 295 */ 296 @POST 297 @Path("order/delete.json") 298 Order deleteOrder( 299 @QueryParam("access_key") String accessKey, 300 @QueryParam("tonce") SynchronizedValueFactory<Long> tonce, 301 @QueryParam("signature") ParamsDigest signature, 302 @QueryParam("id") long id) 303 throws PeatioException, IOException; 304 305 /** 306 * Get the order book of specified market. 307 * 308 * @param market unique market id. It's always in the form of xxxyyy, 309 * where xxx is the base currency code, yyy is the quote currency code, 310 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 311 * @param asksLimit limit the number of returned sell orders. Default to 20. 312 * @param bidsLimit limit the number of returned buy orders. Default to 20. 313 * @return the order book of the specified market. 314 * @throws PeatioException indicates peatio exchange exception. 315 * @throws IOException indicates I/O exception. 316 */ 317 @GET 318 @Path("order_book.json") 319 OrderBook getOrderBook( 320 @QueryParam("market") String market, 321 @QueryParam("asks_limit") Integer asksLimit, 322 @QueryParam("bids_limit") Integer bidsLimit) 323 throws PeatioException, IOException; 324 325 /** 326 * Get depth of specified market. Both asks and bids are sorted from 327 * highest price to lowest. 328 * 329 * @param market unique market id. It's always in the form of xxxyyy, 330 * where xxx is the base currency code, yyy is the quote currency code, 331 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 332 * @param limit limit the number of returned price levels. Default to 300. 333 * @return the depth of the specified market. 334 * @throws PeatioException indicates peatio exchange exception. 335 * @throws IOException indicates I/O exception. 336 */ 337 @GET 338 @Path("depth.json") 339 Depth getDepth( 340 @QueryParam("market") String market, 341 @QueryParam("limit") Integer limit) 342 throws PeatioException, IOException; 343 344 /** 345 * Get recent trades on market, each trade is included only once. 346 * Trades are sorted in reverse creation order. 347 * 348 * @param market unique market id. It's always in the form of xxxyyy, 349 * where xxx is the base currency code, yyy is the quote currency code, 350 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 351 * @param limit limit the number of returned trades. Default to 50. 352 * @param timestamp an integer represents the seconds elapsed since Unix epoch. 353 * If set, only trades executed before the time will be returned. 354 * @param from trade id. 355 * If set, only trades created after the trade will be returned. 356 * @param to trade id. 357 * If set, only trades created before the trade will be returned. 358 * @param orderBy if set, returned trades will be sorted in specific order, 359 * default to 'desc'. 360 * @return the recent trades on the specified market. 361 * @throws PeatioException indicates peatio exchange exception. 362 * @throws IOException indicates I/O exception. 363 */ 364 @GET 365 @Path("trades.json") 366 Trade[] getTrades( 367 @QueryParam("market") String market, 368 @QueryParam("limit") Integer limit, 369 @QueryParam("timestamp") Long timestamp, 370 @QueryParam("from") Integer from, 371 @QueryParam("to") Integer to, 372 @QueryParam("order_by") String orderBy) 373 throws PeatioException, IOException; 374 375 /** 376 * Get your executed trades. Trades are sorted in reverse creation order. 377 * 378 * @param accessKey access key. 379 * @param tonce tonce is an integer represents the milliseconds elapsed 380 * since Unix epoch. 381 * @param signature the signature of your request payload, generated 382 * using your secret key. 383 * @param market unique market id. It's always in the form of xxxyyy, 384 * where xxx is the base currency code, yyy is the quote currency code, 385 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 386 * @param limit limit the number of returned trades. Default to 50. 387 * @param timestamp an integer represents the seconds elapsed since Unix epoch. 388 * If set, only trades executed before the time will be returned. 389 * @param from trade id. 390 * If set, only trades created after the trade will be returned. 391 * @param to trade id. 392 * If set, only trades created before the trade will be returned. 393 * @param orderBy if set, returned trades will be sorted in specific order, 394 * default to 'desc'. 395 * @return your executed trades. 396 * @throws PeatioException indicates peatio exchange exception. 397 * @throws IOException indicates I/O exception. 398 */ 399 @GET 400 @Path("trades/my.json") 401 Trade[] getMyTrades( 402 @QueryParam("access_key") String accessKey, 403 @QueryParam("tonce") SynchronizedValueFactory<Long> tonce, 404 @QueryParam("signature") ParamsDigest signature, 405 @QueryParam("market") String market, 406 @QueryParam("limit") Integer limit, 407 @QueryParam("timestamp") Long timestamp, 408 @QueryParam("from") Long from, 409 @QueryParam("to") Long to, 410 @QueryParam("order_by") String orderBy) 411 throws PeatioException, IOException; 412 413 /** 414 * Get OHLC(k line) of specified market. 415 * 416 * @param market unique market id. It's always in the form of xxxyyy, 417 * where xxx is the base currency code, yyy is the quote currency code, 418 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 419 * @param limit limit the number of returned data points, default to 30. 420 * @param period time period of K line, default to 1. 421 * You can choose from 1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10080. 422 * @param timestamp an integer represents the seconds elapsed since Unix epoch. 423 * If set, only k-line data after that time will be returned. 424 * @return the OHLC of the specified market. 425 * @throws PeatioException indicates peatio exchange exception. 426 * @throws IOException indicates I/O exception. 427 */ 428 @GET 429 @Path("k.json") 430 BigDecimal[][] getK( 431 @QueryParam("market") String market, 432 @QueryParam("limit") Integer limit, 433 @QueryParam("period") Integer period, 434 @QueryParam("timestamp") Long timestamp) 435 throws PeatioException, IOException; 436 437 /** 438 * Get K data with pending trades, which are the trades not included 439 * in K data yet, because there's delay between trade generated and 440 * processed by K data generator. 441 * 442 * @param market unique market id. It's always in the form of xxxyyy, 443 * where xxx is the base currency code, yyy is the quote currency code, 444 * e.g. 'btccny'. All available markets can be found at {@link #getMarkets()}. 445 * @param tradeId the trade id of the first trade you received. 446 * @param limit limite the number of returned data points, default to 30. 447 * @param period time period of K line, default to 1. You can choose from 448 * 1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10080. 449 * @param timestamp an integer represents the seconds elapsed since Unix epoch. 450 * If set, only k-line data after that time will be returned. 451 * @return K data wit pending trades. 452 * @throws PeatioException indicates peatio exchange exception. 453 * @throws IOException indicates I/O exception. 454 */ 455 @GET 456 @Path("k_with_pending_trades.json") 457 KWithPendingTrades getKWithPendingTrades( 458 @QueryParam("market") String market, 459 @QueryParam("trade_id") Integer tradeId, 460 @QueryParam("limit") Integer limit, 461 @QueryParam("period") Integer period, 462 @QueryParam("timestamp") Long timestamp) 463 throws PeatioException, IOException; 464 465 }