coindcx 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 265101075beb405d193e81c795e734347771bd80f65695e48abcb29729ec293d
4
+ data.tar.gz: bac759acb6518237eae074ab48056e84c2b9f646675939085f5e1df4c03f0db0
5
+ SHA512:
6
+ metadata.gz: f2669d125c251edfda27e9ac9cfc090e74e44b7141f4c8daa8bd3c5e54b439ee23409db4ad17168db420f1b432603f894c57bbb65e7b77f19aa6673111eead13
7
+ data.tar.gz: c3ae269b5df5ab2e41d329950aabf32b04faa67539cb5900e24d697a42a39ce93a19275d9802a291adba01be1adb9a72407a6e17f54f92a2acf384b45898e2be
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,4 @@
1
+ example_id | status | run_time |
2
+ ----------------------------------- | ------ | --------------- |
3
+ ./spec/lib/coindcx_spec.rb[1:1] | passed | 0.00047 seconds |
4
+ ./spec/lib/rest/client_spec.rb[1:1] | passed | 0.001 seconds |
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 2.0.1
@@ -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 snmmaurya@gmail.com. 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,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in coindcx-ruby.gemspec
4
+ gemspec
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ coindcx (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ openssl (2.1.2)
11
+ rake (10.5.0)
12
+ rspec (3.8.0)
13
+ rspec-core (~> 3.8.0)
14
+ rspec-expectations (~> 3.8.0)
15
+ rspec-mocks (~> 3.8.0)
16
+ rspec-core (3.8.0)
17
+ rspec-support (~> 3.8.0)
18
+ rspec-expectations (3.8.2)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.8.0)
21
+ rspec-mocks (3.8.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-support (3.8.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler (~> 2.0)
31
+ coindcx!
32
+ openssl (~> 2.1, >= 2.1.2)
33
+ rake (~> 10.0)
34
+ rspec (~> 3.0)
35
+
36
+ BUNDLED WITH
37
+ 2.0.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Snm Maurya
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,453 @@
1
+ # CoinDCX
2
+
3
+ A Ruby library to access coindcx exchange APIs.
4
+
5
+ ### Note
6
+
7
+ Currently this libarary supports REST only.
8
+ All the endpoints taken from <a href="https://coindcx-official.github.io/rest-api/" target="_blank">coindcx official doc</>.
9
+
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'coindcx'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install coindcx
26
+
27
+ ## Usage
28
+
29
+ ### You can get your API key and Secret as follows
30
+
31
+ 1. Go to your CoinDCX profile section
32
+ 2. Click Access API dashboard
33
+ 3. Click Create API key button and follow the process of verifications
34
+
35
+
36
+ ### Example
37
+
38
+ ```ruby
39
+ require 'coindcx'
40
+
41
+ # Access public endpoints
42
+ client = Coindcx::Rest::client.new
43
+
44
+ # Access private endpoints
45
+ client = Coindcx::Rest::client.new key, secret
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Public Endpoints
51
+
52
+ ### # Get Tickers
53
+ ```ruby
54
+ client.tickers
55
+
56
+ # RESPONSE:
57
+
58
+ # {"BTC_INR":{"id":632526,"percentChange":"-1.131","high24hr":"287957.0","low24hr":"280100.01","last":"282000.99","highestBid":"282001.00000000","lowestAsk":"284999.00000000","isFrozen":"0","quoteVolume":"2.89293","baseVolume":"822586.0723586"},"MDA_BTC":{"id":633389,"percentChange":"0.024","high24hr":"0.00026000","low24hr":"0.00023050","last":"0.00024516","highestBid":"0.00024515","lowestAsk":"0.00024537","isFrozen":"0","quoteVolume":"347.0","baseVolume":"0.08511527"},"XLM_BTC"....}
59
+ ```
60
+
61
+ ### # Get Markets
62
+ ```ruby
63
+ client.markets
64
+
65
+ # RESPONSE:
66
+
67
+ # [
68
+ # "SNTBTC",
69
+ # "TRXBTC",
70
+ # "TRXETH"
71
+ # .
72
+ # .
73
+ # ]
74
+ ```
75
+
76
+ ### # Get markets etails
77
+ ```ruby
78
+ client.markets_details
79
+
80
+ # RESPONSE:
81
+
82
+ # [
83
+ # {
84
+ # "coindcx_name": "SNTBTC",
85
+ # "base_currency_short_name": "BTC",
86
+ # "target_currency_short_name": "SNT",
87
+ # "target_currency_name": "Status",
88
+ # "base_currency_name": "Bitcoin",
89
+ # "min_quantity": 1,
90
+ # "max_quantity": 1000000,
91
+ # "min_notional": 0.001,
92
+ # "base_currency_precision": 8,
93
+ # "target_currency_precision": 0,
94
+ # "step": 1,
95
+ # "order_types": ["market_order", "limit_order"]
96
+ # }
97
+ # ]
98
+ ```
99
+
100
+ ### # Get trades
101
+ ```ruby
102
+ client.trades({"market" => "LTCBTC"})
103
+
104
+ # RESPONSE:
105
+
106
+ # [
107
+ # {
108
+ # "p": 0.00001693,
109
+ # "q": 394,
110
+ # "T": 1521476030955.09,
111
+ # "m": false
112
+ # }
113
+ # }
114
+ ```
115
+
116
+ ### # Get order books
117
+ ```ruby
118
+ client.order_books({"market" => "LTCBTC"})
119
+
120
+ # RESPONSE:
121
+
122
+ # {
123
+ # "asks":{
124
+ # "0.00160900":"23.79000000",
125
+ # "0.00161000":"300.85",
126
+ # "0.00161400":"11.25",
127
+ # "0.00161500":"101.82",
128
+ # "0.00161700":"222.37000000"
129
+ # ,
130
+ # ,
131
+ # ,
132
+ # },
133
+ # "bids":{
134
+ # "0.00160400":"24.24000000",
135
+ # "0.00160300":"7.63",
136
+ # "0.00160100":"917.51000000",
137
+ # "0.00159900":"40.8",
138
+ # "0.00159700":"6"
139
+ # ,
140
+ # ,
141
+ # ,
142
+ # }
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Private Endpoints
148
+
149
+
150
+ ### # Post balances
151
+ ```ruby
152
+ client.balances({"timestamp" => Time.new.to_i * 1000})
153
+
154
+ # RESPONSE:
155
+
156
+ # [
157
+ # {
158
+ # "currency": "BTC",
159
+ # "balance": 1.167,
160
+ # "locked_balance": 2.1
161
+ # }
162
+ # ]
163
+
164
+ # Locked balance is the balance currently being used by an open order
165
+ ```
166
+
167
+ ### # Post place order
168
+ ```ruby
169
+ payload = {
170
+ "side" => "buy",
171
+ "order_type" => "limit_order",
172
+ "market" => "LTCBTC",
173
+ "price_per_unit" => 0.00001,
174
+ "total_quantity" => 10,
175
+ "timestamp" => Time.new.to_i * 1000
176
+ }
177
+
178
+ client.place_order(payload)
179
+
180
+ # RESPONSE:
181
+
182
+ # {
183
+ # "orders":[
184
+ # {
185
+ # "id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
186
+ # "market":"LTCBTC",
187
+ # "order_type":"limit_order",
188
+ # "side":"buy",
189
+ # "status":"open",
190
+ # "fee_amount":0.0000008,
191
+ # "fee":0.1,
192
+ # "total_quantity":10.0,
193
+ # "remaining_quantity":10.0,
194
+ # "avg_price":0.0,
195
+ # "price_per_unit":0.00001,
196
+ # "created_at":"2018-04-19T18:17:28.022Z",
197
+ # "updated_at":"2018-04-19T18:17:28.022Z"
198
+ # }
199
+ # ]
200
+ # }
201
+ ```
202
+
203
+ ### # Post place multiple orders
204
+ ```ruby
205
+ payload = {"orders":[{
206
+ "side" => "buy",
207
+ "order_type" => "limit_order",
208
+ "market" => "LTCBTC",
209
+ "price_per_unit" => 0.00001,
210
+ "total_quantity" => 10,
211
+ "timestamp" => Time.new.to_i * 1000
212
+ },
213
+ {
214
+ "side" => "buy",
215
+ "order_type" => "limit_order",
216
+ "market" => "LTCBTC",
217
+ "price_per_unit" => 0.00001,
218
+ "total_quantity" => 10,
219
+ "timestamp" => Time.new.to_i * 1000
220
+ }],
221
+ }
222
+ client.place_multiple_orders(payload)
223
+
224
+ # RESPONSE:
225
+
226
+ # {
227
+ # "orders":[
228
+ # {
229
+ # "id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
230
+ # "market":"LTCBTC",
231
+ # "order_type":"limit_order",
232
+ # "side":"buy",
233
+ # "status":"open",
234
+ # "fee_amount":0.0000008,
235
+ # "fee":0.1,
236
+ # "total_quantity":10.0,
237
+ # "remaining_quantity":10.0,
238
+ # "avg_price":0.0,
239
+ # "price_per_unit":0.00001,
240
+ # "created_at":"2018-04-19T18:17:28.022Z",
241
+ # "updated_at":"2018-04-19T18:17:28.022Z"
242
+ # }
243
+ # ]
244
+ # }
245
+ ```
246
+
247
+ ### # POST order status
248
+ ```ruby
249
+ payload = {"id" => "ead19992-43fd-11e8-b027-bb815bcb14ed", "timestamp" => Time.new.to_i * 1000}
250
+
251
+ client.order_status(payload)
252
+
253
+ # RESPONSE:
254
+
255
+ # {
256
+ # "id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
257
+ # "market":"TRXETH",
258
+ # "order_type":"limit_order",
259
+ # "side":"buy",
260
+ # "status":"open",
261
+ # "fee_amount":0.0000008,
262
+ # "fee":0.1,
263
+ # "total_quantity":2,
264
+ # "remaining_quantity":2.0,
265
+ # "avg_price":0.0,
266
+ # "price_per_unit":0.00001567,
267
+ # "created_at":"2018-04-19T18:17:28.022Z",
268
+ # "updated_at":"2018-04-19T18:17:28.022Z"
269
+ # }
270
+ ```
271
+
272
+ ### # POST multiple order status
273
+ ```ruby
274
+ payload = {
275
+ "ids": ["8a2f4284-c895-11e8-9e00-5b2c002a6ff4", "8a1d1e4c-c895-11e8-9dff-df1480546936"]
276
+ }
277
+ client.multiple_order_status(payload)
278
+
279
+ # RESPONSE:
280
+
281
+ # [
282
+ # {
283
+ # "id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
284
+ # "market":"LTCBTC",
285
+ # "order_type":"limit_order",
286
+ # "side":"buy",
287
+ # "status":"open",
288
+ # "fee_amount":0.0000008,
289
+ # "fee":0.1,
290
+ # "total_quantity":2,
291
+ # "remaining_quantity":2.0,
292
+ # "avg_price":0.0,
293
+ # "price_per_unit":0.00001567,
294
+ # "created_at":"2018-04-19T18:17:28.022Z",
295
+ # "updated_at":"2018-04-19T18:17:28.022Z"
296
+ # }
297
+ # ]
298
+ ```
299
+
300
+ ### # POST active orders
301
+ ```ruby
302
+ payload = {
303
+ "side" => "buy",
304
+ "market" => "LTCBTC",
305
+ "timestamp" => Time.new.to_i * 1000
306
+ }
307
+
308
+ client.active_orders(payload)
309
+
310
+ # RESPONSE:
311
+
312
+ # [
313
+ # {
314
+ # "id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
315
+ # "market":"LTCBTC",
316
+ # "order_type":"limit_order",
317
+ # "side":"buy",
318
+ # "status":"open",
319
+ # "fee_amount":0.0000008,
320
+ # "fee":0.1,
321
+ # "total_quantity":2,
322
+ # "remaining_quantity":2.0,
323
+ # "avg_price":0.0,
324
+ # "price_per_unit":0.00001567,
325
+ # "created_at":"2018-04-19T18:17:28.022Z",
326
+ # "updated_at":"2018-04-19T18:17:28.022Z"
327
+ # }
328
+ # ]
329
+ ```
330
+
331
+ ### # POST trade history
332
+ ```ruby
333
+ payload = {
334
+ "from_id" => 352622,
335
+ "limit" => 50
336
+ }
337
+
338
+ client.trade_history(payload)
339
+
340
+ # RESPONSE:
341
+
342
+ [
343
+ {
344
+ "id": 564389,
345
+ "order_id": "ee060ab6-40ed-11e8-b4b9-3f2ce29cd280",
346
+ "side": "buy",
347
+ "fee_amount": "0.00001129",
348
+ "ecode": "B",
349
+ "quantity": 67.9,
350
+ "price": 0.00008272,
351
+ "symbol": "LTCBTC",
352
+ "timestamp": 1533700109811
353
+ }
354
+ ]
355
+ ```
356
+
357
+ ### # POST active orders count
358
+ ```ruby
359
+ payload = {
360
+ "side" => "buy",
361
+ "market" => "LTCBTC",
362
+ "timestamp" => Time.new.to_i * 1000
363
+ }
364
+
365
+ client.active_orders_count(payload)
366
+
367
+ # RESPONSE:
368
+
369
+ {
370
+ count: 1,
371
+ status: 200
372
+ }
373
+ ```
374
+
375
+ ### # POST cancel all orders
376
+ ```ruby
377
+
378
+ payload = {
379
+ "side" => "buy",
380
+ "market" => "LTCBTC",
381
+ "timestamp" => Time.new.to_i * 1000
382
+ }
383
+
384
+ client.cancel_all_orders(payload)
385
+
386
+ # RESPONSE:
387
+
388
+ # {"message"=>"success", "status"=>200, "code"=>200}
389
+ ```
390
+
391
+ ### # POST cancel orders by ids
392
+ ```ruby
393
+ payload = {
394
+ "ids": ["8a2f4284-c895-11e8-9e00-5b2c002a6ff4", "8a1d1e4c-c895-11e8-9dff-df1480546936"]
395
+ }
396
+
397
+ client.cancel_orders_by_ids(payload)
398
+
399
+ # RESPONSE:
400
+
401
+ # {"message"=>"success", "status"=>200, "code"=>200}
402
+ ```
403
+
404
+ ### # POST cancel_order
405
+ ```ruby
406
+ payload = {"id" => "ead19992-43fd-11e8-b027-bb815bcb14ed", "timestamp" => Time.new.to_i * 1000}
407
+
408
+ client.cancel_order(payload)
409
+
410
+ # RESPONSE:
411
+
412
+ # {"message"=>"success", "status"=>200, "code"=>200}
413
+ ```
414
+
415
+ ---
416
+
417
+ ## Errors
418
+
419
+ | Error Code | Meaning
420
+ | ------------- |:-------------:|
421
+ | 400 | Bad Request -- Your request is invalid.|
422
+ | 401 | Your API key is wrong.|
423
+ | 402 | Invalid Request.|
424
+ | 404 | The specified link could not be found.|
425
+ | 429 | Too Many Requests -- You're making too many API calls.|
426
+ | 500 | Internal Server Error -- We had a problem with our server. Try again later.|
427
+ | 503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later.|
428
+
429
+ ---
430
+
431
+ ## API call limits
432
+
433
+ Typically you can place around 4 orders per second. The exact number depends on the server load. In aggregate, you may call https//api.coindcx.com not more than 10 times per second.
434
+
435
+ ---
436
+
437
+ ## Development
438
+
439
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
440
+
441
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
442
+
443
+ ## Contributing
444
+
445
+ Bug reports and pull requests are welcome on GitHub at https://github.com/coindcx-official/coindcx-ruby-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
446
+
447
+ ## License
448
+
449
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
450
+
451
+ ## Code of Conduct
452
+
453
+ Everyone interacting in the Coindcx::Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/coindcx-official/coindcx-ruby-client/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "coindcx/ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "coindcx/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "coindcx"
8
+ spec.version = Coindcx::VERSION
9
+ spec.authors = ["Snm Maurya"]
10
+ spec.email = ["snmmaurya@gmail.com"]
11
+
12
+ spec.summary = %q{A Ruby library to access coindcx exchange APIs.}
13
+ spec.description = %q{An official Ruby library to access coindcx exchange APIs, includes REST and WebSockets.}
14
+ spec.homepage = "https://github.com/coindcx-official/coindcx-ruby-client"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/gems/coindcx-ruby-client"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/coindcx-official/coindcx-ruby-client"
24
+ spec.metadata["changelog_uri"] = "https://github.com/coindcx-official/coindcx-ruby-client"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ spec.add_development_dependency "openssl", "~> 2.1", ">= 2.1.2"
43
+ end
@@ -0,0 +1,2 @@
1
+ require "coindcx/version"
2
+ require "coindcx/rest/client"
@@ -0,0 +1,57 @@
1
+ module Coindcx
2
+ module Rest
3
+ class Base < Coindcx::Rest::Config
4
+
5
+ def http_request method, method_data, payload
6
+ headers, params, endpoint = request_params(method, method_data, payload)
7
+ uri = URI.parse(endpoint)
8
+ https = Net::HTTP.new(uri.host, uri.port)
9
+ https.use_ssl = true
10
+ if method == "POST"
11
+ request = Net::HTTP::Post.new(uri.path, headers)
12
+ request.body = params.to_json
13
+ elsif method == "PUT"
14
+ request = Net::HTTP::Put.new(uri.path, headers)
15
+ request.body = params.to_json
16
+ else method == "GET"
17
+ request = Net::HTTP::Get.new(uri.path, headers)
18
+ end
19
+ response = https.request(request)
20
+ JSON.parse(response.body)
21
+ end
22
+
23
+ def request_params method, method_data, payload
24
+ if method_data["authentication"]
25
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @secret, payload.to_json)
26
+ headers = {
27
+ 'Content-Type' => 'application/json',
28
+ 'X-AUTH-APIKEY' => @key,
29
+ 'X-AUTH-SIGNATURE' => signature
30
+ }
31
+ [headers, payload, endpoint(method, method_data, payload)]
32
+ else
33
+ headers = {
34
+ 'Content-Type' => 'application/json',
35
+ }
36
+ [headers, payload, endpoint(method, method_data, payload)]
37
+ end
38
+ end
39
+
40
+ def endpoint method, method_data, payload
41
+ if method_data["parameters"]["type"] == "url"
42
+ endpoint = method_data["endpoint"]
43
+ method_data["parameters"]["replace"].each do |key, value|
44
+ endpoint.gsub!(key, payload[value])
45
+ end
46
+ elsif method_data["parameters"]["type"] == "query"
47
+ query_string = URI.encode(payload.map{|k,v| "#{k}=#{v}"}.join("&"))
48
+ endpoint = "#{method_data["endpoint"]}?#{query_string}"
49
+ elsif method_data["parameters"]["type"] == "body"
50
+ endpoint = method_data["endpoint"]
51
+ end
52
+ "#{BASE_URL}#{endpoint}"
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,19 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+ require 'openssl'
5
+ require_relative "config"
6
+ require_relative "base"
7
+
8
+
9
+ module Coindcx
10
+ module Rest
11
+ class Client < Coindcx::Rest::Base
12
+
13
+ def initialize key=nil, secret=nil
14
+ @key, @secret = key, secret
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,160 @@
1
+ module Coindcx
2
+ module Rest
3
+ class Config
4
+ BASE_URL = 'https://api.coindcx.com/exchange'.freeze
5
+
6
+ ENDPOINTS = {
7
+ "markets" => {
8
+ "endpoint" => "/v1/markets",
9
+ "parameters" => {
10
+ "type" => "query",
11
+ },
12
+ "method" => "GET",
13
+ "authentication" => false
14
+ },
15
+ "markets_details" => {
16
+ "endpoint" => "/v1/markets_details",
17
+ "parameters" => {
18
+ "type" => "query",
19
+ },
20
+ "method" => "GET",
21
+ "authentication" => false
22
+ },
23
+ "trades" => {
24
+ "endpoint" => "/v1/trades/:market",
25
+ "parameters" => {
26
+ "type" => "url",
27
+ "replace" => {
28
+ ":market" => "market"
29
+ }
30
+ },
31
+ "method" => "GET",
32
+ "authentication" => false
33
+ },
34
+ "order_books" => {
35
+ "endpoint" => "/v1/books/:market",
36
+ "parameters" => {
37
+ "type" => "url",
38
+ "replace" => {
39
+ ":market" => "market"
40
+ }
41
+ },
42
+ "method" => "GET",
43
+ "authentication" => false
44
+ },
45
+ "tickers" => {
46
+ "endpoint" => "/v1/tickers",
47
+ "parameters" => {
48
+ "type" => "query",
49
+ "replace" => {
50
+ "market" => "market"
51
+ }
52
+ },
53
+ "method" => "GET",
54
+ "authentication" => false
55
+ },
56
+ # END public endpoints
57
+
58
+ #START Private end points
59
+ "balances" => {
60
+ "endpoint" => "/v1/users/balances",
61
+ "parameters" => {
62
+ "type" => "body"
63
+ },
64
+ "method" => "POST",
65
+ "authentication" => true
66
+ },
67
+ "place_order" => {
68
+ "endpoint" => "/v1/orders/create",
69
+ "parameters" => {
70
+ "type" => "body"
71
+ },
72
+ "method" => "POST",
73
+ "authentication" => true
74
+ },
75
+ "place_multiple_orders" => {
76
+ "endpoint" => "/v1/orders/create_multiple",
77
+ "parameters" => {
78
+ "type" => "body"
79
+ },
80
+ "method" => "POST",
81
+ "authentication" => true
82
+ },
83
+ "order_status" => {
84
+ "endpoint" => "/v1/orders/status",
85
+ "parameters" => {
86
+ "type" => "body"
87
+ },
88
+ "method" => "POST",
89
+ "authentication" => true
90
+ },
91
+ "multiple_order_status" => {
92
+ "endpoint" => "/v1/orders/status_multiple",
93
+ "parameters" => {
94
+ "type" => "body"
95
+ },
96
+ "method" => "POST",
97
+ "authentication" => true
98
+ },
99
+ "active_orders" => {
100
+ "endpoint" => "/v1/orders/active_orders",
101
+ "parameters" => {
102
+ "type" => "body"
103
+ },
104
+ "method" => "POST",
105
+ "authentication" => true
106
+ },
107
+ "trade_history" => {
108
+ "endpoint" => "/v1/orders/trade_history",
109
+ "parameters" => {
110
+ "type" => "body"
111
+ },
112
+ "method" => "POST",
113
+ "authentication" => true
114
+ },
115
+
116
+ "active_orders_count" => {
117
+ "endpoint" => "/v1/orders/active_orders_count",
118
+ "parameters" => {
119
+ "type" => "body"
120
+ },
121
+ "method" => "POST",
122
+ "authentication" => true
123
+ },
124
+ "cancel_all_orders" => {
125
+ "endpoint" => "/v1/orders/cancel_all",
126
+ "parameters" => {
127
+ "type" => "body"
128
+ },
129
+ "method" => "POST",
130
+ "authentication" => true
131
+ },
132
+ "cancel_orders_by_ids" => {
133
+ "endpoint" => "/v1/orders/cancel_by_ids",
134
+ "parameters" => {
135
+ "type" => "body"
136
+ },
137
+ "method" => "POST",
138
+ "authentication" => true
139
+ },
140
+ "cancel_order" => {
141
+ "endpoint" => "/v1/orders/cancel",
142
+ "parameters" => {
143
+ "type" => "body"
144
+ },
145
+ "method" => "POST",
146
+ "authentication" => true
147
+ },
148
+ }.freeze
149
+
150
+ Coindcx::Rest::Config.class_eval do
151
+ ENDPOINTS.each do |method, method_data|
152
+ define_method "#{method}" do |payload={}|
153
+ http_request(method_data["method"], method_data, payload)
154
+ end
155
+ end
156
+ end
157
+
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,3 @@
1
+ module Coindcx
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coindcx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Snm Maurya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: openssl
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.1.2
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.1'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.1.2
75
+ description: An official Ruby library to access coindcx exchange APIs, includes REST
76
+ and WebSockets.
77
+ email:
78
+ - snmmaurya@gmail.com
79
+ executables: []
80
+ extensions: []
81
+ extra_rdoc_files: []
82
+ files:
83
+ - ".rspec"
84
+ - ".rspec_status"
85
+ - ".travis.yml"
86
+ - CODE_OF_CONDUCT.md
87
+ - Gemfile
88
+ - Gemfile.lock
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - bin/console
93
+ - bin/setup
94
+ - coindcx.gemspec
95
+ - lib/coindcx.rb
96
+ - lib/coindcx/rest/base.rb
97
+ - lib/coindcx/rest/client.rb
98
+ - lib/coindcx/rest/config.rb
99
+ - lib/coindcx/version.rb
100
+ homepage: https://github.com/coindcx-official/coindcx-ruby-client
101
+ licenses:
102
+ - MIT
103
+ metadata:
104
+ allowed_push_host: https://rubygems.org/gems/coindcx-ruby-client
105
+ homepage_uri: https://github.com/coindcx-official/coindcx-ruby-client
106
+ source_code_uri: https://github.com/coindcx-official/coindcx-ruby-client
107
+ changelog_uri: https://github.com/coindcx-official/coindcx-ruby-client
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.7.3
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: A Ruby library to access coindcx exchange APIs.
128
+ test_files: []