bitflyer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57c2f2187e13ad6c30dbd328ecb74b854b557c44
4
+ data.tar.gz: c8e9384069f8d3639dfdd73b15b4abb0a744d27f
5
+ SHA512:
6
+ metadata.gz: 43e93eb1b75538995808dca61707bb0398909527ab9a0b4c933b1577e8236d00a0409280d9d92773d5aa3cc15b0b7d971411b39c907537f0bfb6a0f88b7ecda1
7
+ data.tar.gz: dbd9979f1b377c48e4ec369c3ad75a7c8cf5ec2087009ad6fecdfd00f14c24a9547c965a456cd776308faa9358378c7063fb5124bdec647eaa3f0a7284aebfe9
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at unhappychoice@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bitflyer.gemspec
4
+ gemspec
@@ -0,0 +1,99 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bitflyer (0.0.1)
5
+ faraday (~> 0.12.2)
6
+ faraday_middleware (~> 0.11.0.1)
7
+ pubnub (~> 4.0.22)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ celluloid (0.17.3)
13
+ celluloid-essentials
14
+ celluloid-extras
15
+ celluloid-fsm
16
+ celluloid-pool
17
+ celluloid-supervision
18
+ timers (>= 4.1.1)
19
+ celluloid-essentials (0.20.5)
20
+ timers (>= 4.1.1)
21
+ celluloid-extras (0.20.5)
22
+ timers (>= 4.1.1)
23
+ celluloid-fsm (0.20.5)
24
+ timers (>= 4.1.1)
25
+ celluloid-pool (0.20.5)
26
+ timers (>= 4.1.1)
27
+ celluloid-supervision (0.20.6)
28
+ timers (>= 4.1.1)
29
+ concurrent-ruby (1.0.5)
30
+ diff-lcs (1.3)
31
+ dry-configurable (0.7.0)
32
+ concurrent-ruby (~> 1.0)
33
+ dry-container (0.6.0)
34
+ concurrent-ruby (~> 1.0)
35
+ dry-configurable (~> 0.1, >= 0.1.3)
36
+ dry-core (0.3.1)
37
+ concurrent-ruby (~> 1.0)
38
+ dry-equalizer (0.2.0)
39
+ dry-logic (0.4.1)
40
+ dry-container (~> 0.2, >= 0.2.6)
41
+ dry-core (~> 0.2)
42
+ dry-equalizer (~> 0.2)
43
+ dry-types (0.11.0)
44
+ concurrent-ruby (~> 1.0)
45
+ dry-configurable (~> 0.1)
46
+ dry-container (~> 0.3)
47
+ dry-core (~> 0.2, >= 0.2.1)
48
+ dry-equalizer (~> 0.2)
49
+ dry-logic (~> 0.4, >= 0.4.0)
50
+ inflecto (~> 0.0.0, >= 0.0.2)
51
+ dry-validation (0.11.0)
52
+ concurrent-ruby (~> 1.0)
53
+ dry-configurable (~> 0.1, >= 0.1.3)
54
+ dry-core (~> 0.2, >= 0.2.1)
55
+ dry-equalizer (~> 0.2)
56
+ dry-logic (~> 0.4, >= 0.4.0)
57
+ dry-types (~> 0.11.0)
58
+ faraday (0.12.2)
59
+ multipart-post (>= 1.2, < 3)
60
+ faraday_middleware (0.11.0.1)
61
+ faraday (>= 0.7.4, < 1.0)
62
+ hitimes (1.2.5)
63
+ httpclient (2.8.3)
64
+ inflecto (0.0.2)
65
+ json (2.1.0)
66
+ multipart-post (2.0.0)
67
+ pubnub (4.0.22)
68
+ celluloid (~> 0.17)
69
+ dry-validation (~> 0.10)
70
+ httpclient (~> 2.8)
71
+ json (>= 1.8, < 3)
72
+ rake (10.5.0)
73
+ rspec (3.6.0)
74
+ rspec-core (~> 3.6.0)
75
+ rspec-expectations (~> 3.6.0)
76
+ rspec-mocks (~> 3.6.0)
77
+ rspec-core (3.6.0)
78
+ rspec-support (~> 3.6.0)
79
+ rspec-expectations (3.6.0)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.6.0)
82
+ rspec-mocks (3.6.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.6.0)
85
+ rspec-support (3.6.0)
86
+ timers (4.1.2)
87
+ hitimes
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ bitflyer!
94
+ bundler (~> 1.12)
95
+ rake (~> 10.0)
96
+ rspec (~> 3.0)
97
+
98
+ BUNDLED WITH
99
+ 1.12.5
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Yuji Ueki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # bitflyer
2
+
3
+ bitflyer is a wrapper interface of [Bitflyer lightning API](https://lightning.bitflyer.jp/docs)
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ gem install bitflyer
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### HTTP API
14
+
15
+ TBD
16
+
17
+ ### Realtime API
18
+
19
+ API format is like `{event_name}_{product_code}`.
20
+
21
+ #### `event_name`
22
+ - board_snapshot
23
+ - board
24
+ - ticker
25
+ - executions
26
+
27
+ #### `product_code`
28
+ - btc_jpy
29
+ - fx_btc_jpy
30
+ - eth_btc
31
+
32
+ #### Example
33
+
34
+ ```ruby
35
+ client = Bitflyer::Realtime.new
36
+ client.ticker_btc_jpy = ->(json){ p json } # will print json object
37
+ client.executions_btc_jpy = ->(json){ p json }
38
+ # ...
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/unhappychoice/bitflyer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
49
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bitflyer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'bitflyer'
8
+ spec.version = Bitflyer::VERSION
9
+ spec.authors = ['Yuji Ueki']
10
+ spec.email = ['unhappychoice@gmail.com']
11
+ spec.summary = %q{Bitflyer API wrapper}
12
+ spec.description = %q{Bitflyer API wrapper}
13
+ spec.homepage = 'https://github.com/unhappychoice/bitflyer'
14
+ spec.license = 'MIT'
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'faraday', '~> 0.12.2'
21
+ spec.add_dependency 'faraday_middleware', '~> 0.11.0.1'
22
+ spec.add_dependency 'pubnub', '~> 4.0.22'
23
+ spec.add_development_dependency 'bundler', '~> 1.12'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ end
@@ -0,0 +1,19 @@
1
+ require 'bitflyer/version'
2
+ require 'bitflyer/http'
3
+ require 'bitflyer/realtime'
4
+
5
+ module Bitflyer
6
+ def realtime_client
7
+ Bitflyer::Realtime::Client.new
8
+ end
9
+
10
+ def http_public_client
11
+ Bitflyer::HTTP::Public::Client.new
12
+ end
13
+
14
+ def http_private_client
15
+ Bitflyer::HTTP::Private::Client.new
16
+ end
17
+
18
+ module_function :realtime_client, :http_public_client, :http_private_client
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'bitflyer'
2
+ require 'bitflyer/http/public'
3
+ require 'bitflyer/http/private'
4
+ require 'faraday'
5
+ require 'faraday_middleware'
6
+
7
+ module Bitflyer
8
+ module HTTP
9
+ class Connection
10
+ extend Forwardable
11
+
12
+ def_delegators :@connection, :get, :post
13
+
14
+ def initialize
15
+ @connection = Faraday::Connection.new(:url => 'https://api.bitflyer.jp/v1') do |f|
16
+ f.request :json
17
+ f.response :json
18
+ f.adapter Faraday.default_adapter
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ module Bitflyer
2
+ module HTTP
3
+ module Private
4
+ class Client
5
+ def initialize
6
+ @connection = Connection.new
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ module Bitflyer
2
+ module HTTP
3
+ module Public
4
+ class Client
5
+ def initialize
6
+ @connection = Connection.new
7
+ end
8
+
9
+ def health
10
+ @connection.get('gethealth').body
11
+ end
12
+
13
+ def markets
14
+ @connection.get('markets').body
15
+ end
16
+
17
+ def board(product_code = 'BTC_JPY')
18
+ @connection.get('board', { product_code: product_code }).body
19
+ end
20
+
21
+ def ticker(product_code = 'BTC_JPY')
22
+ @connection.get('ticker', { product_code: product_code }).body
23
+ end
24
+
25
+ def executions(product_code = 'BTC_JPY')
26
+ @connection.get('executions', { product_code: product_code }).body
27
+ end
28
+
29
+ def chats(from_date = (Time.now - 5 * 24 * 60 * 60))
30
+ @connection.get('getchats', { from_date: from_date }).body
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ require 'bitflyer'
2
+ require 'bitflyer/realtime/client'
3
+
4
+ module Bitflyer
5
+ module Realtime
6
+ end
7
+ end
@@ -0,0 +1,42 @@
1
+ require 'pubnub'
2
+
3
+ module Bitflyer
4
+ module Realtime
5
+ PUBNUB_SUBSCRIBE_KEY = 'sub-c-52a9ab50-291b-11e5-baaa-0619f8945a4f'.freeze
6
+ CHANNEL_NAMES = [
7
+ 'lightning_board_snapshot_BTC_JPY',
8
+ 'lightning_board_snapshot_FX_BTC_JPY',
9
+ 'lightning_board_snapshot_ETH_BTC',
10
+ 'lightning_board_BTC_JPY',
11
+ 'lightning_board_FX_BTC_JPY',
12
+ 'lightning_board_ETH_BTC',
13
+ 'lightning_ticker_BTC_JPY',
14
+ 'lightning_ticker_FX_BTC_JPY',
15
+ 'lightning_ticker_ETH_BTC',
16
+ 'lightning_executions_BTC_JPY',
17
+ 'lightning_executions_FX_BTC_JPY',
18
+ 'lightning_executions_ETH_BTC'
19
+ ].freeze
20
+
21
+ class Client
22
+ attr_accessor *Realtime::CHANNEL_NAMES.map { |name| name.gsub('lightning_', '').downcase.to_sym }
23
+
24
+ def initialize
25
+ @pubnub = Pubnub.new(subscribe_key: Realtime::PUBNUB_SUBSCRIBE_KEY)
26
+
27
+ @callback = Pubnub::SubscribeCallback.new(
28
+ message: ->(envelope) {
29
+ channel_name = envelope.result[:data][:subscribed_channel].gsub('lightning_', '').downcase.to_sym
30
+ message = envelope.result[:data][:message]
31
+ send(channel_name).call(message) if send(channel_name)
32
+ },
33
+ presence: ->(envelope) {},
34
+ status: ->(envelope) {}
35
+ )
36
+
37
+ @pubnub.add_listener(callback: @callback)
38
+ @pubnub.subscribe(channels: Realtime::CHANNEL_NAMES)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module Bitflyer
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bitflyer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yuji Ueki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.12.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.11.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.11.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: pubnub
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.0.22
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.0.22
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: Bitflyer API wrapper
98
+ email:
99
+ - unhappychoice@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - CODE_OF_CONDUCT.md
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bitflyer.gemspec
111
+ - lib/bitflyer.rb
112
+ - lib/bitflyer/http.rb
113
+ - lib/bitflyer/http/private.rb
114
+ - lib/bitflyer/http/public.rb
115
+ - lib/bitflyer/realtime.rb
116
+ - lib/bitflyer/realtime/client.rb
117
+ - lib/bitflyer/version.rb
118
+ homepage: https://github.com/unhappychoice/bitflyer
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.5.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Bitflyer API wrapper
142
+ test_files: []