binance-connector-ruby 1.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: 7facfdf6b9532826bcb09f079db1d45d927c7fa05f8431694729ff4268d4d336
4
- data.tar.gz: 943f98d14fe1167239695f1134c40cc068ddaa4c63fe8545f40f2746e5de0264
3
+ metadata.gz: 1b029d14cae7ec52f77a9f61775eba15eb33027f47983f2184e49731c5de746a
4
+ data.tar.gz: 5ecb20e8b7544668b2e4306a5f70548b9e3ce92696f9111b4e4ba4f88b7e4fa4
5
5
  SHA512:
6
- metadata.gz: bb5ac1a51601bef15a2adf1d588c941e125d0cc90bcc836660496c93da6aaf2a4755ecc8a50f8d759f1e0e7550f64c6944aa4c33e0fbae5f72f512c068aa6ef5
7
- data.tar.gz: 1d25971c4d4857a14e00e818a1cfe9c2cf6c8b1b595aafb43a616be8abc2798e4b734e2d37b0b57557fe86fe5c2c809b78b47066ef32f06b9c631ecbaba530c0
6
+ metadata.gz: 1b779f8bf2a01f165f68748c37385d3a4bf79e9e887a82f5d23c08b111b697cb2280c60c9cfe4609b5c061218f008c4b58dd81e7457e26a7f76dfbafc7f1226e
7
+ data.tar.gz: 25e0a750c7db5fb5dd26889548d26aa3a3c1e96b0a13ab21898623a79c69393f1df025a4f7b0c3ea6d6ad893d197544d3e24145be6b0a1e335af28dd42a9d19b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0 - 2022-07-15
4
+
5
+ ### Add
6
+ - Sub account endpoints
7
+ - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` to support master account enable and disable IP restriction for a sub-account API Key
8
+ - `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` to support master account add IP list for a sub-account API Key
9
+ - `GET /sapi/v1/account/apiRestrictions/ipRestriction` to support master account query IP restriction for a sub-account API Key
10
+ - `DELETE /sapi/v1/account/apiRestrictions/ipRestriction/ipList` to support master account delete IP list for a sub-account API Key
11
+ - Market endpoint
12
+ - `GET /api/v3/ticker`
13
+ - Trade endpoint
14
+ - `POST /api/v3/order/cancelReplace`
15
+ - Websocket methods
16
+ - `<symbol>@ticker_<window_size>`
17
+ - `!ticker_<window-size>@arr`
18
+
19
+
3
20
  ## 1.1.0 - 2022-06-09
4
21
 
5
22
  ### Add
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
@@ -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
@@ -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
@@ -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"])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Binance
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.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.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Binance
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler