abucoins 0.1.0 → 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.
- checksums.yaml +4 -4
- data/lib/abucoins/abucoins.rb +19 -8
- data/lib/abucoins/exceptions.rb +3 -0
- data/lib/abucoins/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 156916d312b8573e0e95159e4118cadfe7453616
|
|
4
|
+
data.tar.gz: 3c0fa66ec527af7393afd54f4cf6f897158f47b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 544aa29696f4e817689dce2b246a1b23af764f17b22bd2dd4180865ab5adab41f152807e5c271ecfdb1f9c0a67190fb8bbcfc8bf65c17d71e97a8d7222464f1c
|
|
7
|
+
data.tar.gz: cc14015ff49f5f36ae7ab8785ad47bbca9bf1dd5fca0ec70913a695a609a0dd6556037f59abe767d5874e5291651e410ee0b2a64eaf65246ad1fc8d042412f1f
|
data/lib/abucoins/abucoins.rb
CHANGED
|
@@ -20,14 +20,18 @@ module Abucoins
|
|
|
20
20
|
get('/products')
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def orders
|
|
24
|
-
get('/orders')
|
|
23
|
+
def orders(args = {})
|
|
24
|
+
get('/orders', params: args)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def order(id)
|
|
28
28
|
get("/orders/#{id}")
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def fills
|
|
32
|
+
get('/fills')
|
|
33
|
+
end
|
|
34
|
+
|
|
31
35
|
def create_order(side:, hidden: false, time_in_force: nil, size:, price:, product_id:, type: 'limit', cancel_after: nil, post_only: nil)
|
|
32
36
|
opts = {
|
|
33
37
|
side: side,
|
|
@@ -40,7 +44,11 @@ module Abucoins
|
|
|
40
44
|
opts[:time_in_force] = time_in_force unless time_in_force.nil?
|
|
41
45
|
opts[:cancel_after] = cancel_after unless cancel_after.nil?
|
|
42
46
|
opts[:post_only] = post_only unless post_only.nil?
|
|
43
|
-
post('/orders', opts)
|
|
47
|
+
order = post('/orders', opts)
|
|
48
|
+
|
|
49
|
+
raise Abucoins::CreateOrderException.new(order['error'] || order['message']) unless order['id']
|
|
50
|
+
|
|
51
|
+
order
|
|
44
52
|
end
|
|
45
53
|
|
|
46
54
|
def cancel_order(id)
|
|
@@ -60,8 +68,11 @@ module Abucoins
|
|
|
60
68
|
Base64.encode64(hmac)
|
|
61
69
|
end
|
|
62
70
|
|
|
63
|
-
def get(path, opts={})
|
|
64
|
-
|
|
71
|
+
def get(path, opts = {})
|
|
72
|
+
uri = URI.parse("#{@url}#{path}")
|
|
73
|
+
uri.query = URI.encode_www_form(opts[:params]) if opts[:params]
|
|
74
|
+
|
|
75
|
+
response = RestClient.get(uri.to_s, auth_headers(uri.request_uri, 'GET'))
|
|
65
76
|
|
|
66
77
|
if !opts[:skip_json]
|
|
67
78
|
JSON.parse(response.body)
|
|
@@ -70,7 +81,7 @@ module Abucoins
|
|
|
70
81
|
end
|
|
71
82
|
end
|
|
72
83
|
|
|
73
|
-
def post(path, payload, opts={})
|
|
84
|
+
def post(path, payload, opts = {})
|
|
74
85
|
data = JSON.unparse(payload)
|
|
75
86
|
response = RestClient.post("#{@url}#{path}", data, auth_headers(path, 'POST', data))
|
|
76
87
|
|
|
@@ -81,7 +92,7 @@ module Abucoins
|
|
|
81
92
|
end
|
|
82
93
|
end
|
|
83
94
|
|
|
84
|
-
def delete(path, opts={})
|
|
95
|
+
def delete(path, opts = {})
|
|
85
96
|
response = RestClient.delete("#{@url}#{path}", auth_headers(path, 'DELETE'))
|
|
86
97
|
|
|
87
98
|
if !opts[:skip_json]
|
|
@@ -91,7 +102,7 @@ module Abucoins
|
|
|
91
102
|
end
|
|
92
103
|
end
|
|
93
104
|
|
|
94
|
-
def auth_headers(path, method, body='')
|
|
105
|
+
def auth_headers(path, method, body = '')
|
|
95
106
|
timestamp = Time.now.utc.to_i
|
|
96
107
|
sign = signature(timestamp, method, path, body)
|
|
97
108
|
|
data/lib/abucoins/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: abucoins
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pablo Fernandez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-01-
|
|
11
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -270,6 +270,7 @@ files:
|
|
|
270
270
|
- lib/.rubocop.yml
|
|
271
271
|
- lib/abucoins.rb
|
|
272
272
|
- lib/abucoins/abucoins.rb
|
|
273
|
+
- lib/abucoins/exceptions.rb
|
|
273
274
|
- lib/abucoins/version.rb
|
|
274
275
|
- spec/.rubocop.yml
|
|
275
276
|
- spec/ruby_gem_spec.rb
|