kucoin-api 0.2.0

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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.rspec +2 -0
  4. data/.simplecov +7 -0
  5. data/.travis.yml +7 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +551 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/kucoin-api.gemspec +42 -0
  14. data/lib/kucoin/api.rb +34 -0
  15. data/lib/kucoin/api/endpoints.rb +117 -0
  16. data/lib/kucoin/api/endpoints/base.rb +58 -0
  17. data/lib/kucoin/api/endpoints/markets.rb +17 -0
  18. data/lib/kucoin/api/endpoints/markets/currencies.rb +24 -0
  19. data/lib/kucoin/api/endpoints/markets/histories.rb +18 -0
  20. data/lib/kucoin/api/endpoints/markets/order_book.rb +30 -0
  21. data/lib/kucoin/api/endpoints/markets/symbols.rb +15 -0
  22. data/lib/kucoin/api/endpoints/markets/tickers.rb +19 -0
  23. data/lib/kucoin/api/endpoints/other.rb +12 -0
  24. data/lib/kucoin/api/endpoints/trade.rb +8 -0
  25. data/lib/kucoin/api/endpoints/trade/fills.rb +20 -0
  26. data/lib/kucoin/api/endpoints/trade/orders.rb +44 -0
  27. data/lib/kucoin/api/endpoints/user.rb +8 -0
  28. data/lib/kucoin/api/endpoints/user/accounts.rb +40 -0
  29. data/lib/kucoin/api/endpoints/user/deposits.rb +26 -0
  30. data/lib/kucoin/api/endpoints/user/withdrawals.rb +30 -0
  31. data/lib/kucoin/api/endpoints/websocket.rb +27 -0
  32. data/lib/kucoin/api/error.rb +11 -0
  33. data/lib/kucoin/api/middleware/auth_request.rb +45 -0
  34. data/lib/kucoin/api/middleware/nonce_request.rb +13 -0
  35. data/lib/kucoin/api/rest.rb +46 -0
  36. data/lib/kucoin/api/rest/connection.rb +50 -0
  37. data/lib/kucoin/api/version.rb +5 -0
  38. data/lib/kucoin/api/websocket.rb +150 -0
  39. data/log/.keep +0 -0
  40. metadata +193 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fe92cbad3ab33770138eab85e0be001828546fdf1041567796a70d2516d88c06
