binance-connector-ruby 1.0.3 → 1.3.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: c3a475fdc0713297117730ac086e0ffa03285ab497ef48fb5ba30049c70b3b05
4
- data.tar.gz: 16160279f534e262882d14a10f31ca521165df71247217dfb04b6df3e2ea06a3
3
+ metadata.gz: de524913cc9c575bf9fd6092b85464b1e195cbb28ef639d34a9f6597ebda53a3
4
+ data.tar.gz: 3cf930994609c13b9e11309e81a37f4b489849d0228efca500733f1f7df319a3
5
5
  SHA512:
6
- metadata.gz: 792ea2893a73ab7965fb0f45a56b8e74cdb13403e37a53cb4e82c46b61eb3cb3884ede1deb98718a1a1864aa70675db31375ec836f89db94d3da9485e2fb8758
7
- data.tar.gz: cd64daebc240af81ca0a4b2f9b3f85c4490d621ef246b8557f30980db1a0024e8092efc139e3248ba33367d6023e0a38798e5758ea2bbd9b620bfbda284169d2
6
+ metadata.gz: 5dab0a672033c4880a0afb62f768dff3d75c3103f0ee7d13ab3879063cd8ddc2ca9dd2a5b9a8cdce0031e4e02803e0fed43cdfbb054a95a42bfbbeacb26004b5
7
+ data.tar.gz: 87a8ae78a612843f04017cea5f4135de54cb5c60d5143211b5838be4ea40ab2c64adf7963003477ea24def1017dcdf04df7d354e175423c771097102eedbe5a0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 - 2022-07-21
4
+
5
+ ### Add
6
+ - New endpoint for Margin:
7
+ - `POST /sapi/v3/asset/getUserAsset` to get user assets.
8
+ - New endpoint for Wallet:
9
+ - `GET /sapi/v1/margin/dribblet` to query the historical information of user's margin account small-value asset conversion BNB.
10
+
11
+
12
+ ## 1.2.0 - 2022-07-15
13
+
14
+ ### Add
15
+ - Sub account endpoints
16
+ - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` to support master account enable and disable IP restriction for a sub-account API Key
17
+ - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` to support master account add IP list for a sub-account API Key
18
+ - `GET /sapi/v1/account/apiRestrictions/ipRestriction` to support master account query IP restriction for a sub-account API Key
19
+ - `DELETE /sapi/v1/account/apiRestrictions/ipRestriction/ipList` to support master account delete IP list for a sub-account API Key
20
+ - Market endpoint
21
+ - `GET /api/v3/ticker`
22
+ - Trade endpoint
23
+ - `POST /api/v3/order/cancelReplace`
24
+ - Websocket methods
25
+ - `<symbol>@ticker_<window_size>`
26
+ - `!ticker_<window-size>@arr`
27
+
28
+
29
+ ## 1.1.0 - 2022-06-09
30
+
31
+ ### Add
32
+ - Convert endpoint
33
+ - `GET /sapi/v1/convert/tradeFlow`
34
+ - Margin Endpoint
35
+ - `GET /sapi/v1/margin/crossMarginData`
36
+ - `GET /sapi/v1/margin/isolatedMarginData`
37
+ - `GET /sapi/v1/margin/isolatedMarginTier`
38
+ - `GET /sapi/v1/margin/rateLimit/order`
39
+ - All Staking Endpoints
40
+
41
+ ### Update
42
+ - Fixing rubocop warnnings
43
+
3
44
  ## 1.0.3 - 2022-05-06
4
45
  - Update rake version
5
46
 
data/README.md CHANGED
@@ -35,9 +35,11 @@ This is a lightweight library that works as a connector to [Binance public API](
35
35
  ```shell
36
36
  gem install binance-connector-ruby
37
37
  ```
38
+
38
39
  ## Documentation
39
40
 
40
41
  [https://www.rubydoc.info/gems/binance-connector-ruby](https://www.rubydoc.info/gems/binance-connector-ruby)
42
+
41
43
  ## Restful APIs
42
44
 
43
45
  ```ruby
data/lib/binance/error.rb CHANGED
@@ -25,4 +25,11 @@ module Binance
25
25
  )
26
26
  end
27
27
  end
28
+
29
+ # Error when Multi parameters are not allowed to send together
30
+ class DuplicatedParametersError < Error
31
+ def initialize(*kwargs)
32
+ super("Parameters #{kwargs} should not be sent to server together.")
33
+ end
34
+ end
28
35
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # Convert endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#convert-endpoints
7
+ module Convert
8
+ # Get Convert Trade History (USER_DATA)
9
+ #
10
+ # GET /sapi/v1/convert/tradeFlow
11
+ #
12
+ # @param startTime [Integer]
13
+ # @param endTime [Integer]
14
+ # @param kwargs [Hash]
15
+ # @option kwargs [Integer] :limit default 100, max 1000
16
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
17
+ # @see https://binance-docs.github.io/apidocs/spot/en/#convert-endpoints
18
+ def convert_trade_flow(startTime:, endTime:, **kwargs)
19
+ Binance::Utils::Validation.require_param('startTime', startTime)
20
+ Binance::Utils::Validation.require_param('endTime', endTime)
21
+
22
+ @session.sign_request(:get, '/sapi/v1/convert/tradeFlow', params: kwargs.merge(
23
+ startTime: startTime,
24
+ endTime: endTime
25
+ ))
26
+ end
27
+ end
28
+ end
29
+ end
@@ -671,6 +671,73 @@ module Binance
671
671
 
672
672
  @session.sign_request(:get, '/sapi/v1/margin/interestRateHistory', params: kwargs.merge(asset: asset))
673
673
  end
674
+
675
+ # Query Cross Margin Fee Data (USER_DATA)
676
+ #
677
+ # GET /sapi/v1/margin/crossMarginData
678
+ #
679
+ # @param kwargs [Hash]
680
+ # @option vipLevel [Integer] Default: user's vip level
681
+ # @option coin [String]
682
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
683
+ # @see https://binance-docs.github.io/apidocs/spot/en/#query-cross-margin-fee-data-user_data
684
+ def get_cross_margin_data(**kwargs)
685
+ @session.sign_request(:get, '/sapi/v1/margin/crossMarginData', params: kwargs)
686
+ end
687
+
688
+ # Query Isolated Margin Fee Data (USER_DATA)
689
+ #
690
+ # GET /sapi/v1/margin/isolatedMarginData
691
+ #
692
+ # @param kwargs [Hash]
693
+ # @option vipLevel [Integer] Default: user's vip level
694
+ # @option symbol [String]
695
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
696
+ # @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-fee-data-user_data
697
+ def get_isolated_margin_data(**kwargs)
698
+ @session.sign_request(:get, '/sapi/v1/margin/isolatedMarginData', params: kwargs)
699
+ end
700
+
701
+ # Query Isolated Margin Tier Data (USER_DATA)
702
+ #
703
+ # GET /sapi/v1/margin/isolatedMarginTier
704
+ #
705
+ # @param symbol [String]
706
+ # @param kwargs [Hash]
707
+ # @option tier [Integer]
708
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
709
+ # @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-tier-data-user_data
710
+ def get_isolated_margin_tier(symbol:, **kwargs)
711
+ Binance::Utils::Validation.require_param('symbol', symbol)
712
+
713
+ @session.sign_request(:get, '/sapi/v1/margin/isolatedMarginTier', params: kwargs.merge(symbol: symbol))
714
+ end
715
+
716
+ # Query Current Margin Order Count Usage (TRADE)
717
+ #
718
+ # GET /sapi/v1/margin/rateLimit/order
719
+ #
720
+ # @param kwargs [Hash]
721
+ # @option isIsolated [String]
722
+ # @option symbol [String]
723
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
724
+ # @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-fee-data-user_data
725
+ def get_margin_order_usage(**kwargs)
726
+ @session.sign_request(:get, '/sapi/v1/margin/rateLimit/order', params: kwargs)
727
+ end
728
+
729
+ # Margin Dustlog (USER_DATA)
730
+ #
731
+ # GET /sapi/v1/margin/dribblet
732
+ #
733
+ # @param kwargs [Hash]
734
+ # @option kwargs [String] :startTime
735
+ # @option kwargs [String] :endTime
736
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
737
+ # @see https://binance-docs.github.io/apidocs/spot/en/#margin-dustlog-user_data
738
+ def get_margin_dust_log(**kwargs)
739
+ @session.sign_request(:get, '/sapi/v1/margin/dribblet', params: kwargs)
740
+ end
674
741
  end
675
742
  end
676
743
  end
@@ -215,6 +215,32 @@ module Binance
215
215
  params: { symbol: symbol }
216
216
  )
217
217
  end
218
+
219
+ # Symbol Order Book Ticker
220
+ #
221
+ # Best price/qty on the order book for a symbol or symbols.
222
+ #
223
+ # GET /api/v3/ticker/bookTicker
224
+ #
225
+ # @param symbol [String] the symbol
226
+ # @see https://binance-docs.github.io/apidocs/spot/en/#symbol-order-book-ticker
227
+ def ticker(symbol: nil, symbols: nil, windowSize: '1d')
228
+ raise Binance::DuplicatedParametersError.new('symbol', 'symbols') unless symbols.nil? || symbol.nil?
229
+
230
+ params = { symbol: symbol.upcase } if symbol
231
+
232
+ if symbols
233
+ symbols = symbols.map { |s| "\"#{s}\"" }.join(',')
234
+ params = { symbols: "\[#{symbols}\]".upcase }
235
+ end
236
+
237
+ params[:windowSize] = windowSize
238
+
239
+ @session.public_request(
240
+ path: '/api/v3/ticker',
241
+ params: params
242
+ )
243
+ end
218
244
  end
219
245
  end
220
246
  end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # all savings endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#savings-endpoints
7
+ module Staking
8
+ # Get Staking Product List(USER_DATA)
9
+ #
10
+ # GET /sapi/v1/staking/productList
11
+ #
12
+ # @param product [String] "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
13
+ # @param kwargs [Hash]
14
+ # @option kwargs [String] :asset
15
+ # @option kwargs [Integer] :current
16
+ # @option kwargs [Integer] :size
17
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
18
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-staking-product-list-user_data
19
+ def staking_product_list(product:, **kwargs)
20
+ Binance::Utils::Validation.require_param('product', product)
21
+
22
+ @session.sign_request(:get, '/sapi/v1/staking/productList', params: kwargs.merge(product: product))
23
+ end
24
+
25
+ # Purchase Staking Product(USER_DATA)
26
+ #
27
+ # POST /sapi/v1/staking/purchase
28
+ #
29
+ # @param product [String] "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
30
+ # @param productId [String]
31
+ # @param amount [Float]
32
+ # @param kwargs [Hash]
33
+ # @option kwargs [String] :renewable
34
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
35
+ # @see https://binance-docs.github.io/apidocs/spot/en/#purchase-staking-product-user_data
36
+ def staking_purchase(product:, productId:, amount:, **kwargs)
37
+ Binance::Utils::Validation.require_param('product', product)
38
+ Binance::Utils::Validation.require_param('productId', productId)
39
+ Binance::Utils::Validation.require_param('amount', amount)
40
+
41
+ @session.sign_request(:post, '/sapi/v1/staking/purchase', params: kwargs.merge(product: product, productId: productId, amount: amount))
42
+ end
43
+
44
+ # Redeem Staking Product(USER_DATA)
45
+ #
46
+ # POST /sapi/v1/staking/redeem
47
+ #
48
+ # @param product [String] "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
49
+ # @param productId [String]
50
+ # @param kwargs [Hash]
51
+ # @option kwargs [Float] :amount
52
+ # @option kwargs [String] :positionId
53
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
54
+ # @see https://binance-docs.github.io/apidocs/spot/en/#redeem-staking-product-user_data
55
+ def staking_redeem(product:, productId:, **kwargs)
56
+ Binance::Utils::Validation.require_param('product', product)
57
+ Binance::Utils::Validation.require_param('productId', productId)
58
+
59
+ @session.sign_request(:post, '/sapi/v1/staking/redeem', params: kwargs.merge(product: product, productId: productId))
60
+ end
61
+
62
+ # Get Staking Product Position(USER_DATA)
63
+ #
64
+ # GET /sapi/v1/staking/position
65
+ #
66
+ # @param product [String] "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
67
+ # @param kwargs [Hash]
68
+ # @option kwargs [String] :productId
69
+ # @option kwargs [String] :asset
70
+ # @option kwargs [Integer] :current
71
+ # @option kwargs [Integer] :size
72
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
73
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-staking-product-list-user_data
74
+ def staking_position(product:, **kwargs)
75
+ Binance::Utils::Validation.require_param('product', product)
76
+
77
+ @session.sign_request(:get, '/sapi/v1/staking/position', params: kwargs.merge(product: product))
78
+ end
79
+
80
+ # Get Staking History(USER_DATA)
81
+ #
82
+ # GET /sapi/v1/staking/stakingRecord
83
+ #
84
+ # @param product [String] "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
85
+ # @param txnType [String] "SUBSCRIPTION", "REDEMPTION", "INTEREST"
86
+ # @param kwargs [Hash]
87
+ # @option kwargs [String] :asset
88
+ # @option kwargs [Integer] :startTime
89
+ # @option kwargs [Integer] :endTime
90
+ # @option kwargs [Integer] :current
91
+ # @option kwargs [Integer] :size
92
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
93
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-staking-history-user_data
94
+ def staking_history(product:, txnType:, **kwargs)
95
+ Binance::Utils::Validation.require_param('product', product)
96
+ Binance::Utils::Validation.require_param('txnType', txnType)
97
+
98
+ @session.sign_request(:get, '/sapi/v1/staking/stakingRecord', params: kwargs.merge(product: product, txnType: txnType))
99
+ end
100
+
101
+ # Set Auto Staking(USER_DATA)
102
+ #
103
+ # POST /sapi/v1/staking/setAutoStaking
104
+ #
105
+ # @param product [String] "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
106
+ # @param positionId [String]
107
+ # @param renewable [String] true or false
108
+ # @param kwargs [Hash]
109
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
110
+ # @see https://binance-docs.github.io/apidocs/spot/en/#set-auto-staking-user_data
111
+ def staking_set_auto(product:, positionId:, renewable:, **kwargs)
112
+ Binance::Utils::Validation.require_param('product', product)
113
+ Binance::Utils::Validation.require_param('positionId', positionId)
114
+ Binance::Utils::Validation.require_param('renewable', renewable)
115
+
116
+ @session.sign_request(:post, '/sapi/v1/staking/setAutoStaking', params: kwargs.merge(product: product, positionId: positionId, renewable: renewable))
117
+ end
118
+
119
+ # Get Personal Left Quota of Staking Product(USER_DATA)
120
+ #
121
+ # GET /sapi/v1/staking/personalLeftQuota
122
+ #
123
+ # @param product [String] "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
124
+ # @param productId [String]
125
+ # @param kwargs [Hash]
126
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
127
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-staking-history-user_data
128
+ def staking_personal_quota_remain(product:, productId:, **kwargs)
129
+ Binance::Utils::Validation.require_param('product', product)
130
+ Binance::Utils::Validation.require_param('productId', productId)
131
+
132
+ @session.sign_request(:get, '/sapi/v1/staking/personalLeftQuota', params: kwargs.merge(product: product, productId: productId))
133
+ end
134
+ end
135
+ end
136
+ end
@@ -548,6 +548,87 @@ module Binance
548
548
  amount: amount
549
549
  ))
550
550
  end
551
+
552
+ # Enable or Disable IP Restriction for a Sub-account API Key (For Master Account)
553
+ #
554
+ # POST /sapi/v1/sub-account/subAccountApi/ipRestriction
555
+ #
556
+ # @param email [String]
557
+ # @param subAccountApiKey [String]
558
+ # @param ipRestrict [Boolean]
559
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
560
+ # @see https://binance-docs.github.io/apidocs/spot/en/#enable-or-disable-ip-restriction-for-a-sub-account-api-key-for-master-account
561
+ def sub_account_toggle_ip_restriction(email:, subAccountApiKey:, ipRestrict:, **kwargs)
562
+ Binance::Utils::Validation.require_param('email', email)
563
+ Binance::Utils::Validation.require_param('subAccountApiKey', subAccountApiKey)
564
+ Binance::Utils::Validation.require_param('ipRestrict', ipRestrict)
565
+
566
+ @session.sign_request(:post, '/sapi/v1/sub-account/subAccountApi/ipRestriction', params: kwargs.merge(
567
+ email: email,
568
+ subAccountApiKey: subAccountApiKey,
569
+ ipRestrict: ipRestrict
570
+ ))
571
+ end
572
+
573
+ # Add IP List for a Sub-account API Key (For Master Account)
574
+ #
575
+ # POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList
576
+ #
577
+ # @param email [String]
578
+ # @param subAccountApiKey [String]
579
+ # @param ipAddress [String]
580
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
581
+ # @see https://binance-docs.github.io/apidocs/spot/en/#add-ip-list-for-a-sub-account-api-key-for-master-account
582
+ def sub_account_add_ip_list(email:, subAccountApiKey:, ipAddress:, **kwargs)
583
+ Binance::Utils::Validation.require_param('email', email)
584
+ Binance::Utils::Validation.require_param('subAccountApiKey', subAccountApiKey)
585
+ Binance::Utils::Validation.require_param('ipAddress', ipAddress)
586
+
587
+ @session.sign_request(:post, '/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList', params: kwargs.merge(
588
+ email: email,
589
+ subAccountApiKey: subAccountApiKey,
590
+ ipAddress: ipAddress
591
+ ))
592
+ end
593
+
594
+ # Get IP Restriction for a Sub-account API Key (For Master Account)
595
+ #
596
+ # GET /sapi/v1/sub-account/subAccountApi/ipRestriction
597
+ #
598
+ # @param email [String]
599
+ # @param subAccountApiKey [String]
600
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
601
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-ip-restriction-for-a-sub-account-api-key-for-master-account
602
+ def sub_account_ip_list(email:, subAccountApiKey:, **kwargs)
603
+ Binance::Utils::Validation.require_param('email', email)
604
+ Binance::Utils::Validation.require_param('subAccountApiKey', subAccountApiKey)
605
+
606
+ @session.sign_request(:get, '/sapi/v1/sub-account/subAccountApi/ipRestriction', params: kwargs.merge(
607
+ email: email,
608
+ subAccountApiKey: subAccountApiKey
609
+ ))
610
+ end
611
+
612
+ # Delete IP List For a Sub-account API Key (For Master Account)
613
+ #
614
+ # DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList
615
+ #
616
+ # @param email [String]
617
+ # @param subAccountApiKey [String]
618
+ # @param ipAddress [String]
619
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
620
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-ip-restriction-for-a-sub-account-api-key-for-master-account
621
+ def sub_account_delete_ip_list(email:, subAccountApiKey:, ipAddress:, **kwargs)
622
+ Binance::Utils::Validation.require_param('email', email)
623
+ Binance::Utils::Validation.require_param('subAccountApiKey', subAccountApiKey)
624
+ Binance::Utils::Validation.require_param('ipAddress', ipAddress)
625
+
626
+ @session.sign_request(:delete, '/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList', params: kwargs.merge(
627
+ email: email,
628
+ subAccountApiKey: subAccountApiKey,
629
+ ipAddress: ipAddress
630
+ ))
631
+ end
551
632
  end
552
633
  end
553
634
  end
@@ -289,6 +289,44 @@ module Binance
289
289
  def get_order_rate_limit(**kwargs)
290
290
  @session.sign_request(:get, '/api/v3/rateLimit/order', params: kwargs)
291
291
  end
292
+
293
+ # Cancel an Existing Order and Send a New Order (TRADE)
294
+ #
295
+ # POST /api/v3/order/cancelReplace
296
+ #
297
+ # @param symbol [String] the symbol
298
+ # @param side [String]
299
+ # @param type [String]
300
+ # @param cancelReplaceMode [String] STOP_ON_FAILURE or ALLOW_FAILURE
301
+ # @param kwargs [Hash]
302
+ # @option kwargs [String] :timeInForce
303
+ # @option kwargs [Float] :quantity
304
+ # @option kwargs [Float] :quoteOrderQty
305
+ # @option kwargs [Float] :price
306
+ # @option kwargs [String] :cancelNewClientOrderId
307
+ # @option kwargs [String] :cancelOrigClientOrderId
308
+ # @option kwargs [Integer] :cancelOrderId
309
+ # @option kwargs [String] :newClientOrderId
310
+ # @option kwargs [Float] :stopPrice
311
+ # @option kwargs [Integer] :trailingDelta
312
+ # @option kwargs [Float] :icebergQty
313
+ # @option kwargs [String] :newOrderRespType
314
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
315
+ # @see https://binance-docs.github.io/apidocs/spot/en/#cancel-an-existing-order-and-send-a-new-order-trade
316
+ def cancel_replace(symbol:, side:, type:, cancelReplaceMode:, **kwargs)
317
+ Binance::Utils::Validation.require_param('symbol', symbol)
318
+ Binance::Utils::Validation.require_param('side', side)
319
+ Binance::Utils::Validation.require_param('type', type)
320
+ Binance::Utils::Validation.require_param('cancelReplaceMode', cancelReplaceMode)
321
+
322
+ @session.sign_request(:post, '/api/v3/order/cancelReplace',
323
+ params: kwargs.merge(
324
+ symbol: symbol,
325
+ side: side,
326
+ type: type,
327
+ cancelReplaceMode: cancelReplaceMode
328
+ ))
329
+ end
292
330
  end
293
331
  end
294
332
  end
@@ -311,6 +311,19 @@ module Binance
311
311
  def api_key_permission(**kwargs)
312
312
  @session.sign_request(:get, '/sapi/v1/account/apiRestrictions', params: kwargs)
313
313
  end
314
+
315
+ # User Asset (USER_DATA)
316
+ #
317
+ # POST /sapi/v3/asset/getUserAsset
318
+ #
319
+ # @param kwargs [Hash]
320
+ # @option kwargs [String] :asset If asset is blank, then query all positive assets user have.
321
+ # @option kwargs [Boolean] :needBtcValuation
322
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
323
+ # @see https://binance-docs.github.io/apidocs/spot/en/#user-asset-user_data
324
+ def get_user_asset(**kwargs)
325
+ @session.sign_request(:post, '/sapi/v3/asset/getUserAsset', params: kwargs)
326
+ end
314
327
  end
315
328
  end
316
329
  end
@@ -126,6 +126,30 @@ module Binance
126
126
  create_connection(url, callbacks)
127
127
  end
128
128
 
129
+ # Individual Symbol Rolling Window Statistics Streams
130
+ # Rolling window ticker statistics for a single symbol, computed over multiple windows.
131
+ # Stream Name: <symbol>@ticker_<window_size>
132
+ # Window Sizes: 1h,4h
133
+ # Update Speed: 1000ms
134
+ #
135
+ # @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-rolling-window-statistics-streams
136
+ def rolling_window_ticker(symbol:, windowSize:, callbacks:)
137
+ url = "#{@base_url}/ws/#{symbol.downcase}@ticker_#{windowSize}"
138
+ create_connection(url, callbacks)
139
+ end
140
+
141
+ # All Market Rolling Window Statistics Streams
142
+ # Rolling window ticker statistics for all market symbols, computed over multiple windows. Note that only tickers that have changed will be present in the array.
143
+ # Stream Name: !ticker_<window-size>@arr
144
+ # Window Sizes: 1h, 4h
145
+ # Update Speed: 1000ms
146
+ #
147
+ # @see https://binance-docs.github.io/apidocs/spot/en/#all-market-rolling-window-statistics-streams
148
+ def rolling_window_ticker_all_symbols(windowSize:, callbacks:)
149
+ url = "#{@base_url}/ws/!ticker_#{windowSize}@arr"
150
+ create_connection(url, callbacks)
151
+ end
152
+
129
153
  # Subscribe to a stream manually
130
154
  # subscribe(stream: "btcusdt@miniTicker") or
131
155
  # subscribe(stream: ["btcusdt@miniTicker", "ethusdt@miniTicker"])
data/lib/binance/spot.rb CHANGED
@@ -8,6 +8,7 @@ require 'binance/error'
8
8
  require 'binance/spot/blvt'
9
9
  require 'binance/spot/bswap'
10
10
  require 'binance/spot/c2c'
11
+ require 'binance/spot/convert'
11
12
  require 'binance/spot/fiat'
12
13
  require 'binance/spot/futures'
13
14
  require 'binance/spot/loan'
@@ -15,6 +16,7 @@ require 'binance/spot/margin'
15
16
  require 'binance/spot/market'
16
17
  require 'binance/spot/mining'
17
18
  require 'binance/spot/savings'
19
+ require 'binance/spot/staking'
18
20
  require 'binance/spot/stream'
19
21
  require 'binance/spot/subaccount'
20
22
  require 'binance/spot/trade'
@@ -26,6 +28,7 @@ module Binance
26
28
  # - Blvt
27
29
  # - Bswap
28
30
  # - C2C
31
+ # - Convert
29
32
  # - Fiat
30
33
  # - Futures
31
34
  # - Loan
@@ -42,6 +45,7 @@ module Binance
42
45
  include Binance::Spot::Blvt
43
46
  include Binance::Spot::Bswap
44
47
  include Binance::Spot::C2C
48
+ include Binance::Spot::Convert
45
49
  include Binance::Spot::Fiat
46
50
  include Binance::Spot::Futures
47
51
  include Binance::Spot::Loan
@@ -49,6 +53,7 @@ module Binance
49
53
  include Binance::Spot::Market
50
54
  include Binance::Spot::Mining
51
55
  include Binance::Spot::Savings
56
+ include Binance::Spot::Staking
52
57
  include Binance::Spot::Stream
53
58
  include Binance::Spot::Subaccount
54
59
  include Binance::Spot::Trade
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Binance
4
- VERSION = '1.0.3'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binance-connector-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Binance
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.3'
97
97
  description: ''
98
- email:
98
+ email:
99
99
  executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
@@ -111,6 +111,7 @@ files:
111
111
  - lib/binance/spot/blvt.rb
112
112
  - lib/binance/spot/bswap.rb
113
113
  - lib/binance/spot/c2c.rb
114
+ - lib/binance/spot/convert.rb
114
115
  - lib/binance/spot/fiat.rb
115
116
  - lib/binance/spot/futures.rb
116
117
  - lib/binance/spot/loan.rb
@@ -118,6 +119,7 @@ files:
118
119
  - lib/binance/spot/market.rb
119
120
  - lib/binance/spot/mining.rb
120
121
  - lib/binance/spot/savings.rb
122
+ - lib/binance/spot/staking.rb
121
123
  - lib/binance/spot/stream.rb
122
124
  - lib/binance/spot/subaccount.rb
123
125
  - lib/binance/spot/trade.rb
@@ -135,10 +137,8 @@ homepage: https://github.com/binance/binance-connector-ruby
135
137
  licenses:
136
138
  - MIT
137
139
  metadata:
138
- homepage_uri: https://github.com/binance/binance-connector-ruby
139
- documentation_uri: https://binance-docs.github.io/apidocs/spot/en/
140
- source_code_uri: https://github.com/binance/binance-connector-ruby
141
- post_install_message:
140
+ rubygems_mfa_required: 'true'
141
+ post_install_message:
142
142
  rdoc_options: []
143
143
  require_paths:
144
144
  - lib
@@ -153,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.1.2
157
- signing_key:
156
+ rubygems_version: 3.3.3
157
+ signing_key:
158
158
  specification_version: 4
159
159
  summary: This is a lightweight library that works as a connector to the Binance public
160
160
  API.