binance-connector-ruby 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,269 @@
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 Savings
8
+ # Get Flexible Product List (USER_DATA)
9
+ #
10
+ # GET /sapi/v1/lending/daily/product/list
11
+ #
12
+ # @param kwargs [Hash]
13
+ # @option kwargs [String] :status "ALL", "SUBSCRIBABLE", "UNSUBSCRIBABLE"; Default: "ALL"
14
+ # @option kwargs [String] :featured "ALL", "TRUE"; Default: "ALL"
15
+ # @option kwargs [Integer] :current Current query page. Default: 1, Min: 1
16
+ # @option kwargs [Integer] :size Default: 50, Max: 100
17
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
18
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-product-list-user_data
19
+ def savings_flexible_products(**kwargs)
20
+ @session.sign_request(:get, '/sapi/v1/lending/daily/product/list', params: kwargs)
21
+ end
22
+
23
+ # Get Left Daily Purchase Quota of Flexible Product (USER_DATA)
24
+ #
25
+ # GET /sapi/v1/lending/daily/userLeftQuota
26
+ #
27
+ # @param productId [String]
28
+ # @param kwargs [Hash]
29
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
30
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-left-daily-purchase-quota-of-flexible-product-user_data
31
+ def savings_flexible_user_left_quota(productId:, **kwargs)
32
+ Binance::Utils::Validation.require_param('productId', productId)
33
+
34
+ @session.sign_request(:get, '/sapi/v1/lending/daily/userLeftQuota', params: kwargs.merge(
35
+ productId: productId
36
+ ))
37
+ end
38
+
39
+ # Purchase Flexible Product (USER_DATA)
40
+ #
41
+ # POST /sapi/v1/lending/daily/purchase
42
+ #
43
+ # @param productId [String]
44
+ # @param amount [Float]
45
+ # @param kwargs [Hash]
46
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
47
+ # @see https://binance-docs.github.io/apidocs/spot/en/#purchase-flexible-product-user_data
48
+ def savings_purchase_flexible_product(productId:, amount:, **kwargs)
49
+ Binance::Utils::Validation.require_param('productId', productId)
50
+ Binance::Utils::Validation.require_param('amount', amount)
51
+
52
+ @session.sign_request(:post, '/sapi/v1/lending/daily/purchase', params: kwargs.merge(
53
+ productId: productId,
54
+ amount: amount
55
+ ))
56
+ end
57
+
58
+ # Get Left Daily Redemption Quota of Flexible Product (USER_DATA)
59
+ #
60
+ # GET /sapi/v1/lending/daily/userRedemptionQuota
61
+ #
62
+ # @param productId [String]
63
+ # @param type [String] "FAST", "NORMAL"
64
+ # @param kwargs [Hash]
65
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
66
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-left-daily-redemption-quota-of-flexible-product-user_data
67
+ def savings_flexible_user_redemption_quota(productId:, type:, **kwargs)
68
+ Binance::Utils::Validation.require_param('productId', productId)
69
+ Binance::Utils::Validation.require_param('type', type)
70
+
71
+ @session.sign_request(:get, '/sapi/v1/lending/daily/userRedemptionQuota', params: kwargs.merge(
72
+ productId: productId,
73
+ type: type
74
+ ))
75
+ end
76
+
77
+ # Redeem Flexible Product (USER_DATA)
78
+ #
79
+ # POST /sapi/v1/lending/daily/redeem
80
+ #
81
+ # @param productId [String]
82
+ # @param amount [Float]]
83
+ # @param type [String]
84
+ # @param kwargs [Hash]
85
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
86
+ # @see https://binance-docs.github.io/apidocs/spot/en/#redeem-flexible-product-user_data
87
+ def savings_flexible_redeem(productId:, amount:, type:, **kwargs)
88
+ Binance::Utils::Validation.require_param('productId', productId)
89
+ Binance::Utils::Validation.require_param('amount', amount)
90
+ Binance::Utils::Validation.require_param('type', type)
91
+
92
+ @session.sign_request(:post, '/sapi/v1/lending/daily/redeem', params: kwargs.merge(
93
+ productId: productId,
94
+ amount: amount,
95
+ type: type
96
+ ))
97
+ end
98
+
99
+ # Get Flexible Product Position (USER_DATA)
100
+ #
101
+ # GET /sapi/v1/lending/daily/token/position
102
+ #
103
+ # @param asset [String]
104
+ # @param kwargs [Hash]
105
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
106
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-product-position-user_data
107
+ def savings_flexible_product_position(asset:, **kwargs)
108
+ Binance::Utils::Validation.require_param('asset', asset)
109
+
110
+ @session.sign_request(:get, '/sapi/v1/lending/daily/token/position', params: kwargs.merge(
111
+ asset: asset
112
+ ))
113
+ end
114
+
115
+ # Get Fixed and Activity Project List(USER_DATA)
116
+ #
117
+ # GET /sapi/v1/lending/project/list
118
+ #
119
+ # @param type [String] "REGULAR", "CUSTOMIZED_FIXED"
120
+ # @param kwargs [Hash]
121
+ # @option kwargs [String] :asset
122
+ # @option kwargs [String] :status "ALL", "SUBSCRIBABLE", "UNSUBSCRIBABLE"; default "ALL"
123
+ # @option kwargs [Boolean] :isSortAsc default "true"
124
+ # @option kwargs [String] :sortBy "START_TIME", "LOT_SIZE", "INTEREST_RATE", "DURATION"; default "START_TIME"
125
+ # @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
126
+ # @option kwargs [Integer] :size Default:10, Max:100
127
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
128
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-fixed-and-activity-project-list-user_data
129
+ def savings_product_list(type:, **kwargs)
130
+ Binance::Utils::Validation.require_param('type', type)
131
+
132
+ @session.sign_request(:get, '/sapi/v1/lending/project/list', params: kwargs.merge(
133
+ type: type
134
+ ))
135
+ end
136
+
137
+ # Purchase Fixed/Activity Project (USER_DATA)
138
+ #
139
+ # POST /sapi/v1/lending/customizedFixed/purchase
140
+ #
141
+ # @param projectId [String]
142
+ # @param lot [String]
143
+ # @param kwargs [Hash]
144
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
145
+ # @see https://binance-docs.github.io/apidocs/spot/en/#purchase-fixed-activity-project-user_data
146
+ def savings_purchase_customized_project(projectId:, lot:, **kwargs)
147
+ Binance::Utils::Validation.require_param('projectId', projectId)
148
+ Binance::Utils::Validation.require_param('lot', lot)
149
+
150
+ @session.sign_request(:post, '/sapi/v1/lending/customizedFixed/purchase', params: kwargs.merge(
151
+ projectId: projectId,
152
+ lot: lot
153
+ ))
154
+ end
155
+
156
+ # Get Fixed/Activity Project Position (USER_DATA)
157
+ #
158
+ # GET /sapi/v1/lending/project/position/list
159
+ #
160
+ # @param asset [String]
161
+ # @param kwargs [Hash]
162
+ # @option kwargs [String] :projectId
163
+ # @option kwargs [String] :status "HOLDING", "REDEEMED"
164
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
165
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-fixed-activity-project-position-user_data
166
+ def savings_customized_position(asset:, **kwargs)
167
+ Binance::Utils::Validation.require_param('asset', asset)
168
+
169
+ @session.sign_request(:get, '/sapi/v1/lending/project/position/list', params: kwargs.merge(
170
+ asset: asset
171
+ ))
172
+ end
173
+
174
+ # Lending Account (USER_DATA)
175
+ #
176
+ # GET /sapi/v1/lending/union/account
177
+ #
178
+ # @param kwargs [Hash]
179
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
180
+ # @see https://binance-docs.github.io/apidocs/spot/en/#lending-account-user_data
181
+ def savings_account(**kwargs)
182
+ @session.sign_request(:get, '/sapi/v1/lending/union/account', params: kwargs)
183
+ end
184
+
185
+ # Get Purchase Record (USER_DATA)
186
+ #
187
+ # GET /sapi/v1/lending/union/purchaseRecord
188
+ #
189
+ # @param lendingType [String]
190
+ # @param kwargs [Hash]
191
+ # @option kwargs [String] :asset
192
+ # @option kwargs [Integer] :startTime
193
+ # @option kwargs [Integer] :endTime
194
+ # @option kwargs [Integer] :current
195
+ # @option kwargs [Integer] :size
196
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
197
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-purchase-record-user_data
198
+ def savings_purchase_record(lendingType:, **kwargs)
199
+ Binance::Utils::Validation.require_param('lendingType', lendingType)
200
+
201
+ @session.sign_request(:get, '/sapi/v1/lending/union/purchaseRecord', params: kwargs.merge(
202
+ lendingType: lendingType
203
+ ))
204
+ end
205
+
206
+ # Get Redemption Record (USER_DATA)
207
+ #
208
+ # GET /sapi/v1/lending/union/redemptionRecord
209
+ #
210
+ # @param lendingType [String]
211
+ # @param kwargs [Hash]
212
+ # @option kwargs [String] :asset
213
+ # @option kwargs [Integer] :startTime
214
+ # @option kwargs [Integer] :endTime
215
+ # @option kwargs [Integer] :current
216
+ # @option kwargs [Integer] :size
217
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
218
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-redemption-record-user_data
219
+ def savings_redemption_record(lendingType:, **kwargs)
220
+ Binance::Utils::Validation.require_param('lendingType', lendingType)
221
+
222
+ @session.sign_request(:get, '/sapi/v1/lending/union/redemptionRecord', params: kwargs.merge(
223
+ lendingType: lendingType
224
+ ))
225
+ end
226
+
227
+ # Get Interest History (USER_DATA)
228
+ #
229
+ # GET /sapi/v1/lending/union/interestHistory
230
+ #
231
+ # @param lendingType [String]
232
+ # @param kwargs [Hash]
233
+ # @option kwargs [String] :asset
234
+ # @option kwargs [Integer] :startTime
235
+ # @option kwargs [Integer] :endTime
236
+ # @option kwargs [Integer] :current
237
+ # @option kwargs [Integer] :size
238
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
239
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-interest-history-user_data-2
240
+ def savings_interest_history(lendingType:, **kwargs)
241
+ Binance::Utils::Validation.require_param('lendingType', lendingType)
242
+
243
+ @session.sign_request(:get, '/sapi/v1/lending/union/interestHistory', params: kwargs.merge(
244
+ lendingType: lendingType
245
+ ))
246
+ end
247
+
248
+ # Change Fixed/Activity Position to Daily Position(USER_DATA)
249
+ #
250
+ # POST /sapi/v1/lending/positionChanged
251
+ #
252
+ # @param projectId [String]
253
+ # @param lot [Integer]
254
+ # @param kwargs [Hash]
255
+ # @option kwargs [Integer] :positionId
256
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
257
+ # @see https://binance-docs.github.io/apidocs/spot/en/#change-fixed-activity-position-to-daily-position-user_data
258
+ def savings_position_changed(projectId:, lot:, **kwargs)
259
+ Binance::Utils::Validation.require_param('projectId', projectId)
260
+ Binance::Utils::Validation.require_param('lot', lot)
261
+
262
+ @session.sign_request(:post, '/sapi/v1/lending/positionChanged', params: kwargs.merge(
263
+ projectId: projectId,
264
+ lot: lot
265
+ ))
266
+ end
267
+ end
268
+ end
269
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # User data stream endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#user-data-streams
7
+ module Stream
8
+ # Create a ListenKey (USER_STREAM)
9
+ #
10
+ # POST /api/v3/userDataStream
11
+ def new_listen_key
12
+ @session.limit_request(method: :post, path: '/api/v3/userDataStream')
13
+ end
14
+
15
+ # Ping/Keep-alive a ListenKey (USER_STREAM)
16
+ #
17
+ # PUT /api/v3/userDataStream
18
+ #
19
+ # @param listenKey [String]
20
+ def renew_listen_key(listenKey)
21
+ @session.limit_request(method: :put, path: '/api/v3/userDataStream', params: { listenKey: listenKey })
22
+ end
23
+
24
+ # Close a ListenKey (USER_STREAM)
25
+ #
26
+ # DELETE /api/v3/userDataStream
27
+ #
28
+ # @param listenKey [String]
29
+ def delete_listen_key(listenKey)
30
+ @session.limit_request(method: :delete, path: '/api/v3/userDataStream', params: { listenKey: listenKey })
31
+ end
32
+
33
+ # Margin
34
+
35
+ # Create a ListenKey (USER_STREAM)
36
+ #
37
+ # POST /sapi/v1/userDataStream
38
+ def new_margin_listen_key
39
+ @session.limit_request(method: :post, path: '/sapi/v1/userDataStream')
40
+ end
41
+
42
+ # Ping/Keep-alive a ListenKey (USER_STREAM)
43
+ #
44
+ # PUT /sapi/v1/userDataStream
45
+ #
46
+ # @param listenKey [String]
47
+ def renew_margin_listen_key(listenKey)
48
+ @session.limit_request(method: :put, path: '/sapi/v1/userDataStream', params: { listenKey: listenKey })
49
+ end
50
+
51
+ # Close a ListenKey (USER_STREAM)
52
+ #
53
+ # DELETE /sapi/v1/userDataStream
54
+ #
55
+ # @param listenKey [String]
56
+ def delete_margin_listen_key(listenKey)
57
+ @session.limit_request(method: :delete, path: '/sapi/v1/userDataStream', params: { listenKey: listenKey })
58
+ end
59
+ end
60
+ end
61
+ end