bitflyer 2.0.2 → 2.1.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/.github/dependabot.yml +13 -21
- data/.github/workflows/release.yaml +1 -1
- data/.github/workflows/test.yml +16 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +58 -29
- data/README.md +16 -0
- data/Rakefile +5 -0
- data/Steepfile +12 -0
- data/bitflyer.gemspec +0 -1
- data/lib/bitflyer/http.rb +49 -26
- data/lib/bitflyer/realtime/client.rb +1 -0
- data/lib/bitflyer/realtime/websocket.rb +13 -8
- data/lib/bitflyer/version.rb +1 -1
- data/sig/bitflyer/http/private.rbs +101 -0
- data/sig/bitflyer/http/public.rbs +23 -0
- data/sig/bitflyer/http.rbs +33 -0
- data/sig/bitflyer/realtime/client.rbs +124 -0
- data/sig/bitflyer/realtime/websocket.rbs +56 -0
- data/sig/bitflyer.rbs +9 -0
- data/sig-private/websocket-client-simple.rbs +18 -0
- metadata +9 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e097c3c9b8db3dd701a6aa8022d08d0234c856bc2d9102d3a8400a589fc7848
|
|
4
|
+
data.tar.gz: 9403012c78543bd9856936f59e345aecbed768b32057a9c75413a7c6150b94f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 486de5c7e687e95155f3c28e7c82ed120acb97006267323ef1de5b7293ee2410f9a2aa4b9994875687131b4eca3cead7cbe2d13df65f599bd9ec5d4029ccc3b5
|
|
7
|
+
data.tar.gz: c87b0ec70a9c00de556778b3a308e5a67399717bf81d675d778a989185305a95fb2895108680a7f418f83d41609ee9cef4389c4dd9cbeb744cf2c38fd3ea586b
|
data/.github/dependabot.yml
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
version: 2
|
|
2
2
|
updates:
|
|
3
|
-
- package-ecosystem: bundler
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- dependency-name: rubocop
|
|
17
|
-
versions:
|
|
18
|
-
- 1.12.0
|
|
19
|
-
- 1.12.1
|
|
20
|
-
- dependency-name: regexp_parser
|
|
21
|
-
versions:
|
|
22
|
-
- 2.1.0
|
|
23
|
-
- 2.1.1
|
|
3
|
+
- package-ecosystem: bundler
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
time: "12:00"
|
|
8
|
+
timezone: Asia/Tokyo
|
|
9
|
+
open-pull-requests-limit: 20
|
|
10
|
+
allow:
|
|
11
|
+
- dependency-type: direct
|
|
12
|
+
- dependency-type: indirect
|
|
13
|
+
ignore:
|
|
14
|
+
- dependency-name: parallel
|
|
15
|
+
update-types: ["version-update:semver-major"]
|
|
@@ -30,7 +30,7 @@ jobs:
|
|
|
30
30
|
- name: Setup Git
|
|
31
31
|
run: |
|
|
32
32
|
git config --global user.email "unhappychoice@gmail.com"
|
|
33
|
-
git config --global user.name "
|
|
33
|
+
git config --global user.name "Yuji Ueki"
|
|
34
34
|
- name: Install gem-release
|
|
35
35
|
run: gem install gem-release
|
|
36
36
|
- name: Bump version
|
data/.github/workflows/test.yml
CHANGED
|
@@ -17,6 +17,22 @@ jobs:
|
|
|
17
17
|
run: bundle install --jobs 4
|
|
18
18
|
- name: Run lint
|
|
19
19
|
run: bundle exec rubocop lib
|
|
20
|
+
typecheck:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
env:
|
|
23
|
+
BUNDLE_WITH: typecheck
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@master
|
|
26
|
+
- name: Set up Ruby
|
|
27
|
+
uses: ruby/setup-ruby@v1
|
|
28
|
+
with:
|
|
29
|
+
ruby-version: .ruby-version
|
|
30
|
+
- name: Install bundler
|
|
31
|
+
run: gem install bundler
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: bundle install --jobs 4
|
|
34
|
+
- name: Run type check
|
|
35
|
+
run: bundle exec rake steep
|
|
20
36
|
test:
|
|
21
37
|
runs-on: ubuntu-latest
|
|
22
38
|
strategy:
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bitflyer (2.0
|
|
5
|
-
faraday (>= 2.0)
|
|
4
|
+
bitflyer (2.1.0)
|
|
6
5
|
websocket-client-simple (>= 0.9)
|
|
7
6
|
|
|
8
7
|
GEM
|
|
@@ -11,37 +10,45 @@ GEM
|
|
|
11
10
|
ast (2.4.3)
|
|
12
11
|
base64 (0.3.0)
|
|
13
12
|
coderay (1.1.3)
|
|
13
|
+
concurrent-ruby (1.3.8)
|
|
14
|
+
csv (3.3.7)
|
|
14
15
|
diff-lcs (1.6.2)
|
|
15
16
|
event_emitter (0.2.6)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
io-console (0.8.2)
|
|
23
|
-
json (2.18.1)
|
|
24
|
-
language_server-protocol (3.17.0.5)
|
|
17
|
+
ffi (1.17.4)
|
|
18
|
+
ffi (1.17.4-x86_64-darwin)
|
|
19
|
+
fileutils (1.8.1)
|
|
20
|
+
io-console (0.9.5)
|
|
21
|
+
json (3.1.0)
|
|
22
|
+
language_server-protocol (3.17.0.6)
|
|
25
23
|
lint_roller (1.1.0)
|
|
24
|
+
listen (3.10.1)
|
|
25
|
+
logger
|
|
26
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
27
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
26
28
|
logger (1.7.0)
|
|
27
29
|
method_source (1.1.0)
|
|
28
30
|
mutex_m (0.3.0)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
parallel (1.27.0)
|
|
32
|
-
parser (3.3.10.1)
|
|
31
|
+
parallel (1.28.0)
|
|
32
|
+
parser (3.3.13.0)
|
|
33
33
|
ast (~> 2.4.1)
|
|
34
34
|
racc
|
|
35
35
|
prism (1.9.0)
|
|
36
|
-
pry (0.16.
|
|
36
|
+
pry (0.16.1)
|
|
37
37
|
coderay (~> 1.1)
|
|
38
38
|
method_source (~> 1.0)
|
|
39
39
|
reline (>= 0.6.0)
|
|
40
40
|
racc (1.8.1)
|
|
41
41
|
rainbow (3.1.1)
|
|
42
|
-
rake (13.
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
rake (13.4.2)
|
|
43
|
+
rb-fsevent (0.11.2)
|
|
44
|
+
rb-inotify (0.11.1)
|
|
45
|
+
ffi (~> 1.0)
|
|
46
|
+
rbs (4.2.0)
|
|
47
|
+
logger
|
|
48
|
+
prism (>= 1.6.0)
|
|
49
|
+
tsort
|
|
50
|
+
regexp_parser (2.13.1)
|
|
51
|
+
reline (0.7.0)
|
|
45
52
|
io-console (~> 0.5)
|
|
46
53
|
rspec (3.13.2)
|
|
47
54
|
rspec-core (~> 3.13.0)
|
|
@@ -52,29 +59,50 @@ GEM
|
|
|
52
59
|
rspec-expectations (3.13.5)
|
|
53
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
61
|
rspec-support (~> 3.13.0)
|
|
55
|
-
rspec-mocks (3.13.
|
|
62
|
+
rspec-mocks (3.13.8)
|
|
56
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
57
64
|
rspec-support (~> 3.13.0)
|
|
58
65
|
rspec-support (3.13.7)
|
|
59
|
-
rubocop (1.
|
|
60
|
-
json (
|
|
66
|
+
rubocop (1.92.2)
|
|
67
|
+
json (>= 2.3)
|
|
61
68
|
language_server-protocol (~> 3.17.0.2)
|
|
62
69
|
lint_roller (~> 1.1.0)
|
|
63
|
-
parallel (
|
|
70
|
+
parallel (>= 1.10)
|
|
64
71
|
parser (>= 3.3.0.2)
|
|
65
72
|
rainbow (>= 2.2.2, < 4.0)
|
|
66
|
-
regexp_parser (>= 2.
|
|
73
|
+
regexp_parser (>= 2.11.3, < 3.0)
|
|
67
74
|
rubocop-ast (>= 1.49.0, < 2.0)
|
|
68
75
|
ruby-progressbar (~> 1.7)
|
|
69
76
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
70
|
-
rubocop-ast (1.
|
|
77
|
+
rubocop-ast (1.50.0)
|
|
71
78
|
parser (>= 3.3.7.2)
|
|
72
79
|
prism (~> 1.7)
|
|
73
80
|
ruby-progressbar (1.13.0)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
securerandom (0.4.1)
|
|
82
|
+
steep (2.1.0)
|
|
83
|
+
concurrent-ruby (>= 1.1.10)
|
|
84
|
+
csv (>= 3.0.9)
|
|
85
|
+
fileutils (>= 1.1.0)
|
|
86
|
+
json (>= 2.1.0)
|
|
87
|
+
language_server-protocol (>= 3.17.0.4, < 4.0)
|
|
88
|
+
listen (~> 3.0)
|
|
89
|
+
logger (>= 1.3.0)
|
|
90
|
+
parser (>= 3.2)
|
|
91
|
+
prism (>= 0.25.0)
|
|
92
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
93
|
+
rbs (~> 4.2)
|
|
94
|
+
securerandom (>= 0.1)
|
|
95
|
+
strscan (>= 1.0.0)
|
|
96
|
+
terminal-table (>= 2, < 5)
|
|
97
|
+
uri (>= 0.12.0)
|
|
98
|
+
strscan (3.1.8)
|
|
99
|
+
terminal-table (4.0.0)
|
|
100
|
+
unicode-display_width (>= 1.1.1, < 4)
|
|
101
|
+
tsort (0.2.0)
|
|
102
|
+
unicode-display_width (3.3.0)
|
|
103
|
+
unicode-emoji (~> 4.3)
|
|
104
|
+
unicode-emoji (4.3.0)
|
|
105
|
+
uri (1.1.2)
|
|
78
106
|
websocket (1.2.11)
|
|
79
107
|
websocket-client-simple (0.9.0)
|
|
80
108
|
base64
|
|
@@ -93,6 +121,7 @@ DEPENDENCIES
|
|
|
93
121
|
rake
|
|
94
122
|
rspec
|
|
95
123
|
rubocop
|
|
124
|
+
steep
|
|
96
125
|
|
|
97
126
|
BUNDLED WITH
|
|
98
127
|
2.6.9
|
data/README.md
CHANGED
|
@@ -80,6 +80,18 @@ client.ready = -> { p "Client is ready to receive events" }
|
|
|
80
80
|
client.disconnected = ->(error) { p "Client got disconnected" }
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
### Type signatures
|
|
84
|
+
|
|
85
|
+
The gem ships [RBS](https://github.com/ruby/rbs) signatures in `sig/`, so [Steep](https://github.com/soutaro/steep) and other RBS-based tools
|
|
86
|
+
can check code that uses it. API responses are parsed JSON and are typed as `untyped`.
|
|
87
|
+
|
|
88
|
+
To type check the gem itself:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
bundle config set --local with typecheck
|
|
92
|
+
bundle install
|
|
93
|
+
bundle exec rake steep
|
|
94
|
+
```
|
|
83
95
|
|
|
84
96
|
|
|
85
97
|
## Contributing
|
|
@@ -114,3 +126,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
114
126
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
115
127
|
|
|
116
128
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
129
|
+
|
|
130
|
+
## Author
|
|
131
|
+
|
|
132
|
+
[@unhappychoice](https://unhappychoice.com)
|
data/Rakefile
CHANGED
data/Steepfile
ADDED
data/bitflyer.gemspec
CHANGED
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
-
spec.add_dependency 'faraday', '>= 2.0'
|
|
22
21
|
spec.add_dependency 'websocket-client-simple', '>= 0.9'
|
|
23
22
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
24
23
|
spec.add_development_dependency 'pry'
|
data/lib/bitflyer/http.rb
CHANGED
|
@@ -3,45 +3,68 @@
|
|
|
3
3
|
require 'bitflyer'
|
|
4
4
|
require 'bitflyer/http/public'
|
|
5
5
|
require 'bitflyer/http/private'
|
|
6
|
-
require '
|
|
6
|
+
require 'net/http'
|
|
7
|
+
require 'uri'
|
|
8
|
+
require 'json'
|
|
7
9
|
require 'openssl'
|
|
8
10
|
|
|
9
11
|
module Bitflyer
|
|
10
12
|
module HTTP
|
|
11
|
-
|
|
12
|
-
extend Forwardable
|
|
13
|
+
BASE_URL = 'https://api.bitflyer.jp'
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
Response = Struct.new(:body)
|
|
15
16
|
|
|
17
|
+
class Connection
|
|
16
18
|
def initialize(key, secret)
|
|
17
|
-
@connection = Faraday::Connection.new(url: 'https://api.bitflyer.jp') do |f|
|
|
18
|
-
f.request :json
|
|
19
|
-
f.response :json
|
|
20
|
-
f.use Authentication, key, secret
|
|
21
|
-
f.adapter Faraday.default_adapter
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
class Authentication < Faraday::Middleware
|
|
27
|
-
def initialize(app, key, secret)
|
|
28
|
-
super(app)
|
|
29
19
|
@key = key
|
|
30
20
|
@secret = secret
|
|
21
|
+
@uri = URI.parse(BASE_URL)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get(path, params = {})
|
|
25
|
+
query = URI.encode_www_form(params.compact)
|
|
26
|
+
full_path = query.empty? ? path : "#{path}?#{query}"
|
|
27
|
+
request = Net::HTTP::Get.new(full_path, default_headers)
|
|
28
|
+
sign_request(request, full_path)
|
|
29
|
+
Response.new(execute(request))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def post(path, body = {})
|
|
33
|
+
request = Net::HTTP::Post.new(path, default_headers.merge('Content-Type' => 'application/json'))
|
|
34
|
+
request.body = JSON.generate(body.compact)
|
|
35
|
+
sign_request(request, path, request.body)
|
|
36
|
+
Response.new(execute(request))
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def default_headers
|
|
42
|
+
{ 'Accept' => 'application/json' }
|
|
31
43
|
end
|
|
32
44
|
|
|
33
|
-
def
|
|
34
|
-
|
|
45
|
+
def sign_request(request, path, body = '')
|
|
46
|
+
key = @key
|
|
47
|
+
secret = @secret
|
|
48
|
+
return if key.nil? || secret.nil?
|
|
35
49
|
|
|
36
50
|
timestamp = Time.now.to_i.to_s
|
|
37
|
-
method =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
method = request.method.upcase
|
|
52
|
+
text = timestamp + method + path + (body || '')
|
|
53
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), secret, text)
|
|
54
|
+
request['ACCESS-KEY'] = key
|
|
55
|
+
request['ACCESS-TIMESTAMP'] = timestamp
|
|
56
|
+
request['ACCESS-SIGN'] = signature
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def execute(request)
|
|
60
|
+
response = Net::HTTP.start(@uri.host.to_s, @uri.port, use_ssl: true) { |http| http.request(request) }
|
|
61
|
+
parse_body(response.body)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def parse_body(body)
|
|
65
|
+
JSON.parse(body)
|
|
66
|
+
rescue JSON::ParserError
|
|
67
|
+
body
|
|
45
68
|
end
|
|
46
69
|
end
|
|
47
70
|
end
|
|
@@ -36,7 +36,7 @@ module Bitflyer
|
|
|
36
36
|
@websocket_client.on(:close) { |error| this.handle_close(error: error) }
|
|
37
37
|
rescue SocketError => e
|
|
38
38
|
puts e
|
|
39
|
-
puts e.backtrace
|
|
39
|
+
puts e.backtrace&.join("\n")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def start_monitoring
|
|
@@ -54,8 +54,10 @@ module Bitflyer
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def send_ping
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
last_ping_at = @last_ping_at
|
|
58
|
+
ping_interval = @ping_interval
|
|
59
|
+
return unless last_ping_at && ping_interval
|
|
60
|
+
return unless Time.now.to_i - last_ping_at > ping_interval / 1000
|
|
59
61
|
|
|
60
62
|
debug_log 'Sent ping'
|
|
61
63
|
@websocket_client.send '2'
|
|
@@ -63,8 +65,11 @@ module Bitflyer
|
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
def wait_pong
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
last_pong_at = @last_pong_at
|
|
69
|
+
ping_interval = @ping_interval
|
|
70
|
+
ping_timeout = @ping_timeout
|
|
71
|
+
return unless last_pong_at && ping_interval && ping_timeout
|
|
72
|
+
return unless Time.now.to_i - last_pong_at > (ping_interval + ping_timeout) / 1000
|
|
68
73
|
|
|
69
74
|
debug_log 'Timed out waiting pong'
|
|
70
75
|
@websocket_client.close
|
|
@@ -102,7 +107,7 @@ module Bitflyer
|
|
|
102
107
|
end
|
|
103
108
|
rescue StandardError => e
|
|
104
109
|
puts e
|
|
105
|
-
puts e.backtrace
|
|
110
|
+
puts e.backtrace&.join("\n")
|
|
106
111
|
end
|
|
107
112
|
|
|
108
113
|
def handle_close(error:)
|
|
@@ -127,8 +132,8 @@ module Bitflyer
|
|
|
127
132
|
def authenticate
|
|
128
133
|
debug_log 'Authenticate'
|
|
129
134
|
timestamp = Time.now.to_i
|
|
130
|
-
nonce = Random.new.bytes(16).unpack1('H*')
|
|
131
|
-
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @secret, timestamp.to_s + nonce)
|
|
135
|
+
nonce = Random.new.bytes(16).unpack1('H*').to_s
|
|
136
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @secret.to_s, timestamp.to_s + nonce)
|
|
132
137
|
auth_params = {
|
|
133
138
|
api_key: @key,
|
|
134
139
|
timestamp: timestamp,
|
data/lib/bitflyer/version.rb
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
module Bitflyer
|
|
2
|
+
module HTTP
|
|
3
|
+
module Private
|
|
4
|
+
class Client
|
|
5
|
+
@connection: Connection
|
|
6
|
+
|
|
7
|
+
def initialize: (String key, String secret) -> void
|
|
8
|
+
|
|
9
|
+
def permissions: () -> untyped
|
|
10
|
+
|
|
11
|
+
def balance: () -> untyped
|
|
12
|
+
|
|
13
|
+
def collateral: () -> untyped
|
|
14
|
+
|
|
15
|
+
def addresses: () -> untyped
|
|
16
|
+
|
|
17
|
+
def coin_ins: () -> untyped
|
|
18
|
+
|
|
19
|
+
def coin_outs: () -> untyped
|
|
20
|
+
|
|
21
|
+
def bank_accounts: () -> untyped
|
|
22
|
+
|
|
23
|
+
def deposits: () -> untyped
|
|
24
|
+
|
|
25
|
+
def withdraw: (
|
|
26
|
+
?currency_code: String,
|
|
27
|
+
?bank_account_id: Integer?,
|
|
28
|
+
?amount: Numeric?,
|
|
29
|
+
?code: String?
|
|
30
|
+
) -> untyped
|
|
31
|
+
|
|
32
|
+
def withdrawals: () -> untyped
|
|
33
|
+
|
|
34
|
+
def send_child_order: (
|
|
35
|
+
?product_code: String,
|
|
36
|
+
?child_order_type: String?,
|
|
37
|
+
?side: String?,
|
|
38
|
+
?price: Numeric?,
|
|
39
|
+
?size: Numeric?,
|
|
40
|
+
?minute_to_expire: Integer?,
|
|
41
|
+
?time_in_force: String
|
|
42
|
+
) -> untyped
|
|
43
|
+
|
|
44
|
+
def cancel_child_order: (
|
|
45
|
+
?product_code: String,
|
|
46
|
+
?child_order_id: String?,
|
|
47
|
+
?child_order_acceptance_id: String?
|
|
48
|
+
) -> untyped
|
|
49
|
+
|
|
50
|
+
def send_parent_order: (
|
|
51
|
+
?order_method: String?,
|
|
52
|
+
?minute_to_expire: Integer?,
|
|
53
|
+
?time_in_force: String,
|
|
54
|
+
?parameters: Array[Hash[Symbol, untyped]] | Hash[Symbol, untyped]
|
|
55
|
+
) -> untyped
|
|
56
|
+
|
|
57
|
+
def cancel_parent_order: (
|
|
58
|
+
?product_code: String,
|
|
59
|
+
?parent_order_id: String?,
|
|
60
|
+
?parent_order_acceptance_id: String?
|
|
61
|
+
) -> untyped
|
|
62
|
+
|
|
63
|
+
def cancel_all_child_orders: (?product_code: String) -> untyped
|
|
64
|
+
|
|
65
|
+
def child_orders: (
|
|
66
|
+
?product_code: String,
|
|
67
|
+
?count: Integer?,
|
|
68
|
+
?before: Integer?,
|
|
69
|
+
?after: Integer?,
|
|
70
|
+
?child_order_state: String?,
|
|
71
|
+
?parent_order_id: String?
|
|
72
|
+
) -> untyped
|
|
73
|
+
|
|
74
|
+
def parent_orders: (
|
|
75
|
+
?product_code: String,
|
|
76
|
+
?count: Integer?,
|
|
77
|
+
?before: Integer?,
|
|
78
|
+
?after: Integer?,
|
|
79
|
+
?parent_order_state: String?
|
|
80
|
+
) -> untyped
|
|
81
|
+
|
|
82
|
+
def parent_order: (?parent_order_id: String?, ?parent_order_acceptance_id: String?) -> untyped
|
|
83
|
+
|
|
84
|
+
def executions: (
|
|
85
|
+
?product_code: String,
|
|
86
|
+
?count: Integer?,
|
|
87
|
+
?before: Integer?,
|
|
88
|
+
?after: Integer?,
|
|
89
|
+
?child_order_id: String?,
|
|
90
|
+
?child_order_acceptance_id: String?
|
|
91
|
+
) -> untyped
|
|
92
|
+
|
|
93
|
+
def balance_history: (?currency_code: String?, ?count: Integer?, ?before: Integer?, ?after: Integer?) -> untyped
|
|
94
|
+
|
|
95
|
+
def positions: (?product_code: String) -> untyped
|
|
96
|
+
|
|
97
|
+
def trading_commission: (?product_code: String) -> untyped
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Bitflyer
|
|
2
|
+
module HTTP
|
|
3
|
+
module Public
|
|
4
|
+
class Client
|
|
5
|
+
@connection: Connection
|
|
6
|
+
|
|
7
|
+
def initialize: () -> void
|
|
8
|
+
|
|
9
|
+
def health: () -> untyped
|
|
10
|
+
|
|
11
|
+
def markets: () -> untyped
|
|
12
|
+
|
|
13
|
+
def board: (?product_code: String) -> untyped
|
|
14
|
+
|
|
15
|
+
def ticker: (?product_code: String) -> untyped
|
|
16
|
+
|
|
17
|
+
def executions: (?product_code: String, ?count: Integer?, ?before: Integer?, ?after: Integer?) -> untyped
|
|
18
|
+
|
|
19
|
+
def chats: (?from_date: Time | String) -> untyped
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Bitflyer
|
|
2
|
+
module HTTP
|
|
3
|
+
BASE_URL: String
|
|
4
|
+
|
|
5
|
+
class Response < Struct[untyped]
|
|
6
|
+
attr_accessor body: untyped
|
|
7
|
+
|
|
8
|
+
def self.new: (untyped body) -> instance
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Connection
|
|
12
|
+
@key: String?
|
|
13
|
+
@secret: String?
|
|
14
|
+
@uri: URI::Generic
|
|
15
|
+
|
|
16
|
+
def initialize: (String? key, String? secret) -> void
|
|
17
|
+
|
|
18
|
+
def get: (String path, ?Hash[Symbol, untyped] params) -> Response
|
|
19
|
+
|
|
20
|
+
def post: (String path, ?Hash[Symbol, untyped] body) -> Response
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def default_headers: () -> Hash[String, String]
|
|
25
|
+
|
|
26
|
+
def sign_request: (Net::HTTPRequest request, String path, ?String? body) -> void
|
|
27
|
+
|
|
28
|
+
def execute: (Net::HTTPRequest request) -> untyped
|
|
29
|
+
|
|
30
|
+
def parse_body: (String body) -> untyped
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
module Bitflyer
|
|
2
|
+
module Realtime
|
|
3
|
+
PUBLIC_EVENT_NAMES: Array[String]
|
|
4
|
+
MARKETS: Array[String]
|
|
5
|
+
PUBLIC_CHANNEL_NAMES: Array[String]
|
|
6
|
+
PRIVATE_CHANNEL_NAMES: Array[String]
|
|
7
|
+
CHANNEL_NAMES: Array[String]
|
|
8
|
+
SOCKET_HOST: String
|
|
9
|
+
|
|
10
|
+
type message_callback = ^(untyped message) -> void
|
|
11
|
+
|
|
12
|
+
type ready_callback = ^() -> void
|
|
13
|
+
|
|
14
|
+
type disconnected_callback = ^(untyped error) -> void
|
|
15
|
+
|
|
16
|
+
class Client
|
|
17
|
+
extend Forwardable
|
|
18
|
+
|
|
19
|
+
attr_accessor websocket_client: WebSocketClient
|
|
20
|
+
attr_accessor ping_interval: Integer?
|
|
21
|
+
attr_accessor ping_timeout: Integer?
|
|
22
|
+
attr_accessor last_ping_at: Integer?
|
|
23
|
+
attr_accessor last_pong_at: Integer?
|
|
24
|
+
|
|
25
|
+
def initialize: (?String? key, ?String? secret) -> void
|
|
26
|
+
|
|
27
|
+
def ready=: (ready_callback? callback) -> ready_callback?
|
|
28
|
+
|
|
29
|
+
def disconnected=: (disconnected_callback? callback) -> disconnected_callback?
|
|
30
|
+
|
|
31
|
+
def board_snapshot_btc_jpy=: (message_callback callback) -> message_callback
|
|
32
|
+
|
|
33
|
+
def board_snapshot_xrp_jpy=: (message_callback callback) -> message_callback
|
|
34
|
+
|
|
35
|
+
def board_snapshot_eth_jpy=: (message_callback callback) -> message_callback
|
|
36
|
+
|
|
37
|
+
def board_snapshot_xlm_jpy=: (message_callback callback) -> message_callback
|
|
38
|
+
|
|
39
|
+
def board_snapshot_mona_jpy=: (message_callback callback) -> message_callback
|
|
40
|
+
|
|
41
|
+
def board_snapshot_eth_btc=: (message_callback callback) -> message_callback
|
|
42
|
+
|
|
43
|
+
def board_snapshot_bch_btc=: (message_callback callback) -> message_callback
|
|
44
|
+
|
|
45
|
+
def board_snapshot_fx_btc_jpy=: (message_callback callback) -> message_callback
|
|
46
|
+
|
|
47
|
+
def board_snapshot_btcjpy_mat1wk=: (message_callback callback) -> message_callback
|
|
48
|
+
|
|
49
|
+
def board_snapshot_btcjpy_mat2wk=: (message_callback callback) -> message_callback
|
|
50
|
+
|
|
51
|
+
def board_snapshot_btcjpy_mat3m=: (message_callback callback) -> message_callback
|
|
52
|
+
|
|
53
|
+
def board_btc_jpy=: (message_callback callback) -> message_callback
|
|
54
|
+
|
|
55
|
+
def board_xrp_jpy=: (message_callback callback) -> message_callback
|
|
56
|
+
|
|
57
|
+
def board_eth_jpy=: (message_callback callback) -> message_callback
|
|
58
|
+
|
|
59
|
+
def board_xlm_jpy=: (message_callback callback) -> message_callback
|
|
60
|
+
|
|
61
|
+
def board_mona_jpy=: (message_callback callback) -> message_callback
|
|
62
|
+
|
|
63
|
+
def board_eth_btc=: (message_callback callback) -> message_callback
|
|
64
|
+
|
|
65
|
+
def board_bch_btc=: (message_callback callback) -> message_callback
|
|
66
|
+
|
|
67
|
+
def board_fx_btc_jpy=: (message_callback callback) -> message_callback
|
|
68
|
+
|
|
69
|
+
def board_btcjpy_mat1wk=: (message_callback callback) -> message_callback
|
|
70
|
+
|
|
71
|
+
def board_btcjpy_mat2wk=: (message_callback callback) -> message_callback
|
|
72
|
+
|
|
73
|
+
def board_btcjpy_mat3m=: (message_callback callback) -> message_callback
|
|
74
|
+
|
|
75
|
+
def ticker_btc_jpy=: (message_callback callback) -> message_callback
|
|
76
|
+
|
|
77
|
+
def ticker_xrp_jpy=: (message_callback callback) -> message_callback
|
|
78
|
+
|
|
79
|
+
def ticker_eth_jpy=: (message_callback callback) -> message_callback
|
|
80
|
+
|
|
81
|
+
def ticker_xlm_jpy=: (message_callback callback) -> message_callback
|
|
82
|
+
|
|
83
|
+
def ticker_mona_jpy=: (message_callback callback) -> message_callback
|
|
84
|
+
|
|
85
|
+
def ticker_eth_btc=: (message_callback callback) -> message_callback
|
|
86
|
+
|
|
87
|
+
def ticker_bch_btc=: (message_callback callback) -> message_callback
|
|
88
|
+
|
|
89
|
+
def ticker_fx_btc_jpy=: (message_callback callback) -> message_callback
|
|
90
|
+
|
|
91
|
+
def ticker_btcjpy_mat1wk=: (message_callback callback) -> message_callback
|
|
92
|
+
|
|
93
|
+
def ticker_btcjpy_mat2wk=: (message_callback callback) -> message_callback
|
|
94
|
+
|
|
95
|
+
def ticker_btcjpy_mat3m=: (message_callback callback) -> message_callback
|
|
96
|
+
|
|
97
|
+
def executions_btc_jpy=: (message_callback callback) -> message_callback
|
|
98
|
+
|
|
99
|
+
def executions_xrp_jpy=: (message_callback callback) -> message_callback
|
|
100
|
+
|
|
101
|
+
def executions_eth_jpy=: (message_callback callback) -> message_callback
|
|
102
|
+
|
|
103
|
+
def executions_xlm_jpy=: (message_callback callback) -> message_callback
|
|
104
|
+
|
|
105
|
+
def executions_mona_jpy=: (message_callback callback) -> message_callback
|
|
106
|
+
|
|
107
|
+
def executions_eth_btc=: (message_callback callback) -> message_callback
|
|
108
|
+
|
|
109
|
+
def executions_bch_btc=: (message_callback callback) -> message_callback
|
|
110
|
+
|
|
111
|
+
def executions_fx_btc_jpy=: (message_callback callback) -> message_callback
|
|
112
|
+
|
|
113
|
+
def executions_btcjpy_mat1wk=: (message_callback callback) -> message_callback
|
|
114
|
+
|
|
115
|
+
def executions_btcjpy_mat2wk=: (message_callback callback) -> message_callback
|
|
116
|
+
|
|
117
|
+
def executions_btcjpy_mat3m=: (message_callback callback) -> message_callback
|
|
118
|
+
|
|
119
|
+
def child_order_events=: (message_callback callback) -> message_callback
|
|
120
|
+
|
|
121
|
+
def parent_order_events=: (message_callback callback) -> message_callback
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Bitflyer
|
|
2
|
+
module Realtime
|
|
3
|
+
class WebSocketClient
|
|
4
|
+
@host: String
|
|
5
|
+
@key: String?
|
|
6
|
+
@secret: String?
|
|
7
|
+
@debug: bool
|
|
8
|
+
|
|
9
|
+
attr_accessor websocket_client: WebSocket::Client::Simple::Client
|
|
10
|
+
attr_accessor channel_names: Array[Symbol]
|
|
11
|
+
attr_accessor channel_callbacks: Hash[Symbol, message_callback]
|
|
12
|
+
attr_accessor ping_interval: Integer?
|
|
13
|
+
attr_accessor ping_timeout: Integer?
|
|
14
|
+
attr_accessor last_ping_at: Integer?
|
|
15
|
+
attr_accessor last_pong_at: Integer?
|
|
16
|
+
attr_accessor ready: ready_callback?
|
|
17
|
+
attr_accessor disconnected: disconnected_callback?
|
|
18
|
+
|
|
19
|
+
def initialize: (host: String, key: String?, secret: String?, ?debug: bool) -> void
|
|
20
|
+
|
|
21
|
+
def subscribe: (channel_name: Symbol) { (untyped message) -> void } -> void
|
|
22
|
+
|
|
23
|
+
def connect: () -> void
|
|
24
|
+
|
|
25
|
+
def start_monitoring: () -> Thread
|
|
26
|
+
|
|
27
|
+
def send_ping: () -> void
|
|
28
|
+
|
|
29
|
+
def wait_pong: () -> void
|
|
30
|
+
|
|
31
|
+
def reconnect: () -> void
|
|
32
|
+
|
|
33
|
+
def handle_error: (error: untyped) -> void
|
|
34
|
+
|
|
35
|
+
def handle_message: (payload: untyped) -> void
|
|
36
|
+
|
|
37
|
+
def handle_close: (error: untyped) -> void
|
|
38
|
+
|
|
39
|
+
def setup_by_response: (json: String) -> void
|
|
40
|
+
|
|
41
|
+
def authenticate: () -> void
|
|
42
|
+
|
|
43
|
+
def authenticated: (json: String) -> void
|
|
44
|
+
|
|
45
|
+
def subscribe_channels: () -> void
|
|
46
|
+
|
|
47
|
+
def receive_pong: () -> void
|
|
48
|
+
|
|
49
|
+
def disconnect: () -> void
|
|
50
|
+
|
|
51
|
+
def emit_message: (json: String) -> void
|
|
52
|
+
|
|
53
|
+
def debug_log: (untyped message) -> void
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/sig/bitflyer.rbs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module Bitflyer
|
|
2
|
+
VERSION: String
|
|
3
|
+
|
|
4
|
+
def self?.realtime_client: (?String? key, ?String? secret) -> Realtime::Client
|
|
5
|
+
|
|
6
|
+
def self?.http_public_client: () -> HTTP::Public::Client
|
|
7
|
+
|
|
8
|
+
def self?.http_private_client: (String key, String secret) -> HTTP::Private::Client
|
|
9
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Minimal signatures for websocket-client-simple, which ships no RBS.
|
|
2
|
+
module WebSocket
|
|
3
|
+
module Client
|
|
4
|
+
module Simple
|
|
5
|
+
def self.connect: (String url, ?Hash[Symbol, untyped] options) -> Client
|
|
6
|
+
|
|
7
|
+
class Client
|
|
8
|
+
def on: (Symbol event) { (untyped) -> void } -> void
|
|
9
|
+
|
|
10
|
+
def send: (String data, ?Hash[Symbol, untyped] options) -> void
|
|
11
|
+
|
|
12
|
+
def open?: () -> bool
|
|
13
|
+
|
|
14
|
+
def close: () -> void
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bitflyer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuji Ueki
|
|
@@ -9,20 +9,6 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: faraday
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - ">="
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.0'
|
|
19
|
-
type: :runtime
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - ">="
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.0'
|
|
26
12
|
- !ruby/object:Gem::Dependency
|
|
27
13
|
name: websocket-client-simple
|
|
28
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -129,6 +115,7 @@ files:
|
|
|
129
115
|
- LICENSE.txt
|
|
130
116
|
- README.md
|
|
131
117
|
- Rakefile
|
|
118
|
+
- Steepfile
|
|
132
119
|
- bitflyer.gemspec
|
|
133
120
|
- lib/bitflyer.rb
|
|
134
121
|
- lib/bitflyer/http.rb
|
|
@@ -138,6 +125,13 @@ files:
|
|
|
138
125
|
- lib/bitflyer/realtime/client.rb
|
|
139
126
|
- lib/bitflyer/realtime/websocket.rb
|
|
140
127
|
- lib/bitflyer/version.rb
|
|
128
|
+
- sig-private/websocket-client-simple.rbs
|
|
129
|
+
- sig/bitflyer.rbs
|
|
130
|
+
- sig/bitflyer/http.rbs
|
|
131
|
+
- sig/bitflyer/http/private.rbs
|
|
132
|
+
- sig/bitflyer/http/public.rbs
|
|
133
|
+
- sig/bitflyer/realtime/client.rbs
|
|
134
|
+
- sig/bitflyer/realtime/websocket.rbs
|
|
141
135
|
homepage: https://github.com/bitflyer-tools/bitflyer
|
|
142
136
|
licenses:
|
|
143
137
|
- MIT
|