ruby_coincheck_client 0.1.3 → 0.1.4
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/README.md +28 -5
- data/lib/ruby_coincheck_client/coincheck_client.rb +125 -7
- data/lib/ruby_coincheck_client/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 548d3483ecb885d58c71859b88043fa818053dc3
|
4
|
+
data.tar.gz: 342ad417776fb1e9a1a2643bcda6b1862646ee93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43becc24c2e680d2e76a0ac619acb426bf11b200fa48b2965a612ea8c74b8c5500d1c65fefc4847a13302d55217e884cded318631db10da11e54098beb09a650
|
7
|
+
data.tar.gz: 02a6a74ba11828ddf2569ea7b7667c7ebe8f3a9c5a7e5229bc9b7f37e156ae596c0431c2fce696037a2e07d6ef2ca9f1d6e26c2d6a264a42c7efe1a531f44399
|
data/README.md
CHANGED
@@ -25,15 +25,38 @@ Or install it yourself as:
|
|
25
25
|
require 'ruby_coincheck_client'
|
26
26
|
|
27
27
|
cc = CoincheckClient.new("YOUR API KEY", "YOUR SECRET KEY")
|
28
|
-
response = cc.read_balance
|
29
|
-
response = cc.
|
28
|
+
response = cc.read_balance
|
29
|
+
response = cc.read_leverage_balance
|
30
|
+
response = cc.read_accounts
|
30
31
|
response = cc.read_transactions
|
32
|
+
response = cc.read_positions
|
31
33
|
response = cc.read_orders
|
32
|
-
response = cc.create_orders("40001", "0.01", "
|
33
|
-
response = cc.
|
34
|
-
response = cc.
|
34
|
+
response = cc.create_orders(rate: "40001", amount: "0.01", order_type: "buy")
|
35
|
+
response = cc.create_orders(rate: "50001", amount: "0.001", order_type: "sell")
|
36
|
+
response = cc.create_orders(market_buy_amount: 100, order_type: "market_buy")
|
37
|
+
response = cc.create_orders(amount: "0.001", order_type: "market_sell")
|
38
|
+
response = cc.create_orders(rate: "40000", amount: "0.001", order_type: "leverage_buy")
|
39
|
+
response = cc.create_orders(rate: "60000", amount: "0.001", order_type: "leverage_sell")
|
40
|
+
response = cc.create_orders(rate: "60000", amount: "0.001", position_id: "2222", order_type: "close_long")
|
41
|
+
response = cc.create_orders(rate: "40000", amount: "0.001", position_id: "2222", order_type: "close_short")
|
42
|
+
response = cc.delete_orders(id: "2503344")
|
43
|
+
response = cc.create_send_money(address: "136aHpRdd7eezbEusAKS2GyWx9eXZsEuMz", amount: "0.0005")
|
44
|
+
response = cc.read_send_money
|
45
|
+
response = cc.read_deposit_money
|
46
|
+
response = cc.create_deposit_money_fast(id: "2222")
|
35
47
|
response = cc.read_ticker
|
48
|
+
response = cc.read_trades
|
36
49
|
response = cc.read_order_books
|
50
|
+
response = cc.read_bank_accounts
|
51
|
+
response = cc.delete_bank_accounts(id: "2222")
|
52
|
+
response = cc.read_withdraws
|
53
|
+
response = cc.delete_withdraws
|
54
|
+
response = cc.create_borrows(amount: "0.001", currency: "BTC")
|
55
|
+
response = cc.read_borrows
|
56
|
+
response = cc.delete_borrows(id: "58606")
|
57
|
+
response = cc.transfer_to_leverage(amount: "1000")
|
58
|
+
response = cc.transfer_from_leverage(amount: "1000")
|
59
|
+
JSON.parse(response.body)
|
37
60
|
```
|
38
61
|
|
39
62
|
## Development
|
@@ -24,6 +24,12 @@ class CoincheckClient
|
|
24
24
|
request_for_get(uri, headers)
|
25
25
|
end
|
26
26
|
|
27
|
+
def read_leverage_balance
|
28
|
+
uri = URI.parse @@base_url + "api/accounts/leverage_balance"
|
29
|
+
headers = get_signature(uri, @key, @secret)
|
30
|
+
request_for_get(uri, headers)
|
31
|
+
end
|
32
|
+
|
27
33
|
def read_accounts
|
28
34
|
uri = URI.parse @@base_url + "api/accounts"
|
29
35
|
headers = get_signature(uri, @key, @secret)
|
@@ -36,17 +42,25 @@ class CoincheckClient
|
|
36
42
|
request_for_get(uri, headers)
|
37
43
|
end
|
38
44
|
|
45
|
+
def read_positions(body = {})
|
46
|
+
uri = URI.parse @@base_url + "api/exchange/leverage/positions"
|
47
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
48
|
+
request_for_get(uri, headers, body)
|
49
|
+
end
|
50
|
+
|
39
51
|
def read_orders
|
40
52
|
uri = URI.parse @@base_url + "api/exchange/orders/opens"
|
41
53
|
headers = get_signature(uri, @key, @secret)
|
42
54
|
request_for_get(uri, headers)
|
43
55
|
end
|
44
56
|
|
45
|
-
def create_orders(rate, amount,
|
57
|
+
def create_orders(order_type:, rate: nil, amount: nil, market_buy_amount: nil, position_id: nil, pair: "btc_jpy")
|
46
58
|
body = {
|
47
59
|
rate: rate,
|
48
60
|
amount: amount,
|
61
|
+
market_buy_amount: market_buy_amount,
|
49
62
|
order_type: order_type,
|
63
|
+
position_id: position_id,
|
50
64
|
pair: pair
|
51
65
|
}
|
52
66
|
uri = URI.parse @@base_url + "api/exchange/orders"
|
@@ -54,16 +68,13 @@ class CoincheckClient
|
|
54
68
|
request_for_post(uri, headers, body)
|
55
69
|
end
|
56
70
|
|
57
|
-
def delete_orders(id)
|
58
|
-
body = {
|
59
|
-
id: id,
|
60
|
-
}
|
71
|
+
def delete_orders(id: )
|
61
72
|
uri = URI.parse @@base_url + "api/exchange/orders/#{id}"
|
62
73
|
headers = get_signature(uri, @key, @secret)
|
63
74
|
request_for_delete(uri, headers)
|
64
75
|
end
|
65
76
|
|
66
|
-
def create_send_money(address
|
77
|
+
def create_send_money(address:, amount:)
|
67
78
|
body = {
|
68
79
|
address: address,
|
69
80
|
amount: amount,
|
@@ -73,16 +84,121 @@ class CoincheckClient
|
|
73
84
|
request_for_post(uri, headers, body)
|
74
85
|
end
|
75
86
|
|
87
|
+
def read_send_money(currency: "BTC")
|
88
|
+
body = { currency: currency }
|
89
|
+
uri = URI.parse @@base_url + "api/send_money"
|
90
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
91
|
+
request_for_get(uri, headers, body)
|
92
|
+
end
|
93
|
+
|
94
|
+
def read_deposit_money(currency: "BTC")
|
95
|
+
body = { currency: currency }
|
96
|
+
uri = URI.parse @@base_url + "api/deposit_money"
|
97
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
98
|
+
request_for_get(uri, headers, body)
|
99
|
+
end
|
100
|
+
|
101
|
+
def create_deposit_money_fast(id: )
|
102
|
+
uri = URI.parse @@base_url + "api/deposit_money/#{id}/fast"
|
103
|
+
headers = get_signature(uri, @key, @secret)
|
104
|
+
request_for_delete(uri, headers)
|
105
|
+
end
|
106
|
+
|
76
107
|
def read_ticker
|
77
108
|
uri = URI.parse @@base_url + "api/ticker"
|
78
109
|
request_for_get(uri)
|
79
110
|
end
|
80
111
|
|
112
|
+
def read_trades
|
113
|
+
uri = URI.parse @@base_url + "api/trades"
|
114
|
+
request_for_get(uri)
|
115
|
+
end
|
116
|
+
|
81
117
|
def read_order_books
|
82
118
|
uri = URI.parse @@base_url + "api/order_books"
|
83
119
|
request_for_get(uri)
|
84
120
|
end
|
85
121
|
|
122
|
+
def read_bank_accounts
|
123
|
+
uri = URI.parse @@base_url + "api/bank_accounts"
|
124
|
+
headers = get_signature(uri, @key, @secret)
|
125
|
+
request_for_get(uri, headers)
|
126
|
+
end
|
127
|
+
|
128
|
+
def create_bank_accounts(bank_name:, branch_name:, bank_account_type:, number:, name:)
|
129
|
+
body = {
|
130
|
+
bank_name: bank_name,
|
131
|
+
branch_name: branch_name,
|
132
|
+
bank_account_type: bank_account_type,
|
133
|
+
number: number,
|
134
|
+
name: name
|
135
|
+
}
|
136
|
+
uri = URI.parse @@base_url + "api/bank_accounts"
|
137
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
138
|
+
request_for_post(uri, headers, body)
|
139
|
+
end
|
140
|
+
|
141
|
+
def delete_bank_accounts(id:)
|
142
|
+
uri = URI.parse @@base_url + "api/bank_accounts/#{id}"
|
143
|
+
headers = get_signature(uri, @key, @secret)
|
144
|
+
request_for_delete(uri, headers)
|
145
|
+
end
|
146
|
+
|
147
|
+
def read_withdraws
|
148
|
+
uri = URI.parse @@base_url + "api/withdraws"
|
149
|
+
headers = get_signature(uri, @key, @secret)
|
150
|
+
request_for_get(uri, headers)
|
151
|
+
end
|
152
|
+
|
153
|
+
def delete_withdraws(id:)
|
154
|
+
uri = URI.parse @@base_url + "api/withdraws/#{id}"
|
155
|
+
headers = get_signature(uri, @key, @secret)
|
156
|
+
request_for_delete(uri, headers)
|
157
|
+
end
|
158
|
+
|
159
|
+
def create_borrows(amount:, currency:)
|
160
|
+
body = {
|
161
|
+
amount: amount,
|
162
|
+
currency: currency
|
163
|
+
}
|
164
|
+
uri = URI.parse @@base_url + "api/lending/borrows"
|
165
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
166
|
+
request_for_post(uri, headers, body)
|
167
|
+
end
|
168
|
+
|
169
|
+
def read_borrows
|
170
|
+
uri = URI.parse @@base_url + "api/lending/borrows/matches"
|
171
|
+
headers = get_signature(uri, @key, @secret)
|
172
|
+
request_for_get(uri, headers)
|
173
|
+
end
|
174
|
+
|
175
|
+
def delete_borrows(id:)
|
176
|
+
body = { id: id}
|
177
|
+
uri = URI.parse @@base_url + "api/lending/borrows/#{id}/repay"
|
178
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
179
|
+
request_for_post(uri, headers, body)
|
180
|
+
end
|
181
|
+
|
182
|
+
def transfer_to_leverage(amount:, currency: "JPY")
|
183
|
+
body = {
|
184
|
+
amount: amount,
|
185
|
+
currency: currency
|
186
|
+
}
|
187
|
+
uri = URI.parse @@base_url + "api/exchange/transfers/to_leverage"
|
188
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
189
|
+
request_for_post(uri, headers, body)
|
190
|
+
end
|
191
|
+
|
192
|
+
def transfer_from_leverage(amount:, currency: "JPY")
|
193
|
+
body = {
|
194
|
+
amount: amount,
|
195
|
+
currency: currency
|
196
|
+
}
|
197
|
+
uri = URI.parse @@base_url + "api/exchange/transfers/from_leverage"
|
198
|
+
headers = get_signature(uri, @key, @secret, body.to_json)
|
199
|
+
request_for_post(uri, headers, body)
|
200
|
+
end
|
201
|
+
|
86
202
|
private
|
87
203
|
def http_request(uri, request)
|
88
204
|
https = Net::HTTP.new(uri.host, uri.port)
|
@@ -96,8 +212,9 @@ class CoincheckClient
|
|
96
212
|
end
|
97
213
|
end
|
98
214
|
|
99
|
-
def request_for_get(uri, headers = {})
|
215
|
+
def request_for_get(uri, headers = {}, body = nil)
|
100
216
|
request = Net::HTTP::Get.new(uri.request_uri, initheader = headers)
|
217
|
+
request.body = body.to_json if body
|
101
218
|
http_request(uri, request)
|
102
219
|
end
|
103
220
|
|
@@ -105,6 +222,7 @@ class CoincheckClient
|
|
105
222
|
request = Net::HTTP::Delete.new(uri.request_uri, initheader = headers)
|
106
223
|
http_request(uri, request)
|
107
224
|
end
|
225
|
+
|
108
226
|
def request_for_post(uri, headers, body)
|
109
227
|
request = Net::HTTP::Post.new(uri.request_uri, initheader = headers)
|
110
228
|
request.body = body.to_json
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_coincheck_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- coincheck
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,8 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.5.1
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: This is ruby client of coincheck api
|
98
98
|
test_files: []
|
99
|
+
has_rdoc:
|