4
+ data.tar.gz: c087bee2e4f4b73b881aa6d54a67d7b3a3dbce758c365ad08f0b59253ba71d20
5
+ SHA512:
6
+ metadata.gz: cf5b2492278f8539f9d790426d088be74cdb3c512554347e98126609268679c7394d9d4870141e6896a7d786cc9d37018e6dde0b5fd6be4920b8342855d8cbba
7
+ data.tar.gz: a5a96566d2c08d3dc9052299ff65a29ca962b521c3a3100d9aa5c16c9db6fb6ed41bcda67df573ffc347f53a5e8a48d647f56560a9e40fed0f1de310d0e53669
@@ -0,0 +1,24 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.log
10
+
11
+ Gemfile.lock
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
15
+
16
+ # rubymine config
17
+ .idea
18
+
19
+ # rvm
20
+ .ruby-gemset
21
+ .ruby-version
22
+
23
+ # simplecov
24
+ coverage
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ SimpleCov.start do
2
+ add_filter "/spec/"
3
+ add_group "Rest", ["lib/kucoin/api/rest", "lib/kucoin/api/rest.rb"]
4
+ add_group "Websocket", ["lib/kucoin/api/websocket.rb"]
5
+ add_group "Endpoints", "lib/kucoin/api/endpoints"
6
+ add_group "Middleware", "lib/kucoin/api/middleware"
7
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.6
7
+ before_install: gem install bundler -v 1.17.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in kucoin.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,551 @@
1
+ # Kucoin API
2
+
3
+ This is an unofficial Ruby wrapper for the Kucoin exchange REST and WebSocket APIs.
4
+
5
+ ##### Notice
6
+
7
+ * This is Alpha software. All issues should be aggressively reported for quick resolution!
8
+ * RESTful interface is fully implemented.
9
+ * Websocket is fully implemented.
10
+ * Pull Requests are very welcome!
11
+ * RSPEC tests depend on Ruby >= 2.4 features, specifically `#match?` The gem itself should work find with any Ruby 2.x and higher and perhaps 1.9.x, but has certainly not been tested. YMMV!
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'kucoin-api'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install kucoin-api
28
+
29
+ ## Features
30
+
31
+ #### Current
32
+
33
+ * Basic implementation of REST API
34
+ * Easy to use authentication
35
+ * Methods return parsed JSON
36
+ * No need to generate timestamps
37
+ * No need to generate signatures
38
+
39
+ * Basic implementation of WebSocket API
40
+ * Pass procs or lambdas to event handlers
41
+ * Single streams supported
42
+ * Runs on EventMachine
43
+
44
+ * Exception handling with responses
45
+ * High level abstraction
46
+
47
+ #### TODO
48
+
49
+ * Websockets currently uses the first InstanceServer returned in the "Apply connect token" RESTful calls. It is currently not clear what Kucoin intends with multiple InstanceServers, so until a use-case arises or feature/bug request comes along that sheds some light on how to select and use specific servers, the websocket interface is hard-wired to the first instance server returned.
50
+
51
+ ## Getting Started
52
+
53
+ #### REST Client
54
+
55
+ Require Kucoin API:
56
+
57
+ ```ruby
58
+ require 'kucoin-api'
59
+ ```
60
+
61
+ Create a new instance of the REST Client:
62
+
63
+ ```ruby
64
+ # If you only plan on touching public API endpoints, you can forgo any arguments
65
+ client = Kucoin::Api::REST.new
66
+
67
+ # Otherwise provide an api_key as keyword arguments
68
+ client = Kucoin::Api::REST.new api_key: 'your.api_key', api_secret: 'your.api_secret', api_passphrase: 'your.api_passphrase'
69
+
70
+ # You can provide a sandbox as argument to change into Sandbox environment
71
+ client = Kucoin::Api::REST.new sandbox: true
72
+ ```
73
+
74
+ |**Environment** |**BaseUri** |
75
+ |:---------------------:|:-------------------------------------:|
76
+ | Production `DEFAULT` | https://openapi-v2.kucoin.com |
77
+ | Sandbox | https://openapi-sandbox.kucoin.com |
78
+
79
+ ALTERNATIVELY, set your API key in exported environment variable:
80
+
81
+ ```bash
82
+ export KUCOIN_API_KEY=your.api_key
83
+ export KUCOIN_API_SECRET=your.api_secret
84
+ export KUCOIN_API_PASSPHRASE=your.api_passphrase
85
+ ```
86
+
87
+ Then you can instantiate client without parameters as in first variation above.
88
+
89
+ Create various requests:
90
+
91
+ ```ruby
92
+ # Others / Time / Server Time
93
+ client.other.timestamp
94
+ # => 1554213599244
95
+
96
+ # Currencies Plugin / List exchange rate of coins
97
+ client.currency.all
98
+ # => {"rates"=>{"TRAC"=>{"CHF"=>0.02, "HRK"=>0.14...}}
99
+
100
+ # Public Market Data / Tick
101
+ client.market.tick(symbol: 'KCS-BTC')
102
+ # => {"coinType"=>"KCS", "trading"=>true, "symbol"=>"KCS-BTC", "lastDealPrice"=>0.00016493,
103
+ # "buy"=>0.00016493, "sell"=>0.00016697, "change"=>2.41e-06, "coinTypePair"=>"BTC", "sort"=>0,
104
+ # "feeRate"=>0.001, "volValue"=>19.92555026, "high"=>0.00016888, "datetime"=>1546427934000,
105
+ # "vol"=>120465.9024, "low"=>0.000161, "changeRate"=>0.0148
106
+ # }
107
+
108
+
109
+ # Trading / Create an order
110
+ client.order.create 'KCS-BTC', type: 'BUY', price: 0.000127, amount: 22
111
+ # => { "orderOid": "596186ad07015679730ffa02" }
112
+
113
+
114
+ # Assets Operation / Get coin deposit address
115
+ client.account.wallet_address('KCS')
116
+ # => {
117
+ # "oid": "598aeb627da3355fa3e851ca",
118
+ # "address": "598aeb627da3355fa3e851ca",
119
+ # "context": null,
120
+ # "userOid": "5969ddc96732d54312eb960e",
121
+ # "coinType": "KCS",
122
+ # "createdAt": 1502276446000,
123
+ # "deletedAt": null,
124
+ # "updatedAt": 1502276446000,
125
+ # "lastReceivedAt": 1502276446000
126
+ # }
127
+ ```
128
+
129
+ Required and optional parameters, as well as enum values, can currently be found on the [Kucoin Apiary Page](https://docs.kucoin.com). Parameters should always be passed to client methods as keyword arguments in snake_case form. symbol, when a required parameter is simply passed as first parameter for most API calls.
130
+
131
+ ### REST Endpoints
132
+
133
+ REST endpoints are in order as documented on the Kucoin Apiary page (linked above).
134
+ Endpoints are accessible by following resourceful structure given in Kucoin API documentation. For example - `user.accounts` is for endpoints given in Kucoin API documentation under "User/Accounts".
135
+ The following lists only the method names, aliases (if any) and parameters of the methods to access endpoints.
136
+ For the most part, method names follow RESTful action names and alias method follows the title/name given in Kucoin API documentation.
137
+ There were some deviations where there would otherwise be name clashes/overloading.
138
+
139
+ #### User
140
+
141
+ ##### Accounts
142
+ ----
143
+
144
+ ```ruby
145
+ # List Accounts
146
+ user.accounts.list options={}
147
+ ```
148
+ * required params: none
149
+
150
+ ----
151
+ ```ruby
152
+ # Get an Account
153
+ user.accounts.get account_id
154
+ ```
155
+ * required params: account_id
156
+
157
+ ----
158
+ ```ruby
159
+ # Create an Account
160
+ user.accounts.create currency, type
161
+ ```
162
+ * required params: currency, type
163
+
164
+ ----
165
+ ```ruby
166
+ # Get Account Ledgers
167
+ user.accounts.ledgers account_id, options={}
168
+ ```
169
+ * required params: account_id
170
+
171
+ ----
172
+ ```ruby
173
+ # Get Holds
174
+ user.accounts.holds account_id
175
+ ```
176
+ * required params: account_id
177
+
178
+ ----
179
+ ```ruby
180
+ # Inner Transfer
181
+ user.accounts.inner_transfer client_oid, pay_account_id, rec_account_id, amount
182
+ ```
183
+ * required params: client_oid, pay_account_id, rec_account_id, amount
184
+
185
+ ##### Deposits
186
+ ----
187
+
188
+ ```ruby
189
+ # Create Deposit Address
190
+ user.deposits.create currency
191
+ ```
192
+ * required params: currency
193
+
194
+ ----
195
+ ```ruby
196
+ # Get Deposit Address
197
+ user.deposits.get currency
198
+ ```
199
+ * required params: currency
200
+
201
+ ----
202
+ ```ruby
203
+ # Get Deposit List
204
+ user.deposits.list options={}
205
+ ```
206
+ * required params: none
207
+
208
+ ##### Withdrawals
209
+ ----
210
+
211
+ ```ruby
212
+ # Get Withdrawals List
213
+ user.withdrawals.list options={}
214
+ ```
215
+ * required params: none
216
+
217
+ ----
218
+ ```ruby
219
+ # Get Withdrawal Quotas
220
+ user.withdrawals.quotas currency
221
+ ```
222
+ * required params: currency
223
+
224
+ ----
225
+ ```ruby
226
+ # Apply Withdraw
227
+ user.withdrawals.apply currency, address, amount, options={}
228
+ ```
229
+ * required params: currency, address, amount
230
+
231
+ ----
232
+ ```ruby
233
+ # Cancel Withdrawal
234
+ user.withdrawals.cancel withdrawal_id
235
+ ```
236
+ * required params: withdrawal_id
237
+
238
+ #### Trade
239
+
240
+ ##### Orders
241
+ ----
242
+
243
+ ```ruby
244
+ # Place a new order
245
+ trade.orders.place client_oid, side, symbol, options={}
246
+ ```
247
+ * required params: client_oid, side, symbol
248
+
249
+ ----
250
+ ```ruby
251
+ # Cancel an order
252
+ trade.orders.cancel order_id
253
+ ```
254
+ * required params: order_id
255
+
256
+ ----
257
+ ```ruby
258
+ # Cancel all orders
259
+ trade.orders.cancel_all options={}
260
+ ```
261
+ * required params: none
262
+
263
+ ----
264
+ ```ruby
265
+ # List Orders
266
+ trade.orders.list options={}
267
+ ```
268
+ * required params: none
269
+
270
+ ----
271
+ ```ruby
272
+ # Recent Orders
273
+ trade.orders.recent
274
+ ```
275
+ * required params: none
276
+
277
+ ----
278
+ ```ruby
279
+ # Get an order
280
+ trade.orders.get order_id
281
+ ```
282
+ * required params: order_id
283
+
284
+ ##### Fills
285
+ ----
286
+
287
+ ```ruby
288
+ # List Fills
289
+ trade.fills.list
290
+ ```
291
+ * required params: none
292
+
293
+ ----
294
+ ```ruby
295
+ # Recent Fills
296
+ trade.fills.recent
297
+ ```
298
+ * required params: none
299
+
300
+ #### Market Data
301
+
302
+ ##### Symbols & Ticker
303
+ ----
304
+
305
+ ```ruby
306
+ # Get Symbols List
307
+ markets.all
308
+ ```
309
+ * required params: none
310
+
311
+ ----
312
+ ```ruby
313
+ # Get Ticker
314
+ markets.stats symbol
315
+ ```
316
+ * required params: symbol
317
+
318
+ ----
319
+ ```ruby
320
+ # Get All Tickers
321
+ markets.tickers.all
322
+ ```
323
+ * required params: none
324
+
325
+ ----
326
+ ```ruby
327
+ # Get 24hr Stats
328
+ markets.tickers.inside symbol
329
+ ```
330
+ * required params: symbol
331
+
332
+ ----
333
+ ```ruby
334
+ # Get Market List
335
+ markets.symbols.all options={}
336
+ ```
337
+ * required params: none
338
+
339
+ ##### Order Book
340
+ ----
341
+
342
+ ```ruby
343
+ # Get Part Order Book(aggregated)
344
+ markets.order_book.part symbol, depth
345
+ ```
346
+ * required params: symbol, depth(20, 100)
347
+
348
+ ----
349
+ ```ruby
350
+ # Get Full Order Book(aggregated)
351
+ markets.order_book.full_aggregated symbol
352
+ ```
353
+ * required params: symbol
354
+
355
+ ----
356
+ ```ruby
357
+ # Get Full Order Book(atomic)
358
+ markets.order_book.full_atomic symbol
359
+ ```
360
+ * required params: symbol
361
+
362
+ ##### Histories
363
+ ----
364
+
365
+ ```ruby
366
+ # Get Trade Histories
367
+ markets.histories.trade symbol
368
+ ```
369
+ * required params: symbol
370
+
371
+ ----
372
+ ```ruby
373
+ # Get Klines
374
+ markets.histories.klines symbol, type, options={}
375
+ ```
376
+ * required params: symbol, type
377
+
378
+ ##### Currencies
379
+ ----
380
+
381
+ ```ruby
382
+ # Get Currencies
383
+ markets.currencies.all
384
+ ```
385
+ * required params: none
386
+
387
+ ----
388
+ ```ruby
389
+ # Get Currency Detail
390
+ markets.currencies.detail currency
391
+ ```
392
+ * required params: currency
393
+
394
+ ----
395
+ ```ruby
396
+ # Get Fiat Price
397
+ markets.currencies.fiat options= {}
398
+ ```
399
+ * required params: none
400
+
401
+ #### Other
402
+
403
+ ##### Time
404
+ ----
405
+
406
+ ```ruby
407
+ # Server Time
408
+ other.timestamp
409
+ ```
410
+ * required params: none
411
+
412
+ ## WebSocket Client
413
+
414
+ Create a new instance of the WebSocket Client:
415
+
416
+ ```ruby
417
+ # If you only plan on touching public topics
418
+ client = Kucoin::Api::Websocket.new
419
+
420
+ # Changing the rest_client argument for different authentication
421
+ client = Kucoin::Api::Websocket.new rest_client: Kucoin::Api::REST.new(sendbox: true)
422
+ ```
423
+
424
+ Subscribe various topics:
425
+
426
+ ```ruby
427
+ # Public Channels / Symbol Ticker
428
+ methods = { message: proc { |event| puts event.data } }
429
+ client.ticker symbols: 'ETH-BTC', methods: methods
430
+ # => {"id":"259173795477643264","type":"ack"}
431
+ # => {"data":{"sequence":...}, "subject":"trade.ticker","topic":"/market/ticker:ETH-BTC","type":"message"}
432
+ # => {"data":{"sequence":...}, "subject":"trade.ticker","topic":"/market/ticker:ETH-BTC","type":"message"}
433
+ # => ...
434
+
435
+ # Private Channels / Stop order received event
436
+ client.stop_order_received_event symbols: 'BTC-USDT', methods: methods
437
+ # => {"id":"259173795477643264","type":"ack"}
438
+ # => {"data":{"sequence":...}, "subject":"trade.l3received","topic":"/market/level3:BTC-USDT","type":"message"}
439
+ # => {"data":{"sequence":...}, "subject":"trade.l3received","topic":"/market/level3:BTC-USDT","type":"message"}
440
+ # => ...
441
+ ```
442
+
443
+ Multiplex:
444
+
445
+ ```ruby
446
+ channel = nil
447
+ message = proc do |event|
448
+ puts event.data
449
+ data = JSON.parse(event.data)
450
+ if data['type'] == 'ack' && data['id'] == '1222'
451
+ Kucoin::Api::Websocket.subscribe(channel: channel, params: { topic: "/market/ticker:ETH-BTC", tunnelId: 'bt1' })
452
+ end
453
+ end
454
+ methods = { message: message }
455
+ channel = client.multiplex stream: { newTunnelId: 'bt1', id: '1222' }, methods: methods
456
+ # => {"id":"1222","type":"ack"}
457
+ # => {"tunnelId":"bt1","id":"170022900","type":"ack"}
458
+ # => {"data":{"sequence":...},"subject":"trade.ticker","tunnelId":"bt1","topic":"/market/ticker:ETH-BTC","type":"message"}
459
+ # => {"data":{"sequence":...},"subject":"trade.ticker","tunnelId":"bt1","topic":"/market/ticker:ETH-BTC","type":"message"}
460
+
461
+ # Using the one physical connection - `channel`,
462
+ # you could open different multiplex tunnels to subscribe different topics for different data.
463
+ ```
464
+
465
+ All subscription topic method will expect "methods" in argument(As shown above).
466
+ It's The Hash which contains the event handler methods to pass to the WebSocket client methods.
467
+ Proc is the expected value of each event handler key. Following are list of expected event handler keys.
468
+ - :open - The Proc called when a stream is opened (optional)
469
+ - :message - The Proc called when a stream receives a message
470
+ - :error - The Proc called when a stream receives an error (optional)
471
+ - :close - The Proc called when a stream is closed (optional)
472
+
473
+ ### Websocket Feed
474
+
475
+ Subscribe topics are in order as documented on the Kucoin Apiary page (linked above).
476
+
477
+ #### Public Channels
478
+ ----
479
+
480
+ ```ruby
481
+ # Symbol Ticker
482
+ ticker symbols:, methods:
483
+ ```
484
+ * required params: symbols(Array/String), methods
485
+
486
+ ----
487
+ ```ruby
488
+ # All Symbols Ticker
489
+ all_ticker methods:
490
+ ```
491
+ * required params: methods
492
+
493
+ ----
494
+ ```ruby
495
+ # Symbol Snapshot
496
+ # Market Snapshot
497
+ snapshot symbol:, methods:
498
+ ```
499
+ * required params: symbol, methods
500
+ * alias methods: symbol_snapshot, market_snapshot
501
+
502
+ ----
503
+ ```ruby
504
+ # Level-2 Market Data
505
+ level_2_market_data symbols:, methods:
506
+ ```
507
+ * required params: symbols(Array/String), methods
508
+
509
+ ----
510
+ ```ruby
511
+ # Match Execution Data
512
+ match_execution_data symbols:, methods:, private_channel: false
513
+ ```
514
+ * required params: symbols(Array/String), methods
515
+
516
+ ----
517
+ ```ruby
518
+ # Full MatchEngine Data(Level 3)
519
+ full_match_engine_data symbols:, methods:, private_channel: false
520
+ ```
521
+ * required params: symbols(Array/String), methods
522
+
523
+ #### Private Channels
524
+ ----
525
+
526
+ ```ruby
527
+ # Stop order received event
528
+ # Stop order activate event
529
+ stop_order_received_event symbols:, methods:
530
+ ```
531
+ * required params: symbols(Array/String), methods
532
+ * alias methods: stop_order_activate_event
533
+
534
+ ----
535
+ ```ruby
536
+ # Account balance notice
537
+ balance methods:
538
+ ```
539
+ * required params: methods
540
+
541
+ ## Contributing
542
+
543
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mwlang/kucoin-api.
544
+
545
+ ## Inspiration
546
+
547
+ The inspiration for architectural layout of this gem comes nearly one-for-one from the [Binance gem](https://github.com/craysiii/binance) by craysiii.
548
+
549
+ ## License
550
+
551
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).