max_exchange_api 0.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71535a1c969d383e36c7af1860aeab28c78f55fb62d0e2ef4cb05c9fe8d0df27
4
- data.tar.gz: c132f2796b57303bfd288a64f0b14cf966d4117568dadb02b606270c316d08c7
3
+ metadata.gz: edbae1a964c5392adc89a6bd87851ef12ede61c116ff0e2739ceb7a281e5b680
4
+ data.tar.gz: a643f7961288b860d35b28efdcf8f4ebcec28c1de9b44b5b19110d060400d3f1
5
5
  SHA512:
6
- metadata.gz: f51b1539a5cbc487c325fec8b46e5ef38b6c12f4fd909631769fba2e2d82bdbe8dba39ae0130919ca6951aed220e677ec07f64e5d465907fdb0d4cae7224080d
7
- data.tar.gz: 2afa7b1325fe0756f92416b33e762b9fd264abb6ff4615d6495c4e1d92e8c265b92f680ce8ede43c4e408503cacd15f8b0d9adf84ce31799ca2d25a4aa360e1c
6
+ metadata.gz: fd7fef5a08064c12470a155cd451c95d0139c34e1f452d4df18ed4478aea52c72d298ca872a5afd9a1144be40c2013631fc635c9473565c5e38e642be94ffa86
7
+ data.tar.gz: ab9eaa801cea900a431a201824e443ccd87b64476eed20ee0cac58684d4234b4b57ac658dd7b7458914c96a770a5cd67d5ab3745f2dfae8dd36c282204dabb79
data/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
  ## Change Log
2
2
 
