ruby_bitbankcc 0.6.0 → 0.7.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
- metadata +4 -18
- data/.gitignore +0 -4
- data/.rspec +0 -2
- data/Gemfile +0 -6
- data/README.md +0 -50
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/lib/ruby_bitbankcc/bitbankcc.rb +0 -260
- data/lib/ruby_bitbankcc/version.rb +0 -3
- data/lib/ruby_bitbankcc.rb +0 -6
- data/ruby_bitbankcc.gemspec +0 -33
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c25b23d4fef224630296e0ca305e92445846325a33585d37718417202b92baf
|
|
4
|
+
data.tar.gz: dae5536d6035f67546136f12ffe1fc52d602bdffc8dd5eeba120fec2313c4cd7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa2af40caf02412fdd168a0be373a0f732b682d2efb19a7b91eefbd9a0d9c8b63109bdd23c3752ee1f51a604d601a269a47d906046c44d9ae85417e116f2bc36
|
|
7
|
+
data.tar.gz: 8cf8d948c812075b068479e25737a0d43999831f2dea87a018d6d62fe8c1049d96bb27076f88173ed91d4bd4ae1939669d768402ee9e8ce8e5c215c14014d909
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_bitbankcc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- bitbankcc
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -80,28 +79,16 @@ dependencies:
|
|
|
80
79
|
- - ">="
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
81
|
version: '0'
|
|
83
|
-
description:
|
|
84
82
|
email:
|
|
85
83
|
- system@bitcoinbank.co.jp
|
|
86
84
|
executables: []
|
|
87
85
|
extensions: []
|
|
88
86
|
extra_rdoc_files: []
|
|
89
|
-
files:
|
|
90
|
-
- ".gitignore"
|
|
91
|
-
- ".rspec"
|
|
92
|
-
- Gemfile
|
|
93
|
-
- README.md
|
|
94
|
-
- Rakefile
|
|
95
|
-
- bin/console
|
|
96
|
-
- lib/ruby_bitbankcc.rb
|
|
97
|
-
- lib/ruby_bitbankcc/bitbankcc.rb
|
|
98
|
-
- lib/ruby_bitbankcc/version.rb
|
|
99
|
-
- ruby_bitbankcc.gemspec
|
|
87
|
+
files: []
|
|
100
88
|
homepage: https://github.com/bitbankinc/ruby_bitbankcc
|
|
101
89
|
licenses: []
|
|
102
90
|
metadata:
|
|
103
91
|
allowed_push_host: https://rubygems.org
|
|
104
|
-
post_install_message:
|
|
105
92
|
rdoc_options: []
|
|
106
93
|
require_paths:
|
|
107
94
|
- lib
|
|
@@ -116,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
116
103
|
- !ruby/object:Gem::Version
|
|
117
104
|
version: '0'
|
|
118
105
|
requirements: []
|
|
119
|
-
rubygems_version:
|
|
120
|
-
signing_key:
|
|
106
|
+
rubygems_version: 4.0.3
|
|
121
107
|
specification_version: 4
|
|
122
108
|
summary: This is ruby client of bitbankcc api
|
|
123
109
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/Gemfile
DELETED
data/README.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# RubyBitbankcc
|
|
2
|
-
|
|
3
|
-
This is ruby client implementation for Bitbankcc API.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Add this line to your application's Gemfile:
|
|
8
|
-
|
|
9
|
-
```ruby
|
|
10
|
-
gem 'ruby_bitbankcc'
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
And then execute:
|
|
14
|
-
|
|
15
|
-
$ bundle
|
|
16
|
-
|
|
17
|
-
Or install it yourself as:
|
|
18
|
-
|
|
19
|
-
$ gem install ruby_bitbankcc
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
```ruby
|
|
24
|
-
#!/usr/bin/env ruby -Ilib
|
|
25
|
-
require 'ruby_bitbankcc'
|
|
26
|
-
|
|
27
|
-
# use request_time method
|
|
28
|
-
bbcc = Bitbankcc.new("YOUR API KEY", "YOUR SECRET KEY",params= {"auth_method"=> "request_time", "time_window"=> "5000"})
|
|
29
|
-
# use nonce method
|
|
30
|
-
bbcc = Bitbankcc.new("YOUR API KEY", "YOUR SECRET KEY",params= {"auth_method"=> "nonce"})
|
|
31
|
-
|
|
32
|
-
bbcc.read_transactions('btc_jpy')
|
|
33
|
-
bbcc.read_ticker('btc_jpy')
|
|
34
|
-
bbcc.read_order_books('btc_jpy')
|
|
35
|
-
bbcc.read_balance()
|
|
36
|
-
bbcc.read_candlestick('btc_jpy', '1month', '2024')
|
|
37
|
-
bbcc.read_circuit_break_info('btc_jpy')
|
|
38
|
-
bbcc.read_active_orders('btc_jpy')
|
|
39
|
-
# you can omit last post_only (omit means false)
|
|
40
|
-
bbcc.create_order('btc_jpy', "0.001", 130000, 'buy', 'limit', false)
|
|
41
|
-
# you can omit last trigger_price (omit means nil)
|
|
42
|
-
bbcc.create_order('btc_jpy', "0.001", 130000, 'buy', 'stop_limit', false, 140000)
|
|
43
|
-
bbcc.cancel_order('btc_jpy', order_id)
|
|
44
|
-
bbcc.read_trade_history('btc_jpy')
|
|
45
|
-
bbcc.read_deposit_history('btc')
|
|
46
|
-
bbcc.read_withdrawal_account('btc')
|
|
47
|
-
bbcc.request_withdrawal('btc', 'ACCOUNT UUID', '0.001', 'OTP TOKEN', 'SMS TOKEN')
|
|
48
|
-
bbcc.read_withdrawal_history('btc')
|
|
49
|
-
JSON.parse(response.body)
|
|
50
|
-
```
|
data/Rakefile
DELETED
data/bin/console
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "ruby_bitbankcc_client"
|
|
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
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
require 'net/http'
|
|
2
|
-
require 'uri'
|
|
3
|
-
require 'openssl'
|
|
4
|
-
require 'json'
|
|
5
|
-
require 'active_support'
|
|
6
|
-
require 'active_support/core_ext'
|
|
7
|
-
require 'pp'
|
|
8
|
-
require 'rest_client'
|
|
9
|
-
|
|
10
|
-
class Bitbankcc
|
|
11
|
-
@@base_url = "https://api.bitbank.cc"
|
|
12
|
-
@@base_public_url = "https://public.bitbank.cc"
|
|
13
|
-
@@auth_method = "request_time"
|
|
14
|
-
@@time_window = 5000
|
|
15
|
-
@@ssl = true
|
|
16
|
-
|
|
17
|
-
def initialize(key = nil, secret = nil, params = {})
|
|
18
|
-
@key = key
|
|
19
|
-
@secret = secret
|
|
20
|
-
if !params[:base_url].nil?
|
|
21
|
-
@@base_url = params[:base_url]
|
|
22
|
-
end
|
|
23
|
-
if !params[:auth_method].nil?
|
|
24
|
-
@@auth_method = params[:auth_method]
|
|
25
|
-
end
|
|
26
|
-
if !params[:time_window].nil?
|
|
27
|
-
@@time_window = params[:time_window]
|
|
28
|
-
end
|
|
29
|
-
if !params[:ssl].nil?
|
|
30
|
-
@@ssl = params[:ssl]
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def read_balance
|
|
35
|
-
path = "/v1/user/assets"
|
|
36
|
-
nonce = get_current_milisec
|
|
37
|
-
request_for_get(path, nonce)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def read_active_orders(pair, count = nil, from_id = nil, end_id = nil, since = nil, _end = nil)
|
|
41
|
-
path = "/v1/user/spot/active_orders"
|
|
42
|
-
nonce = get_current_milisec
|
|
43
|
-
params = {
|
|
44
|
-
pair: pair,
|
|
45
|
-
count: count,
|
|
46
|
-
from_id: from_id,
|
|
47
|
-
end_id: end_id,
|
|
48
|
-
since: since,
|
|
49
|
-
end: _end
|
|
50
|
-
}.compact
|
|
51
|
-
request_for_get(path, nonce, params)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def read_margin_positions()
|
|
55
|
-
path = "/v1/user/margin/positions"
|
|
56
|
-
nonce = get_current_milisec
|
|
57
|
-
request_for_get(path, nonce)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def create_order(pair, amount, price, side, type, post_only = false, trigger_price = nil, position_side = nil)
|
|
61
|
-
path = "/v1/user/spot/order"
|
|
62
|
-
nonce = get_current_milisec
|
|
63
|
-
body = {
|
|
64
|
-
pair: pair,
|
|
65
|
-
amount: amount,
|
|
66
|
-
price: price,
|
|
67
|
-
side: side,
|
|
68
|
-
type: type,
|
|
69
|
-
post_only: post_only,
|
|
70
|
-
trigger_price: trigger_price,
|
|
71
|
-
position_side: position_side
|
|
72
|
-
}.to_json
|
|
73
|
-
request_for_post(path, nonce, body)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def cancel_order(pair, order_id)
|
|
77
|
-
path = "/v1/user/spot/cancel_order"
|
|
78
|
-
nonce = get_current_milisec
|
|
79
|
-
body = {
|
|
80
|
-
pair: pair,
|
|
81
|
-
order_id: order_id
|
|
82
|
-
}.to_json
|
|
83
|
-
request_for_post(path, nonce, body)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def read_trade_history(pair, count = nil, order_id = nil, since = nil, _end = nil, order = nil)
|
|
87
|
-
path = "/v1/user/spot/trade_history"
|
|
88
|
-
nonce = get_current_milisec
|
|
89
|
-
params = {
|
|
90
|
-
pair: pair,
|
|
91
|
-
count: count,
|
|
92
|
-
order_id: order_id,
|
|
93
|
-
since: since,
|
|
94
|
-
end: _end,
|
|
95
|
-
order: order
|
|
96
|
-
}.compact
|
|
97
|
-
|
|
98
|
-
request_for_get(path, nonce, params)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def read_deposit_history(asset, count = nil, since = nil, _end = nil, order = nil)
|
|
102
|
-
path = "/v1/user/deposit_history"
|
|
103
|
-
nonce = get_current_milisec
|
|
104
|
-
params = {
|
|
105
|
-
asset: asset,
|
|
106
|
-
count: count,
|
|
107
|
-
since: since,
|
|
108
|
-
end: _end,
|
|
109
|
-
order: order
|
|
110
|
-
}.compact
|
|
111
|
-
|
|
112
|
-
request_for_get(path, nonce, params)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def read_withdrawal_account(asset)
|
|
116
|
-
path = "/v1/user/withdrawal_account"
|
|
117
|
-
nonce = get_current_milisec
|
|
118
|
-
params = {
|
|
119
|
-
asset: asset
|
|
120
|
-
}.compact
|
|
121
|
-
|
|
122
|
-
request_for_get(path, nonce, params)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def request_withdrawal(asset, uuid, amount, otp_token = nil, sms_token = nil)
|
|
126
|
-
path = "/v1/user/request_withdrawal"
|
|
127
|
-
nonce = get_current_milisec
|
|
128
|
-
body = {
|
|
129
|
-
asset: asset,
|
|
130
|
-
uuid: uuid,
|
|
131
|
-
amount: amount,
|
|
132
|
-
otp_token: otp_token,
|
|
133
|
-
sms_token: sms_token
|
|
134
|
-
}.compact.to_json
|
|
135
|
-
request_for_post(path, nonce, body)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def read_withdrawal_history(asset, count = nil, since = nil, _end = nil, order = nil)
|
|
139
|
-
path = "/v1/user/withdrawal_history"
|
|
140
|
-
nonce = get_current_milisec
|
|
141
|
-
params = {
|
|
142
|
-
asset: asset,
|
|
143
|
-
count: count,
|
|
144
|
-
since: since,
|
|
145
|
-
end: _end,
|
|
146
|
-
order: order
|
|
147
|
-
}.compact
|
|
148
|
-
|
|
149
|
-
request_for_get(path, nonce, params)
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def read_user_subscribe()
|
|
153
|
-
path = "/v1/user/subscribe"
|
|
154
|
-
nonce = get_current_milisec
|
|
155
|
-
request_for_get(path, nonce)
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def read_ticker(pair)
|
|
159
|
-
RestClient.get @@base_public_url + "/#{pair}/ticker"
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def read_order_books(pair)
|
|
163
|
-
RestClient.get @@base_public_url + "/#{pair}/depth"
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def read_transactions(pair, date = '')
|
|
167
|
-
RestClient.get @@base_public_url + "/#{pair}/transactions" + (date.empty? ? '' : '/' + date)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def read_candlestick(pair, candle_type, date)
|
|
171
|
-
RestClient.get @@base_public_url + "/#{pair}/candlestick/#{candle_type}/#{date}"
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def read_circuit_break_info(pair)
|
|
175
|
-
RestClient.get @@base_public_url + "/#{pair}/circuit_break_info"
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
private
|
|
179
|
-
def http_request(uri, request)
|
|
180
|
-
https = Net::HTTP.new(uri.host, uri.port)
|
|
181
|
-
|
|
182
|
-
if @@ssl
|
|
183
|
-
https.use_ssl = true
|
|
184
|
-
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
response = https.start do |h|
|
|
188
|
-
h.request(request)
|
|
189
|
-
end
|
|
190
|
-
# XXX: I think we should JSON.parse it, but it makes backward incompatibility. What do you think, code wanderers?
|
|
191
|
-
response.body
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
def make_nonce_header(message, api_key, secret_key, nonce)
|
|
196
|
-
signature = get_signature(secret_key, message)
|
|
197
|
-
headers = {
|
|
198
|
-
"Content-Type" => "application/json",
|
|
199
|
-
"ACCESS-KEY" => api_key,
|
|
200
|
-
"ACCESS-NONCE" => nonce,
|
|
201
|
-
"ACCESS-SIGNATURE" => signature
|
|
202
|
-
}
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def make_request_time_header(message, api_key, secret_key, request_time, time_window)
|
|
206
|
-
signature = get_signature(secret_key, message)
|
|
207
|
-
headers = {
|
|
208
|
-
"Content-Type" => "application/json",
|
|
209
|
-
"ACCESS-KEY" => api_key,
|
|
210
|
-
"ACCESS-REQUEST-TIME" => request_time,
|
|
211
|
-
"ACCESS-TIME-WINDOW" => time_window.to_s,
|
|
212
|
-
"ACCESS-SIGNATURE" => signature
|
|
213
|
-
}
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
def request_for_get(path, nonce, query = {})
|
|
217
|
-
uri = URI.parse @@base_url + path
|
|
218
|
-
query_string = query.present? ? '?' + query.to_query : ''
|
|
219
|
-
if @@auth_method == "request_time"
|
|
220
|
-
request_time = get_current_milisec
|
|
221
|
-
message = request_time + @@time_window.to_s + path + query_string
|
|
222
|
-
headers = make_request_time_header(message, @key, @secret, request_time, @@time_window)
|
|
223
|
-
else
|
|
224
|
-
nonce = get_current_milisec
|
|
225
|
-
headers = make_nonce_header(path,nonce)
|
|
226
|
-
message = nonce + path + query_string
|
|
227
|
-
headers = make_nonce_header(message, @key, @secret, nonce)
|
|
228
|
-
end
|
|
229
|
-
uri.query = query.to_query
|
|
230
|
-
request = Net::HTTP::Get.new(uri.request_uri, initheader = headers)
|
|
231
|
-
http_request(uri, request)
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
def request_for_post(path, nonce, body)
|
|
235
|
-
uri = URI.parse @@base_url + path
|
|
236
|
-
if @@auth_method == "request_time"
|
|
237
|
-
request_time = get_current_milisec
|
|
238
|
-
message = request_time + @@time_window.to_s + body
|
|
239
|
-
headers = make_request_time_header(message, @key, @secret, request_time, @@time_window)
|
|
240
|
-
else
|
|
241
|
-
nonce = get_current_milisec
|
|
242
|
-
headers = make_nonce_header(path,nonce)
|
|
243
|
-
message = nonce + body
|
|
244
|
-
headers = make_nonce_header(message, @key, @secret, nonce)
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
request = Net::HTTP::Post.new(uri.request_uri, initheader = headers)
|
|
248
|
-
request.body = body
|
|
249
|
-
|
|
250
|
-
http_request(uri, request)
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
def get_current_milisec
|
|
254
|
-
(Time.now.to_f * 1000.0).to_i.to_s
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def get_signature(secret_key, message)
|
|
258
|
-
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), secret_key, message)
|
|
259
|
-
end
|
|
260
|
-
end
|
data/lib/ruby_bitbankcc.rb
DELETED
data/ruby_bitbankcc.gemspec
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'ruby_bitbankcc/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = "ruby_bitbankcc"
|
|
8
|
-
spec.version = RubyBitbankcc::VERSION
|
|
9
|
-
spec.authors = ["bitbankcc"]
|
|
10
|
-
spec.email = ["system@bitcoinbank.co.jp"]
|
|
11
|
-
|
|
12
|
-
spec.summary = %q{This is ruby client of bitbankcc api}
|
|
13
|
-
spec.homepage = "https://github.com/bitbankinc/ruby_bitbankcc"
|
|
14
|
-
|
|
15
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
16
|
-
# delete this section to allow pushing this gem to any host.
|
|
17
|
-
if spec.respond_to?(:metadata)
|
|
18
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
19
|
-
else
|
|
20
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
-
spec.bindir = "exe"
|
|
25
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
26
|
-
spec.require_paths = ["lib"]
|
|
27
|
-
|
|
28
|
-
spec.add_dependency "activesupport"
|
|
29
|
-
spec.add_dependency "rest-client"
|
|
30
|
-
spec.add_development_dependency "bundler", "~> 2.4"
|
|
31
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
-
spec.add_development_dependency "rspec"
|
|
33
|
-
end
|