ruby-liquid 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/.rspec_status +3 -3
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/lib/liquid/client.rb +40 -15
- data/lib/liquid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b870defd2092079296ffb2ef6d8f86c44ad51c08bed52d8ff79bab1ec7dfc476
|
4
|
+
data.tar.gz: e2876cdca6f837e6bbe57c6f9ef463f63207bf4bc29b5ba7dca9ffaa2a38df6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc7e97cf8da7d4e0a1525154526d89946e723d372f0fec9512866754397028d33ecdf342a264af9fe020f48e3bbdf55971ff9e4f9d214ddbc2120e30a2af527a
|
7
|
+
data.tar.gz: 69aa01c715673f73c507f078806b05ee7d662c3b4dd0c76029ece241f1b1e4c8e5643a04b59a0e5339c09113e2f9dd74ea4526c0bb20a25671c62c27e147bdf4
|
data/.rspec_status
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
---------------------------- | ------ | --------------- |
|
3
|
-
./spec/liquid_spec.rb[1:1] | passed | 0.
|
4
|
-
./spec/liquid_spec.rb[1:2:1] | passed | 0.
|
5
|
-
./spec/liquid_spec.rb[1:3:1] | passed | 0.
|
3
|
+
./spec/liquid_spec.rb[1:1] | passed | 0.00097 seconds |
|
4
|
+
./spec/liquid_spec.rb[1:2:1] | passed | 0.18417 seconds |
|
5
|
+
./spec/liquid_spec.rb[1:3:1] | passed | 0.2375 seconds |
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,8 +25,11 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
```rb
|
28
|
-
|
29
|
-
|
28
|
+
require 'ruby-liquid'
|
29
|
+
Liquid::Client.new(token, secret).product
|
30
|
+
Liquid::Client.new(token, secret).product_id("BCHJPY")
|
31
|
+
Liquid::Client.new(token, secret).create_order(pair: "BCHJPY", side: 'buy', quantity: 0.01, price: 40000)
|
32
|
+
|
30
33
|
```
|
31
34
|
|
32
35
|
## Contributing
|
data/lib/liquid/client.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
module Liquid
|
2
2
|
class Client
|
3
|
-
|
3
|
+
class InvalidArgument < StandardError; end
|
4
4
|
|
5
|
-
|
5
|
+
attr_reader :http, :token_id, :user_secret, :path, :params
|
6
|
+
attr_accessor :url
|
7
|
+
|
8
|
+
|
6
9
|
|
7
10
|
def initialize(token, secret)
|
11
|
+
@url = "https://api.liquid.com"
|
8
12
|
@http = http
|
9
13
|
@token_id = token || ENV["LIQUID_KEY"]
|
10
14
|
@user_secret = secret || ENV["LIQUID_SECRET"]
|
11
15
|
end
|
12
16
|
|
17
|
+
# get
|
13
18
|
def product
|
14
19
|
@path = '/products'
|
15
|
-
|
20
|
+
get_request
|
16
21
|
end
|
17
22
|
|
18
23
|
def product_detail(pair)
|
@@ -22,15 +27,7 @@ module Liquid
|
|
22
27
|
end
|
23
28
|
|
24
29
|
def product_id(pair)
|
25
|
-
product_detail(pair)["id"]
|
26
|
-
end
|
27
|
-
|
28
|
-
def product_id(pair)
|
29
|
-
product_detail(pair)["id"]
|
30
|
-
end
|
31
|
-
|
32
|
-
def product_id(pair)
|
33
|
-
product_detail(pair)["id"]
|
30
|
+
product_detail(pair)["id"].to_i
|
34
31
|
end
|
35
32
|
|
36
33
|
def taker_buy_price(pair)
|
@@ -41,16 +38,33 @@ module Liquid
|
|
41
38
|
product_detail(pair)["market_ask"].to_f
|
42
39
|
end
|
43
40
|
|
41
|
+
# post
|
42
|
+
def create_order(order_type: "limit", pair: nil, side: nil, quantity: nil, price: nil)
|
43
|
+
pair_id = product_id(pair)
|
44
|
+
raise InvalidArgument if side.nil? || quantity.nil? || price.nil?
|
45
|
+
@path = '/orders'
|
46
|
+
@params =
|
47
|
+
{
|
48
|
+
"order": {
|
49
|
+
"order_type": order_type,
|
50
|
+
"product_id": pair_id,
|
51
|
+
"side": side,
|
52
|
+
"quantity": quantity,
|
53
|
+
"price": price
|
54
|
+
}
|
55
|
+
}.to_json
|
56
|
+
post_request
|
57
|
+
end
|
58
|
+
|
44
59
|
private
|
45
60
|
def http
|
46
|
-
uri = URI.parse(
|
61
|
+
uri = URI.parse(url)
|
47
62
|
http = Net::HTTP.new(uri.host, uri.port)
|
48
63
|
http.use_ssl = true
|
49
64
|
http
|
50
65
|
end
|
51
66
|
|
52
|
-
|
53
|
-
def request
|
67
|
+
def get_request
|
54
68
|
request = Net::HTTP::Get.new(path)
|
55
69
|
request.add_field('X-Quoine-API-Version', '2')
|
56
70
|
request.add_field('X-Quoine-Auth', signature)
|
@@ -60,6 +74,17 @@ module Liquid
|
|
60
74
|
JSON.parse(response.body)
|
61
75
|
end
|
62
76
|
|
77
|
+
def post_request
|
78
|
+
request = Net::HTTP::Post.new(path)
|
79
|
+
request.body = @params
|
80
|
+
request.add_field('X-Quoine-API-Version', '2')
|
81
|
+
request.add_field('X-Quoine-Auth', signature)
|
82
|
+
request.add_field('Content-Type', 'application/json')
|
83
|
+
response = http.request(request)
|
84
|
+
# TODO: error handling
|
85
|
+
JSON.parse(response.body)
|
86
|
+
end
|
87
|
+
|
63
88
|
def auth_payload
|
64
89
|
{
|
65
90
|
path: path,
|
data/lib/liquid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-liquid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- emono
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|