3
+ ### [v1.1.1](https://github.com/khiav223577/max_exchange_api/compare/v1.1.0...v1.1.1) 2021/08/01
4
+ - [#7](https://github.com/khiav223577/max_exchange_api/pull/7) Fix wrong path in rewards API (@khiav223577)
5
+ - [#8](https://github.com/khiav223577/max_exchange_api/pull/8) Adjust: maker fee and min base amount test cases (@khiav223577)
6
+
7
+ ### [v1.1.0](https://github.com/khiav223577/max_exchange_api/compare/v1.0.0...v1.1.0) 2021/06/27
8
+ - [#6](https://github.com/khiav223577/max_exchange_api/pull/6) Allow every api instance to have custom config (@khiav223577)
9
+
10
+ ### [v1.0.0](https://github.com/khiav223577/max_exchange_api/compare/v0.1.0...v1.0.0) 2021/06/27
11
+ - [#5](https://github.com/khiav223577/max_exchange_api/pull/5) Implement all v2 private APIs (@khiav223577)
12
+ - [#4](https://github.com/khiav223577/max_exchange_api/pull/4) Add logger config (@khiav223577)
13
+
14
+ ### [v0.1.0](https://github.com/khiav223577/max_exchange_api/compare/v0.0.1...v0.1.0) 2021/06/26
15
+ - [#3](https://github.com/khiav223577/max_exchange_api/pull/3) Add default_timeout config (@khiav223577)
16
+ - [#2](https://github.com/khiav223577/max_exchange_api/pull/2) Implement all v2 public APIs (@khiav223577)
17
+
3
18
  ### v0.0.1 2021/06/23
4
19
  - [#1](https://github.com/khiav223577/max_exchange_api/pull/1) Implement `/depth` API (@khiav223577)
data/README.md CHANGED
@@ -35,12 +35,31 @@ Or install it yourself as:
35
35
 
36
36
  $ gem install max_exchange_api
37
37
 
38
- ## Default config
38
+ ## Configuration
39
39
 
40
- Change default api timeout time (in seconds)
40
+ ### Set timeout time
41
41
 
42
42
  ```rb
43
- MaxExchangeApi.config.default_timeout = 3
43
+ # default config
44
+ MaxExchangeApi.default_config.timeout = 3 # seconds
45
+
46
+ # custom config
47
+ MaxExchangeApi::PublicApi.new(config: { timeout: 12 })
48
+ MaxExchangeApi::PrivateApi.new(access_key, secret_key, config: { timeout: 12 })
49
+ ```
50
+
51
+ ### Logging
52
+
53
+ ```rb
54
+ require 'logger'
55
+
56
+ # default config
57
+ MaxExchangeApi.default_config.logger = Logger.new(STDOUT) # print log to stdand output
58
+ MaxExchangeApi.default_config.logger = Logger.new('log/api.log')
59
+
60
+ # custom config
61
+ MaxExchangeApi::PublicApi.new(config: { logger: Logger.new(STDOUT) })
62
+ MaxExchangeApi::PrivateApi.new(access_key, secret_key, config: { logger: Logger.new(STDOUT) })
44
63
  ```
45
64
 
46
65
  ## Usage
@@ -205,6 +224,500 @@ MaxExchangeApi.config.default_timeout = 3
205
224
  ```
206
225
  </details>
207
226
 
227
+ ### Private Api Examples
228
+
229
+ ```rb
230
+ access_key = 'YOUR_ACCESS_KEY'
231
+ secret_key = 'YOUR_SECRET_KEY'
232
+
233
+ @api = MaxExchangeApi::PrivateApi.new(access_key, secret_key)
234
+ ```
235
+
236
+ ### Trade
237
+ #### [GET /api/v2/trades/my/of_order](https://max.maicoin.com/documents/api_list#!/private/getApiV2TradesMyOfOrder)
238
+
239
+ > get your executed trades related to a order
240
+
241
+ <details>
242
+ <summary>Show code</summary>
243
+
244
+ ```rb
245
+ # use max unique order id
246
+ @api.my_trades_of_order(123456)
247
+
248
+ # use user specified order id
249
+ @api.my_trades_of_order('MY_ORDER_123456', use_client_id: true)
250
+ ```
251
+ </details>
252
+
253
+ #### [GET /api/v2/trades/my](https://max.maicoin.com/documents/api_list#!/private/getApiV2TradesMy)
254
+
255
+ > get your executed trades, sorted in reverse creation order
256
+
257
+ <details>
258
+ <summary>Show code</summary>
259
+
260
+ ```rb
261
+ # use default parameters
262
+ @api.my_trades('btctwd')
263
+
264
+ # provide all possible parameters
265
+ @api.my_trades(
266
+ 'maxtwd',
267
+ timestamp: 1624705402,
268
+ from: 68444,
269
+ to: 69444,
270
+ order_by: 'asc',
271
+ pagination: true,
272
+ page: 3,
273
+ limit: 15,
274
+ offset: 5,
275
+ )
276
+ ```
277
+ </details>
278
+
279
+ ### Withdrawal
280
+ #### [GET /api/v2/withdrawals](https://max.maicoin.com/documents/api_list#!/private/getApiV2Withdrawals)
281
+
282
+ > get your external withdrawals history
283
+
284
+ <details>
285
+ <summary>Show code</summary>
286
+
287
+ ```rb
288
+ # use default parameters
289
+ @api.withdrawals('max')
290
+
291
+ # provide all possible parameters
292
+ @api.withdrawals(
293
+ 'max',
294
+ 'confirmed',
295
+ from: 68444,
296
+ to: 69444,
297
+ state: 'confirmed',
298
+ pagination: true,
299
+ page: 3,
300
+ limit: 15,
301
+ offset: 5,
302
+ )
303
+ ```
304
+ </details>
305
+
306
+ #### [GET /api/v2/withdrawal](https://max.maicoin.com/documents/api_list#!/private/getApiV2Withdrawal)
307
+
308
+ > get details of a specific external withdraw
309
+
310
+ <details>
311
+ <summary>Show code</summary>
312
+
313
+ ```rb
314
+ @api.withdrawal('withdraw_id')
315
+ ```
316
+ </details>
317
+
318
+ #### [POST /api/v2/withdrawal](https://max.maicoin.com/documents/api_list#!/private/postApiV2Withdrawal)
319
+
320
+ > submit a withdrawal. IP whitelist for api token is required.
321
+
322
+ <details>
323
+ <summary>Show code</summary>
324
+
325
+ ```rb
326
+ @api.create_withdrawal!('twd', 'withdraw_address_id', 100000)
327
+ ```
328
+ </details>
329
+
330
+ ### Profile
331
+ #### [GET /api/v2/members/profile](https://max.maicoin.com/documents/api_list#!/private/getApiV2MembersProfile)
332
+
333
+ > get personal profile information
334
+
335
+ <details>
336
+ <summary>Show code</summary>
337
+
338
+ ```rb
339
+ @api.member_profile
340
+ ```
341
+ </details>
342
+
343
+ #### [GET /api/v2/members/me](https://max.maicoin.com/documents/api_list#!/private/getApiV2MembersMe)
344
+
345
+ > get your profile and accounts information
346
+
347
+ <details>
348
+ <summary>Show code</summary>
349
+
350
+ ```rb
351
+ @api.me
352
+ ```
353
+ </details>
354
+
355
+ #### [GET /api/v2/members/vip_level](https://max.maicoin.com/documents/api_list#!/private/getApiV2MembersVipLevel)
356
+
357
+ > get VIP level info
358
+
359
+ <details>
360
+ <summary>Show code</summary>
361
+
362
+ ```rb
363
+ @api.vip_level
364
+ ```
365
+ </details>
366
+
367
+ ### Account
368
+ #### [GET /api/v2/members/accounts](https://max.maicoin.com/documents/api_list#!/private/getApiV2MembersAccounts)
369
+
370
+ > get personal accounts information
371
+
372
+ <details>
373
+ <summary>Show code</summary>
374
+
375
+ ```rb
376
+ @api.accounts
377
+ ```
378
+ </details>
379
+
380
+ #### [GET /api/v2/members/accounts/{path_currency}](https://max.maicoin.com/documents/api_list#!/private/getApiV2MembersAccountsPathCurrency)
381
+
382
+ > get personal accounts information of a currency
383
+
384
+ <details>
385
+ <summary>Show code</summary>
386
+
387
+ ```rb
388
+ @api.account(currnecy)
389
+ ```
390
+ </details>
391
+
392
+ ### Deposit
393
+ #### [GET /api/v2/deposits](https://max.maicoin.com/documents/api_list#!/private/getApiV2Deposits)
394
+
395
+ > get your deposits history
396
+
397
+ <details>
398
+ <summary>Show code</summary>
399
+
400
+ ```rb
401
+ # use default parameters
402
+ @api.deposits('max')
403
+
404
+ # provide all possible parameters
405
+ @api.deposits(
406
+ 'max',
407
+ 'confirmed',
408
+ from: 68444,
409
+ to: 69444,
410
+ state: 'accepted',
411
+ pagination: true,
412
+ page: 3,
413
+ limit: 15,
414
+ offset: 5,
415
+ )
416
+ ```
417
+ </details>
418
+
419
+ #### [GET /api/v2/deposit](https://max.maicoin.com/documents/api_list#!/private/getApiV2Deposit)
420
+
421
+ > get details of a specific deposit
422
+
423
+ <details>
424
+ <summary>Show code</summary>
425
+
426
+ ```rb
427
+ @api.deposit('transaction_id')
428
+ ```
429
+ </details>
430
+
431
+ ### Address
432
+ #### [GET /api/v2/deposit_addresses](https://max.maicoin.com/documents/api_list#!/private/getApiV2DepositAddresses)
433
+
434
+ > The addresses could be empty before generated, please call POST /deposit_addresses in that case
435
+
436
+ <details>
437
+ <summary>Show code</summary>
438
+
439
+ ```rb
440
+ # use default parameters
441
+ @api.deposit_addresses
442
+
443
+ # provide all possible parameters
444
+ @api.deposit_addresses(currency: 'twd', pagination: true, page: 3, limit: 15, offset: 5)
445
+ ```
446
+ </details>
447
+
448
+ #### [POST /api/v2/deposit_addresses](https://max.maicoin.com/documents/api_list#!/private/postApiV2DepositAddresses)
449
+
450
+ > Address creation is asynchronous, please call GET /deposit_addresses later to get generated addresses
451
+
452
+ <details>
453
+ <summary>Show code</summary>
454
+
455
+ ```rb
456
+ @api.create_deposit_addresses!('twd')
457
+ ```
458
+ </details>
459
+
460
+ #### [GET /api/v2/withdraw_addresses](https://max.maicoin.com/documents/api_list#!/private/getApiV2WithdrawAddresses)
461
+
462
+ > get withdraw addresses
463
+
464
+ <details>
465
+ <summary>Show code</summary>
466
+
467
+ ```rb
468
+ # use default parameters
469
+ @api.withdraw_addresses('twd')
470
+
471
+ # provide all possible parameters
472
+ @api.withdraw_addresses('usdt', pagination: true, page: 3, limit: 15, offset: 5)
473
+ ```
474
+ </details>
475
+
476
+ ### Internal Transfer
477
+ #### [GET /api/v2/internal_transfers](https://max.maicoin.com/documents/api_list#!/private/getApiV2InternalTransfers)
478
+
479
+ > get internal transfers history
480
+
481
+ <details>
482
+ <summary>Show code</summary>
483
+
484
+ ```rb
485
+ # use default parameters
486
+ @api.internal_transfers
487
+
488
+ # provide all possible parameters
489
+ @api.internal_transfers(
490
+ currency: 'btc',
491
+ side: 'in',
492
+ from: 68444,
493
+ to: 69444,
494
+ pagination: true,
495
+ page: 3,
496
+ limit: 15,
497
+ offset: 5,
498
+ )
499
+ ```
500
+ </details>
501
+
502
+ #### [GET /api/v2/internal_transfer](https://max.maicoin.com/documents/api_list#!/private/getApiV2InternalTransfer)
503
+
504
+ > get details of a specific internal transfer
505
+
506
+ <details>
507
+ <summary>Show code</summary>
508
+
509
+ ```rb
510
+ @api.internal_transfer('internal_transfer_id')
511
+ ```
512
+ </details>
513
+
514
+ ### Reward
515
+ #### [GET /api/v2/rewards](https://max.maicoin.com/documents/api_list#!/private/getApiV2Rewards)
516
+
517
+ > get rewards history
518
+
519
+ <details>
520
+ <summary>Show code</summary>
521
+
522
+ ```rb
523
+ # use default parameters
524
+ @api.rewards
525
+
526
+ # provide all possible parameters
527
+ @api.rewards(
528
+ currency: 'btc',
529
+ from: 68444,
530
+ to: 69444,
531
+ pagination: true,
532
+ page: 3,
533
+ limit: 15,
534
+ offset: 5,
535
+ )
536
+ ```
537
+ </details>
538
+
539
+ #### [GET /api/v2/rewards/{path_reward_type}](https://max.maicoin.com/documents/api_list#!/private/getApiV2RewardsPathRewardType)
540
+
541
+ > get specific rewards history
542
+
543
+ <details>
544
+ <summary>Show code</summary>
545
+
546
+ ```rb
547
+ # use default parameters
548
+ @api.rewards(reward_type: 'airdrop_rewards')
549
+
550
+ # provide all possible parameters
551
+ @api.rewards(
552
+ reward_type: 'airdrop_rewards',
553
+ currency: 'btc',
554
+ from: 68444,
555
+ to: 69444,
556
+ pagination: true,
557
+ page: 3,
558
+ limit: 15,
559
+ offset: 5,
560
+ )
561
+ ```
562
+ </details>
563
+
564
+ #### [GET /api/v2/max_rewards/yesterday](https://max.maicoin.com/documents/api_list#!/private/getApiV2MaxRewardsYesterday)
565
+
566
+ > get max rewards yesterday
567
+
568
+ <details>
569
+ <summary>Show code</summary>
570
+
571
+ ```rb
572
+ @api.max_rewards_yesterday
573
+ ```
574
+ </details>
575
+
576
+ #### GET /api/v2/yields
577
+
578
+ > get yields history
579
+
580
+ <details>
581
+ <summary>Show code</summary>
582
+
583
+ ```rb
584
+ # use default parameters
585
+ @api.yields
586
+
587
+ # provide all possible parameters
588
+ @api.yields(
589
+ currency: 'usdt',
590
+ from: 68444,
591
+ to: 69444,
592
+ pagination: true,
593
+ page: 3,
594
+ limit: 15,
595
+ offset: 5,
596
+ )
597
+ ```
598
+ </details>
599
+
600
+ ### Order
601
+ #### [GET /api/v2/orders](https://max.maicoin.com/documents/api_list#!/private/getApiV2Orders)
602
+
603
+ > get your orders, results is paginated.
604
+
605
+ <details>
606
+ <summary>Show code</summary>
607
+
608
+ ```rb
609
+ # use default parameters
610
+ @api.orders('maxtwd')
611
+
612
+ # provide all possible parameters
613
+ @api.orders(
614
+ 'maxtwd',
615
+ state: 'done',
616
+ order_by: 'desc',
617
+ group_id: 12345,
618
+ pagination: true,
619
+ page: 3,
620
+ limit: 15,
621
+ offset: 5,
622
+ )
623
+ ```
624
+ </details>
625
+
626
+ #### [GET /api/v2/order](https://max.maicoin.com/documents/api_list#!/private/getApiV2Order)
627
+
628
+ > get a specific order.
629
+
630
+ <details>
631
+ <summary>Show code</summary>
632
+
633
+ ```rb
634
+ # use max unique order id
635
+ @api.order(123456)
636
+
637
+ # use user specified order id
638
+ @api.order('MY_ORDER_123456', use_client_id: true)
639
+ ```
640
+ </details>
641
+
642
+ #### [POST /api/v2/orders/clear](https://max.maicoin.com/documents/api_list#!/private/postApiV2OrdersClear)
643
+
644
+ > cancel all your orders with given market and side
645
+
646
+ <details>
647
+ <summary>Show code</summary>
648
+
649
+ ```rb
650
+ # use default parameters
651
+ @api.cancel_orders!
652
+
653
+ # provide all possible parameters
654
+ @api.cancel_orders!(market: 'maxtwd', side: 'sell', group_id: '123456')
655
+ ```
656
+ </details>
657
+
658
+ #### [POST /api/v2/order/delete](https://max.maicoin.com/documents/api_list#!/private/postApiV2OrderDelete)
659
+
660
+ > cancel an order
661
+
662
+ <details>
663
+ <summary>Show code</summary>
664
+
665
+ ```rb
666
+ # use max unique order id
667
+ @api.cancel_order!(123456)
668
+
669
+ # use user specified order id
670
+ @api.cancel_order!('MY_ORDER_123456', use_client_id: true)
671
+ ```
672
+ </details>
673
+
674
+ #### [POST /api/v2/orders](https://max.maicoin.com/documents/api_list#!/private/postApiV2Orders)
675
+
676
+ > create a sell/buy order
677
+
678
+ <details>
679
+ <summary>Show code</summary>
680
+
681
+ ```rb
682
+ # use default parameters
683
+ @api.create_order!('maxtwd', 'buy', 1000, price: 7.5)
684
+
685
+ # provide all possible parameters
686
+ @api.create_order!(
687
+ 'maxtwd',
688
+ 'buy',
689
+ 1000,
690
+ price: 7.5,
691
+ client_oid: 'MY_ORDER_ID_12345',
692
+ stop_price: 8,
693
+ ord_type: 'limit',
694
+ group_id: 12345678,
695
+ )
696
+ ```
697
+ </details>
698
+
699
+ #### [POST /api/v2/orders/multi/onebyone](https://max.maicoin.com/documents/api_list#!/private/postApiV2OrdersMultiOnebyone)
700
+
701
+ > Create multiple sell/buy orders, orders may be partially accepted, please put your orders as an array in json body.
702
+
703
+ <details>
704
+ <summary>Show code</summary>
705
+
706
+ ```rb
707
+ # use default parameters
708
+ @api.create_orders!('maxtwd', [
709
+ { side: 'buy', volume: '1000', price: 7.5 },
710
+ { side: 'buy', volume: '1500', price: 7.2 },
711
+ ])
712
+
713
+ # provide all possible parameters
714
+ @api.create_orders!('maxtwd', [
715
+ { side: 'buy', volume: '1000', price: 7.5, client_oid: 'MY_ORDER_ID_12345', stop_price: 8, ord_type: 'limit' },
716
+ { side: 'buy', volume: '1500', price: 7.2, client_oid: 'MY_ORDER_ID_12346', stop_price: 8, ord_type: 'limit' },
717
+ ], group_id: 12345)
718
+ ```
719
+ </details>
720
+
208
721
  ## Development
209
722
 
210
723
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,3 +1,4 @@
1
1
  require 'max_exchange_api/version'
2
2
  require 'max_exchange_api/config'
3
3
  require 'max_exchange_api/public_api'
4
+ require 'max_exchange_api/private_api'
@@ -7,6 +7,13 @@ module MaxExchangeApi
7
7
  class BaseApi
8
8
  include HTTParty
9
9
 
10
+ attr_reader :config
11
+
12
+ def initialize(config: nil)
13
+ @config = Config.new(config)
14
+ @config.reverse_merge!(MaxExchangeApi.default_config)
15
+ end
16
+
10
17
  protected
11
18
 
12
19
  def send_request(method, path, headers, query)
@@ -19,7 +26,7 @@ module MaxExchangeApi
19
26
  path,
20
27
  headers: headers,
21
28
  query: query,
22
- timeout: MaxExchangeApi.config.default_timeout,
29
+ timeout: @config.timeout,
23
30
  ).parsed_response
24
31
 
25
32
  print_log(:info, "[API] #{uuid} response #{response}")
@@ -32,8 +39,9 @@ module MaxExchangeApi
32
39
 
33
40
  private
34
41
 
35
- def print_log(_method, message)
36
- puts message
42
+ def print_log(method, message)
43
+ logger = @config.logger
44
+ logger.send(method, message) if logger
37
45
  end
38
46
  end
39
47
  end
@@ -2,16 +2,25 @@
2
2
 
3
3
  module MaxExchangeApi
4
4
  class Config
5
- attr_accessor :default_timeout
5
+ attr_accessor :timeout
6
+ attr_accessor :logger
6
7
 
7
- def initialize
8
- @default_timeout = 3
8
+ def initialize(data = nil)
9
+ data ||= {}
10
+ @timeout = data[:timeout]
11
+ @logger = data[:logger]
12
+ end
13
+
14
+ def reverse_merge!(other)
15
+ @timeout ||= other.timeout
16
+ @logger ||= other.logger
9
17
  end
10
18
  end
11
19
 
12
- @config = Config.new
20
+ @default_config = Config.new
21
+ @default_config.timeout = 3
13
22
 
14
23
  class << self
15
- attr_reader :config
24
+ attr_reader :default_config
16
25
  end
17
26
  end
@@ -2,5 +2,26 @@
2
2
 
3
3
  module MaxExchangeApi
4
4
  module Helper
5
+ class << self
6
+ def gen_headers(payload, access_key, secret_key)
7
+ encoded_payload = encode(payload)
8
+
9
+ return {
10
+ 'X-MAX-ACCESSKEY' => access_key,
11
+ 'X-MAX-PAYLOAD' => encoded_payload,
12
+ 'X-MAX-SIGNATURE' => encrypt(encoded_payload, secret_key),
13
+ }
14
+ end
15
+
16
+ private
17
+
18
+ def encode(data)
19
+ Base64.strict_encode64(data.to_json)
20
+ end
21
+
22
+ def encrypt(data, key)
23
+ OpenSSL::HMAC.digest('sha256', key, data).unpack('H*')[0]
24
+ end
25
+ end
5
26
  end
6
27
  end
@@ -0,0 +1,239 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'max_exchange_api/base_api'
4
+
5
+ module MaxExchangeApi
6
+ class PrivateApi < BaseApi
7
+ base_uri 'https://max-api.maicoin.com/api/v2'
8
+
9
+ def initialize(access_key, secret_key, config: nil)
10
+ super(config: config)
11
+
12
+ @access_key = access_key
13
+ @secret_key = secret_key
14
+ end
15
+
16
+ def my_trades_of_order(order_id, use_client_id: false)
17
+ id_params_key = use_client_id ? :client_oid : :id
18
+ send_request(:get, '/trades/my/of_order', id_params_key => order_id)
19
+ end
20
+
21
+ def my_trades(market, timestamp: nil, from: nil, to: nil, order_by: 'desc', pagination: true, page: 1, limit: 50,
22
+ offset: 0)
23
+ send_request(
24
+ :get,
25
+ '/trades/my',
26
+ market: market,
27
+ timestamp: timestamp,
28
+ from: from,
29
+ to: to,
30
+ order_by: order_by,
31
+ pagination: pagination,
32
+ page: page,
33
+ limit: limit,
34
+ offset: offset,
35
+ )
36
+ end
37
+
38
+ def member_profile
39
+ send_request(:get, '/members/profile', {})
40
+ end
41
+
42
+ def me
43
+ send_request(:get, '/members/me', {})
44
+ end
45
+
46
+ def vip_level
47
+ send_request(:get, '/members/vip_level', {})
48
+ end
49
+
50
+ def accounts
51
+ send_request(:get, '/members/accounts', {})
52
+ end
53
+
54
+ def account(currency)
55
+ send_request(:get, "/members/accounts/#{currency}", {})
56
+ end
57
+
58
+ def deposits(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50,
59
+ offset: 0)
60
+ send_request(
61
+ :get,
62
+ '/deposits',
63
+ currency: currency,
64
+ from: from,
65
+ to: to,
66
+ state: state,
67
+ pagination: pagination,
68
+ page: page,
69
+ limit: limit,
70
+ offset: offset,
71
+ )
72
+ end
73
+
74
+ def deposit(transaction_id)
75
+ send_request(:get, '/deposit', txid: transaction_id)
76
+ end
77
+
78
+ def deposit_addresses(currency: nil, pagination: nil, page: 1, limit: 50, offset: 0)
79
+ send_request(
80
+ :get,
81
+ '/deposit_addresses',
82
+ currency: currency,
83
+ pagination: pagination,
84
+ page: page,
85
+ limit: limit,
86
+ offset: offset,
87
+ )
88
+ end
89
+
90
+ def create_deposit_addresses!(currency)
91
+ send_request(:post, '/deposit_addresses', currency: currency)
92
+ end
93
+
94
+ def withdraw_addresses(currency, pagination: nil, page: 1, limit: 50, offset: 0)
95
+ send_request(
96
+ :get,
97
+ '/withdraw_addresses',
98
+ currency: currency,
99
+ pagination: pagination,
100
+ page: page,
101
+ limit: limit,
102
+ offset: offset,
103
+ )
104
+ end
105
+
106
+ def withdrawal(withdraw_id)
107
+ send_request(:get, '/withdrawal', uuid: withdraw_id)
108
+ end
109
+
110
+ def withdrawals(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50,
111
+ offset: 0)
112
+ send_request(
113
+ :get,
114
+ '/withdrawals',
115
+ currency: currency,
116
+ from: from,
117
+ to: to,
118
+ state: state,
119
+ pagination: pagination,
120
+ page: page,
121
+ limit: limit,
122
+ offset: offset,
123
+ )
124
+ end
125
+
126
+ def create_withdrawal!(currency, withdraw_address_id, amount)
127
+ send_request(:post, '/withdrawal', currency: currency, withdraw_address_uuid: withdraw_address_id, amount: amount)
128
+ end
129
+
130
+ def internal_transfers(currency: nil, side: 'in', from: nil, to: nil, pagination: nil, page: 1, limit: 50,
131
+ offset: 0)
132
+ send_request(
133
+ :get,
134
+ '/internal_transfers',
135
+ currency: currency,
136
+ side: side,
137
+ from: from,
138
+ to: to,
139
+ pagination: pagination,
140
+ page: page,
141
+ limit: limit,
142
+ offset: offset,
143
+ )
144
+ end
145
+
146
+ def internal_transfer(internal_transfer_id)
147
+ send_request(:get, '/internal_transfer', uuid: internal_transfer_id)
148
+ end
149
+
150
+ def rewards(reward_type: nil, currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
151
+ path = reward_type ? "/rewards/#{reward_type}" : '/rewards'
152
+ send_request(
153
+ :get,
154
+ path,
155
+ currency: currency,
156
+ from: from,
157
+ to: to,
158
+ pagination: pagination,
159
+ page: page,
160
+ limit: limit,
161
+ offset: offset,
162
+ )
163
+ end
164
+
165
+ def yields(currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
166
+ send_request(
167
+ :get,
168
+ '/yields',
169
+ currency: currency,
170
+ from: from,
171
+ to: to,
172
+ pagination: pagination,
173
+ page: page,
174
+ limit: limit,
175
+ offset: offset,
176
+ )
177
+ end
178
+
179
+ def max_rewards_yesterday
180
+ send_request(:get, '/max_rewards/yesterday', {})
181
+ end
182
+
183
+ def orders(market, state: nil, order_by: 'asc', group_id: nil, pagination: nil, page: 1, limit: 50, offset: 0)
184
+ send_request(
185
+ :get,
186
+ '/orders',
187
+ market: market,
188
+ state: state,
189
+ order_by: order_by,
190
+ group_id: group_id,
191
+ pagination: pagination,
192
+ page: page,
193
+ limit: limit,
194
+ offset: offset,
195
+ )
196
+ end
197
+
198
+ def order(order_id, use_client_id: false)
199
+ id_params_key = use_client_id ? :client_oid : :id
200
+ send_request(:get, '/order', id_params_key => order_id)
201
+ end
202
+
203
+ def cancel_orders!(market: nil, side: nil, group_id: nil)
204
+ send_request(:post, '/orders/clear', market: market, side: side, group_id: group_id)
205
+ end
206
+
207
+ def cancel_order!(order_id, use_client_id: false)
208
+ id_params_key = use_client_id ? :client_oid : :id
209
+ send_request(:post, '/order/delete', id_params_key => order_id)
210
+ end
211
+
212
+ def create_order!(market, side, volume, price: nil, client_oid: nil, stop_price: nil, ord_type: nil, group_id: nil)
213
+ send_request(
214
+ :post,
215
+ '/orders',
216
+ market: market,
217
+ side: side,
218
+ volume: volume,
219
+ price: price,
220
+ client_oid: client_oid,
221
+ stop_price: stop_price,
222
+ ord_type: ord_type,
223
+ group_id: group_id,
224
+ )
225
+ end
226
+
227
+ def create_orders!(market, orders, group_id: nil)
228
+ send_request(:post, '/orders/multi/onebyone', market: market, orders: orders, group_id: group_id)
229
+ end
230
+
231
+ protected
232
+
233
+ def send_request(method, path, query)
234
+ query = query.compact
235
+ query.merge!(path: "/api/v2#{path}", nonce: (Time.now.to_f * 1000).to_i)
236
+ return super(method, path, Helper.gen_headers(query, @access_key, @secret_key), query)
237
+ end
238
+ end
239
+ end
@@ -1,3 +1,3 @@
1
1
  module MaxExchangeApi
2
- VERSION = '0.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: max_exchange_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-26 00:00:00.000000000 Z
11
+ date: 2021-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,7 @@ files:
108
108
  - lib/max_exchange_api/base_api.rb
109
109
  - lib/max_exchange_api/config.rb
110
110
  - lib/max_exchange_api/helper.rb
111
+ - lib/max_exchange_api/private_api.rb
111
112
  - lib/max_exchange_api/public_api.rb
112
113
  - lib/max_exchange_api/version.rb
113
114
  - max_exchange_api.gemspec