Class: Bitmart::API::V1::Spot
- Inherits:
-
Object
- Object
- Bitmart::API::V1::Spot
- Defined in:
- lib/bitmart/api_spot.rb
Constant Summary collapse
- API_ENDPOINT =
'https://api-cloud.bitmart.com/spot/v1'.freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_memo ⇒ Object
readonly
Returns the value of attribute api_memo.
-
#api_sign ⇒ Object
readonly
Returns the value of attribute api_sign.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#get_currencies ⇒ Object
basic API GET api-cloud.bitmart.com/spot/v1/currencies.
- #get_steps ⇒ Object
- #get_symbol_book(symbol, precision = nil, size = nil) ⇒ Object
- #get_symbol_detail ⇒ Object
- #get_symbol_kline(symbol, fromTime, toTime, step = 1) ⇒ Object
- #get_symbol_ticker(symbol) ⇒ Object
- #get_symbol_trades(symbol) ⇒ Object
- #get_symbols ⇒ Object
- #get_ticker ⇒ Object
- #get_user_order_detail(symbol, orderId) ⇒ Object
- #get_user_order_trades(symbol, orderId) ⇒ Object
- #get_user_orders(symbol, offset, limit, status) ⇒ Object
- #get_user_trades(symbol, offset, limit) ⇒ Object
- #get_wallet ⇒ Object
-
#initialize(api_key = nil, api_sign = nil, api_memo = nil) ⇒ Spot
constructor
A new instance of Spot.
- #post_cancel_order(symbol, orderId) ⇒ Object
- #post_cancel_orders(symbol, side) ⇒ Object
- #post_submit_limit_buy_order(symbol, size = '', price = '') ⇒ Object
- #post_submit_limit_sell_order(symbol, size = '', price = '') ⇒ Object
- #post_submit_market_buy_order(symbol, notional = '') ⇒ Object
- #post_submit_market_sell_order(symbol, size = '') ⇒ Object
Constructor Details
#initialize(api_key = nil, api_sign = nil, api_memo = nil) ⇒ Spot
Returns a new instance of Spot.
16 17 18 19 20 |
# File 'lib/bitmart/api_spot.rb', line 16 def initialize(api_key = nil, api_sign = nil, api_memo = nil) @api_key = api_key @api_sign = api_sign @api_memo = api_memo end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/bitmart/api_spot.rb', line 10 def api_key @api_key end |
#api_memo ⇒ Object (readonly)
Returns the value of attribute api_memo.
12 13 14 |
# File 'lib/bitmart/api_spot.rb', line 12 def api_memo @api_memo end |
#api_sign ⇒ Object (readonly)
Returns the value of attribute api_sign.
11 12 13 |
# File 'lib/bitmart/api_spot.rb', line 11 def api_sign @api_sign end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
14 15 16 |
# File 'lib/bitmart/api_spot.rb', line 14 def signature @signature end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
13 14 15 |
# File 'lib/bitmart/api_spot.rb', line 13 def @timestamp end |
Instance Method Details
#get_currencies ⇒ Object
basic API GET api-cloud.bitmart.com/spot/v1/currencies
24 25 26 27 28 29 |
# File 'lib/bitmart/api_spot.rb', line 24 def get_currencies request( http_method: :get, endpoint: "currencies" ) end |
#get_steps ⇒ Object
65 66 67 68 69 70 |
# File 'lib/bitmart/api_spot.rb', line 65 def get_steps request( http_method: :get, endpoint: "steps" ) end |
#get_symbol_book(symbol, precision = nil, size = nil) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/bitmart/api_spot.rb', line 88 def get_symbol_book(symbol, precision = nil, size = nil) params = { 'symbol' => symbol } param['precision'] = precision if precision param['size'] = size if size request( http_method: :get, endpoint: "symbols/book", params: params ) end |
#get_symbol_detail ⇒ Object
40 41 42 43 44 45 |
# File 'lib/bitmart/api_spot.rb', line 40 def get_symbol_detail request( http_method: :get, endpoint: "symbols/details" ) end |
#get_symbol_kline(symbol, fromTime, toTime, step = 1) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bitmart/api_spot.rb', line 73 def get_symbol_kline(symbol, fromTime, toTime, step = 1) params = { 'symbol' => symbol, 'from' => fromTime, 'to' => toTime, 'step' => step } request( http_method: :get, endpoint: "symboles/kline", params: params ) end |
#get_symbol_ticker(symbol) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/bitmart/api_spot.rb', line 55 def get_symbol_ticker(symbol) params = {'symbol' => symbol} request( http_method: :get, endpoint: "ticker", params: params ) end |
#get_symbol_trades(symbol) ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/bitmart/api_spot.rb', line 102 def get_symbol_trades(symbol) params = { 'symbol' => symbol } request( http_method: :get, endpoint: "symbols/trades", params: params ) end |
#get_symbols ⇒ Object
32 33 34 35 36 37 |
# File 'lib/bitmart/api_spot.rb', line 32 def get_symbols request( http_method: :get, endpoint: "symbols" ) end |
#get_ticker ⇒ Object
48 49 50 51 52 53 |
# File 'lib/bitmart/api_spot.rb', line 48 def get_ticker request( http_method: :get, endpoint: "ticker" ) end |
#get_user_order_detail(symbol, orderId) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/bitmart/api_spot.rb', line 209 def get_user_order_detail(symbol, orderId) params = { 'order_id' => orderId, 'symbol' => symbol, } request( http_method: :get, endpoint: "order_detail", params: params ) end |
#get_user_order_trades(symbol, orderId) ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/bitmart/api_spot.rb', line 237 def get_user_order_trades(symbol, orderId) params = { 'order_id' => orderId, 'symbol' => symbol } request( http_method: :get, endpoint: "trades", params: params ) end |
#get_user_orders(symbol, offset, limit, status) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/bitmart/api_spot.rb', line 222 def get_user_orders(symbol, offset, limit, status) params = { 'limit' => limit, 'offset' => offset, 'status' => status, 'symbol' => symbol, } request( http_method: :get, endpoint: "orders", params: params ) end |
#get_user_trades(symbol, offset, limit) ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/bitmart/api_spot.rb', line 249 def get_user_trades(symbol, offset, limit) params = { 'limit' => limit, 'offset' => offset, 'symbol' => symbol, } request( http_method: :get, endpoint: "trades", params: params ) end |
#get_wallet ⇒ Object
116 117 118 119 120 121 |
# File 'lib/bitmart/api_spot.rb', line 116 def get_wallet request( http_method: :get, endpoint: "wallet" ) end |
#post_cancel_order(symbol, orderId) ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/bitmart/api_spot.rb', line 183 def post_cancel_order(symbol, orderId) params = { 'order_id' => orderId, 'symbol' => symbol, } request( http_method: :post, endpoint: "cancel_order", params: params ) end |
#post_cancel_orders(symbol, side) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/bitmart/api_spot.rb', line 196 def post_cancel_orders(symbol, side) params = { 'side' => side, 'symbol' => symbol, } request( http_method: :post, endpoint: "cancel_orders", params: params ) end |
#post_submit_limit_buy_order(symbol, size = '', price = '') ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/bitmart/api_spot.rb', line 124 def post_submit_limit_buy_order(symbol, size='', price='') params = { 'price' => price, 'side' => 'buy', 'size' => size, 'symbol' => symbol, 'type' => 'limit', } request( http_method: :post, endpoint: "submit_order", params: params ) end |
#post_submit_limit_sell_order(symbol, size = '', price = '') ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/bitmart/api_spot.rb', line 139 def post_submit_limit_sell_order(symbol, size='', price='') params = { 'price' => price, 'side' => 'sell', 'size' => size, 'symbol' => symbol, 'type' => 'limit', } request( http_method: :post, endpoint: "submit_order", params: params ) end |
#post_submit_market_buy_order(symbol, notional = '') ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/bitmart/api_spot.rb', line 168 def post_submit_market_buy_order(symbol, notional='') params = { 'notional' => notional, 'side' => 'buy', 'symbol' => symbol, 'type' => 'market', } request( http_method: :post, endpoint: "submit_order", params: params ) end |
#post_submit_market_sell_order(symbol, size = '') ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/bitmart/api_spot.rb', line 154 def post_submit_market_sell_order(symbol, size='') params = { 'side' => 'sell', 'size' => size, 'symbol' => symbol, 'type' => 'market', } request( http_method: :post, endpoint: "submit_order", params: params ) end |