ruby_bitbankcc 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e48f80aa8f0909af9b82e000a38671bb535f412a65cdab919bc42bde57e3988
4
- data.tar.gz: a5d723ccb9c8587bbec729ea422a794ed7a0a16bc153454290031c7570f7db55
3
+ metadata.gz: 4c25b23d4fef224630296e0ca305e92445846325a33585d37718417202b92baf
4
+ data.tar.gz: dae5536d6035f67546136f12ffe1fc52d602bdffc8dd5eeba120fec2313c4cd7
5
5
  SHA512:
6
- metadata.gz: 73b70de6309bc958de176548924cf2fe3b543da982eb180185fe027e8c9f681a99737f09e088b68c16d2daec7c7d4328512b8e15b2ecfd65ea1c5b37ae377f72
7
- data.tar.gz: bf7aca7e8058e8b2263b4b3ca7797f8985a927db67e7b63bfa0c3324d6099282dd1f6f2e04e9e47b18c5276d0d2ac598ca636e8f500f49db2ea25cfead40c10c
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.5.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: 2025-04-02 00:00:00.000000000 Z
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: 3.0.3.1
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
@@ -1,4 +0,0 @@
1
- /Gemfile.lock
2
- /vendor/bundle
3
- /.bundle/*
4
- /pkg
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in ruby_bitbankcc.gemspec
4
- gemspec
5
- gem 'activesupport'
6
- gem 'rest-client'
data/README.md DELETED
@@ -1,49 +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_circuit_break_info('btc_jpy')
37
- bbcc.read_active_orders('btc_jpy')
38
- # you can omit last post_only (omit means false)
39
- bbcc.create_order('btc_jpy', "0.001", 130000, 'buy', 'limit', false)
40
- # you can omit last trigger_price (omit means nil)
41
- bbcc.create_order('btc_jpy', "0.001", 130000, 'buy', 'stop_limit', false, 140000)
42
- bbcc.cancel_order('btc_jpy', order_id)
43
- bbcc.read_trade_history('btc_jpy')
44
- bbcc.read_deposit_history('btc')
45
- bbcc.read_withdrawal_account('btc')
46
- bbcc.request_withdrawal('btc', 'ACCOUNT UUID', '0.001', 'OTP TOKEN', 'SMS TOKEN')
47
- bbcc.read_withdrawal_history('btc')
48
- JSON.parse(response.body)
49
- ```
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
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,256 +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_circuit_break_info(pair)
171
- RestClient.get @@base_public_url + "/#{pair}/circuit_break_info"
172
- end
173
-
174
- private
175
- def http_request(uri, request)
176
- https = Net::HTTP.new(uri.host, uri.port)
177
-
178
- if @@ssl
179
- https.use_ssl = true
180
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
181
- end
182
-
183
- response = https.start do |h|
184
- h.request(request)
185
- end
186
- # XXX: I think we should JSON.parse it, but it makes backward incompatibility. What do you think, code wanderers?
187
- response.body
188
- end
189
-
190
-
191
- def make_nonce_header(message, api_key, secret_key, nonce)
192
- signature = get_signature(secret_key, message)
193
- headers = {
194
- "Content-Type" => "application/json",
195
- "ACCESS-KEY" => api_key,
196
- "ACCESS-NONCE" => nonce,
197
- "ACCESS-SIGNATURE" => signature
198
- }
199
- end
200
-
201
- def make_request_time_header(message, api_key, secret_key, request_time, time_window)
202
- signature = get_signature(secret_key, message)
203
- headers = {
204
- "Content-Type" => "application/json",
205
- "ACCESS-KEY" => api_key,
206
- "ACCESS-REQUEST-TIME" => request_time,
207
- "ACCESS-TIME-WINDOW" => time_window.to_s,
208
- "ACCESS-SIGNATURE" => signature
209
- }
210
- end
211
-
212
- def request_for_get(path, nonce, query = {})
213
- uri = URI.parse @@base_url + path
214
- query_string = query.present? ? '?' + query.to_query : ''
215
- if @@auth_method == "request_time"
216
- request_time = get_current_milisec
217
- message = request_time + @@time_window.to_s + path + query_string
218
- headers = make_request_time_header(message, @key, @secret, request_time, @@time_window)
219
- else
220
- nonce = get_current_milisec
221
- headers = make_nonce_header(path,nonce)
222
- message = nonce + path + query_string
223
- headers = make_nonce_header(message, @key, @secret, nonce)
224
- end
225
- uri.query = query.to_query
226
- request = Net::HTTP::Get.new(uri.request_uri, initheader = headers)
227
- http_request(uri, request)
228
- end
229
-
230
- def request_for_post(path, nonce, body)
231
- uri = URI.parse @@base_url + path
232
- if @@auth_method == "request_time"
233
- request_time = get_current_milisec
234
- message = request_time + @@time_window.to_s + body
235
- headers = make_request_time_header(message, @key, @secret, request_time, @@time_window)
236
- else
237
- nonce = get_current_milisec
238
- headers = make_nonce_header(path,nonce)
239
- message = nonce + body
240
- headers = make_nonce_header(message, @key, @secret, nonce)
241
- end
242
-
243
- request = Net::HTTP::Post.new(uri.request_uri, initheader = headers)
244
- request.body = body
245
-
246
- http_request(uri, request)
247
- end
248
-
249
- def get_current_milisec
250
- (Time.now.to_f * 1000.0).to_i.to_s
251
- end
252
-
253
- def get_signature(secret_key, message)
254
- signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), secret_key, message)
255
- end
256
- end
@@ -1,3 +0,0 @@
1
- module RubyBitbankcc
2
- VERSION = "0.5.0"
3
- end
@@ -1,6 +0,0 @@
1
- require "ruby_bitbankcc/version"
2
- require "ruby_bitbankcc/bitbankcc"
3
-
4
- module RubyBitbankcc
5
- # Your code goes here...
6
- end
@@ -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