bitmart 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bitmart/api_account.rb +4 -2
- data/lib/bitmart/api_contract.rb +4 -2
- data/lib/bitmart/api_spot.rb +45 -42
- data/lib/bitmart/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 620f2db1c9a04bbbb681640d6e179ade9ac5870aed4a9eac95cfcacca9883854
|
4
|
+
data.tar.gz: 3991d403df9cccf13ada8a2bd310e2b358e3f3d0bdc1bbb7ea807e6456455ba8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd38ec38f26c1fa0cfe411eab748dfcdb9d1754af4013a41508740bc4d5c32d74df0cdce552b173c55d00c3966bc7278311545bcf629c7feae8a18608f2a4331
|
7
|
+
data.tar.gz: a9a5dc94a13130ca2bf077fee1b32fd5ca8d8958318f430933d6e1fef21cfe1b31ca17510ba9a370cfe41d16cadeba0100e5554c928c60b2c4a3ee72ce85bc7b
|
data/Gemfile.lock
CHANGED
data/lib/bitmart/api_account.rb
CHANGED
@@ -109,6 +109,7 @@ module Bitmart
|
|
109
109
|
@_client ||= Faraday.new(API_ENDPOINT) do |client|
|
110
110
|
client.request :url_encoded
|
111
111
|
client.adapter Faraday.default_adapter
|
112
|
+
client.headers["Content-Type"] = "application/json"
|
112
113
|
client.headers['X-BM-KEY'] = api_key unless api_key&.nil?
|
113
114
|
client.headers['X-BM-SIGN'] = @signature if @signature
|
114
115
|
client.headers['X-BM-TIMESTAMP'] = @timestamp if @timestamp
|
@@ -116,9 +117,10 @@ module Bitmart
|
|
116
117
|
end
|
117
118
|
|
118
119
|
def request(http_method:, endpoint:, params: {})
|
119
|
-
|
120
|
+
if http_method == :post
|
120
121
|
@timestamp = Bitmart::API::System.new.get_system_time["data"]["server_time"].to_s
|
121
|
-
|
122
|
+
params = Oj.dump(params)
|
123
|
+
data = [timestamp,"#",api_memo,"#",params].join
|
122
124
|
@signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_sign, data)
|
123
125
|
end
|
124
126
|
response = client.public_send(http_method, endpoint, params)
|
data/lib/bitmart/api_contract.rb
CHANGED
@@ -272,6 +272,7 @@ module Bitmart
|
|
272
272
|
@_client ||= Faraday.new(API_ENDPOINT) do |client|
|
273
273
|
client.request :url_encoded
|
274
274
|
client.adapter Faraday.default_adapter
|
275
|
+
client.headers["Content-Type"] = "application/json"
|
275
276
|
client.headers['X-BM-KEY'] = api_key unless api_key&.nil?
|
276
277
|
client.headers['X-BM-SIGN'] = @signature if @signature
|
277
278
|
client.headers['X-BM-TIMESTAMP'] = @timestamp if @timestamp
|
@@ -279,9 +280,10 @@ module Bitmart
|
|
279
280
|
end
|
280
281
|
|
281
282
|
def request(http_method:, endpoint:, params: {})
|
282
|
-
|
283
|
+
if http_method == :post
|
283
284
|
@timestamp = Bitmart::API::System.new.get_system_time["data"]["server_time"].to_s
|
284
|
-
|
285
|
+
params = Oj.dump(params)
|
286
|
+
data = [timestamp,"#",api_memo,"#",params].join
|
285
287
|
@signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_sign, data)
|
286
288
|
end
|
287
289
|
response = client.public_send(http_method, endpoint, params)
|
data/lib/bitmart/api_spot.rb
CHANGED
@@ -53,7 +53,7 @@ module Bitmart
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def get_symbol_ticker(symbol)
|
56
|
-
params = {'symbol'
|
56
|
+
params = {'symbol' => symbol}
|
57
57
|
request(
|
58
58
|
http_method: :get,
|
59
59
|
endpoint: "ticker",
|
@@ -72,10 +72,10 @@ module Bitmart
|
|
72
72
|
# GET https://api-cloud.bitmart.com/spot/v1/symbols/kline
|
73
73
|
def get_symbol_kline(symbol, fromTime, toTime, step = 1)
|
74
74
|
params = {
|
75
|
-
'symbol'
|
76
|
-
'from'
|
77
|
-
'to'
|
78
|
-
'step'
|
75
|
+
'symbol' => symbol,
|
76
|
+
'from' => fromTime,
|
77
|
+
'to' => toTime,
|
78
|
+
'step' => step
|
79
79
|
}
|
80
80
|
request(
|
81
81
|
http_method: :get,
|
@@ -87,7 +87,7 @@ module Bitmart
|
|
87
87
|
# GET https://api-cloud.bitmart.com/spot/v1/symbols/book
|
88
88
|
def get_symbol_book(symbol, precision = nil, size = nil)
|
89
89
|
params = {
|
90
|
-
'symbol'
|
90
|
+
'symbol' => symbol
|
91
91
|
}
|
92
92
|
param['precision'] = precision if precision
|
93
93
|
param['size'] = size if size
|
@@ -101,7 +101,7 @@ module Bitmart
|
|
101
101
|
# GET https://api-cloud.bitmart.com/spot/v1/symbols/trades
|
102
102
|
def get_symbol_trades(symbol)
|
103
103
|
params = {
|
104
|
-
'symbol'
|
104
|
+
'symbol' => symbol
|
105
105
|
}
|
106
106
|
request(
|
107
107
|
http_method: :get,
|
@@ -123,11 +123,11 @@ module Bitmart
|
|
123
123
|
# POST https://api-cloud.bitmart.com/spot/v1/submit_order
|
124
124
|
def post_submit_limit_buy_order(symbol, size='', price='')
|
125
125
|
params = {
|
126
|
-
'price'
|
127
|
-
'side'
|
128
|
-
'size'
|
129
|
-
'symbol'
|
130
|
-
'type'
|
126
|
+
'price' => price,
|
127
|
+
'side' => 'buy',
|
128
|
+
'size' => size,
|
129
|
+
'symbol' => symbol,
|
130
|
+
'type' => 'limit',
|
131
131
|
}
|
132
132
|
request(
|
133
133
|
http_method: :post,
|
@@ -138,11 +138,11 @@ module Bitmart
|
|
138
138
|
|
139
139
|
def post_submit_limit_sell_order(symbol, size='', price='')
|
140
140
|
params = {
|
141
|
-
'price'
|
142
|
-
'side'
|
143
|
-
'size'
|
144
|
-
'symbol'
|
145
|
-
'type'
|
141
|
+
'price' => price,
|
142
|
+
'side' => 'sell',
|
143
|
+
'size' => size,
|
144
|
+
'symbol' => symbol,
|
145
|
+
'type' => 'limit',
|
146
146
|
}
|
147
147
|
request(
|
148
148
|
http_method: :post,
|
@@ -153,10 +153,10 @@ module Bitmart
|
|
153
153
|
|
154
154
|
def post_submit_market_sell_order(symbol, size='')
|
155
155
|
params = {
|
156
|
-
'side'
|
157
|
-
'size'
|
158
|
-
'symbol'
|
159
|
-
'type'
|
156
|
+
'side' => 'sell',
|
157
|
+
'size' => size,
|
158
|
+
'symbol' => symbol,
|
159
|
+
'type' => 'market',
|
160
160
|
}
|
161
161
|
request(
|
162
162
|
http_method: :post,
|
@@ -167,10 +167,10 @@ module Bitmart
|
|
167
167
|
|
168
168
|
def post_submit_market_buy_order(symbol, notional='')
|
169
169
|
params = {
|
170
|
-
'notional'
|
171
|
-
'side'
|
172
|
-
'symbol'
|
173
|
-
'type'
|
170
|
+
'notional' => notional,
|
171
|
+
'side' => 'buy',
|
172
|
+
'symbol' => symbol,
|
173
|
+
'type' => 'market',
|
174
174
|
}
|
175
175
|
request(
|
176
176
|
http_method: :post,
|
@@ -182,8 +182,8 @@ module Bitmart
|
|
182
182
|
# POST https://api-cloud.bitmart.com/spot/v2/cancel_order
|
183
183
|
def post_cancel_order(symbol, orderId)
|
184
184
|
params = {
|
185
|
-
'order_id'
|
186
|
-
'symbol'
|
185
|
+
'order_id' => orderId,
|
186
|
+
'symbol' => symbol,
|
187
187
|
}
|
188
188
|
request(
|
189
189
|
http_method: :post,
|
@@ -195,8 +195,8 @@ module Bitmart
|
|
195
195
|
# POST https://api-cloud.bitmart.com/spot/v1/cancel_orders
|
196
196
|
def post_cancel_orders(symbol, side)
|
197
197
|
params = {
|
198
|
-
'side'
|
199
|
-
'symbol'
|
198
|
+
'side' => side,
|
199
|
+
'symbol' => symbol,
|
200
200
|
}
|
201
201
|
request(
|
202
202
|
http_method: :post,
|
@@ -208,8 +208,8 @@ module Bitmart
|
|
208
208
|
# GET https://api-cloud.bitmart.com/spot/v1/order_detail
|
209
209
|
def get_user_order_detail(symbol, orderId)
|
210
210
|
params = {
|
211
|
-
'order_id'
|
212
|
-
'symbol'
|
211
|
+
'order_id' => orderId,
|
212
|
+
'symbol' => symbol,
|
213
213
|
}
|
214
214
|
request(
|
215
215
|
http_method: :get,
|
@@ -221,10 +221,10 @@ module Bitmart
|
|
221
221
|
# GET https://api-cloud.bitmart.com/spot/v1/orders
|
222
222
|
def get_user_orders(symbol, offset, limit, status)
|
223
223
|
params = {
|
224
|
-
'limit'
|
225
|
-
'offset'
|
226
|
-
'status'
|
227
|
-
'symbol'
|
224
|
+
'limit' => limit,
|
225
|
+
'offset' => offset,
|
226
|
+
'status' => status,
|
227
|
+
'symbol' => symbol,
|
228
228
|
}
|
229
229
|
request(
|
230
230
|
http_method: :get,
|
@@ -236,8 +236,8 @@ module Bitmart
|
|
236
236
|
# GET https://api-cloud.bitmart.com/spot/v1/trades
|
237
237
|
def get_user_order_trades(symbol, orderId)
|
238
238
|
params = {
|
239
|
-
'order_id'
|
240
|
-
'symbol'
|
239
|
+
'order_id' => orderId,
|
240
|
+
'symbol' => symbol
|
241
241
|
}
|
242
242
|
request(
|
243
243
|
http_method: :get,
|
@@ -248,9 +248,9 @@ module Bitmart
|
|
248
248
|
|
249
249
|
def get_user_trades(symbol, offset, limit)
|
250
250
|
params = {
|
251
|
-
'limit'
|
252
|
-
'offset'
|
253
|
-
'symbol'
|
251
|
+
'limit' => limit,
|
252
|
+
'offset' => offset,
|
253
|
+
'symbol' => symbol,
|
254
254
|
}
|
255
255
|
request(
|
256
256
|
http_method: :get,
|
@@ -265,6 +265,7 @@ module Bitmart
|
|
265
265
|
@_client ||= Faraday.new(API_ENDPOINT) do |client|
|
266
266
|
client.request :url_encoded
|
267
267
|
client.adapter Faraday.default_adapter
|
268
|
+
client.headers["Content-Type"] = "application/json"
|
268
269
|
client.headers['X-BM-KEY'] = api_key unless api_key&.nil?
|
269
270
|
client.headers['X-BM-SIGN'] = @signature if @signature
|
270
271
|
client.headers['X-BM-TIMESTAMP'] = @timestamp if @timestamp
|
@@ -272,9 +273,11 @@ module Bitmart
|
|
272
273
|
end
|
273
274
|
|
274
275
|
def request(http_method:, endpoint:, params: {})
|
275
|
-
|
276
|
+
puts http_method
|
277
|
+
if http_method == :post
|
276
278
|
@timestamp = Bitmart::API::System.new.get_system_time["data"]["server_time"].to_s
|
277
|
-
|
279
|
+
params = Oj.dump(params)
|
280
|
+
data = [timestamp,"#",api_memo,"#",params].join
|
278
281
|
@signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_sign, data)
|
279
282
|
end
|
280
283
|
response = client.public_send(http_method, endpoint, params)
|
data/lib/bitmart/version.rb
CHANGED