coinrail 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +99 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/coinrail.gemspec +26 -0
- data/lib/coinrail.rb +20 -0
- data/lib/coinrail/http.rb +48 -0
- data/lib/coinrail/http/private.rb +141 -0
- data/lib/coinrail/http/public.rb +24 -0
- data/lib/coinrail/realtime.rb +7 -0
- data/lib/coinrail/realtime/client.rb +42 -0
- data/lib/coinrail/version.rb +3 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c1d6e7f55eb938256c2db85e90376b237434fa4
|
4
|
+
data.tar.gz: 034341019c46392cea46942b39c239dc83f67758
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2f76beaa27fde8e6c427b6012f14f522c343eb377c4872a1d62fe84d28d0e1cafbc6d82b5e035a394d732071f633dc9e2cab36e8b68b7dd8a89d58f5dd35237
|
7
|
+
data.tar.gz: 12b95d4b80bb4792475103ec07c225f5d64d8de0776efddbaf4ff8caaf45102be38517e2d51ea0dd224fac1be57bfac4fee0b44cc2c1034a92f3f5f55c7037c7
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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
data/Gemfile.lock
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bitflyer (0.1.2)
|
5
|
+
faraday (~> 0.12.2)
|
6
|
+
faraday_middleware (~> 0.12.0)
|
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.12.0)
|
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.23)
|
68
|
+
celluloid (~> 0.17)
|
69
|
+
dry-validation (~> 0.10)
|
70
|
+
httpclient (~> 2.8, >= 2.8.3)
|
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
|
data/LICENSE.txt
ADDED
@@ -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.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coinrail
|
2
|
+
coinrail is a wrapper interface of [CoinRail API](https://coinrail.co.kr/api/document)
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
```sh
|
7
|
+
gem install coinrail
|
8
|
+
```
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
See https://coinrail.co.kr/api/document for details.
|
13
|
+
|
14
|
+
### HTTP API
|
15
|
+
|
16
|
+
#### Example
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
public_client = CoinRail.http_public_client
|
20
|
+
p public_client.orderbook # will print orderbook snapshot
|
21
|
+
|
22
|
+
private_client = CoinRail.http_private_client('YOUR_API_KEY', 'YOUR_API_SECRET')
|
23
|
+
p private_client.pending # will print your pending orders
|
24
|
+
```
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mithrandir/coinrail. 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.
|
29
|
+
|
30
|
+
|
31
|
+
## License
|
32
|
+
|
33
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
34
|
+
|
data/Rakefile
ADDED
data/coinrail.gemspec
ADDED
@@ -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 'coinrail/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'coinrail'
|
8
|
+
spec.version = CoinRail::VERSION
|
9
|
+
spec.authors = ['Park Jiin']
|
10
|
+
spec.email = ['tisphie@gmail.com']
|
11
|
+
spec.summary = %q{CoinRail API wrapper}
|
12
|
+
spec.description = %q{CoinRail API wrapper}
|
13
|
+
spec.homepage = 'https://github.com/mithrandir/coinrail'
|
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.12.0'
|
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
|
data/lib/coinrail.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'coinrail/version'
|
2
|
+
require 'coinrail/http'
|
3
|
+
# CoinRail API doesn't support realtime API yet
|
4
|
+
#require 'coinrail/realtime'
|
5
|
+
|
6
|
+
module CoinRail
|
7
|
+
# def realtime_client
|
8
|
+
# Bitflyer::Realtime::Client.new
|
9
|
+
# end
|
10
|
+
|
11
|
+
def http_public_client
|
12
|
+
CoinRail::HTTP::Public::Client.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def http_private_client(key, secret)
|
16
|
+
CoinRail::HTTP::Private::Client.new(key, secret)
|
17
|
+
end
|
18
|
+
|
19
|
+
module_function :http_public_client, :http_private_client
|
20
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'coinrail'
|
2
|
+
require 'coinrail/http/public'
|
3
|
+
require 'coinrail/http/private'
|
4
|
+
require 'faraday'
|
5
|
+
require 'faraday_middleware'
|
6
|
+
require 'openssl'
|
7
|
+
require 'base64'
|
8
|
+
|
9
|
+
module CoinRail
|
10
|
+
module HTTP
|
11
|
+
class Connection
|
12
|
+
extend Forwardable
|
13
|
+
|
14
|
+
def_delegators :@connection, :get, :post
|
15
|
+
|
16
|
+
def initialize(key, secret)
|
17
|
+
@connection = Faraday::Connection.new(:url => 'https://api.coinrail.co.kr') 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
|
+
@key = key
|
30
|
+
@secret = secret
|
31
|
+
end
|
32
|
+
|
33
|
+
def call(env)
|
34
|
+
return @app.call(env) if @key.nil? || @secret.nil?
|
35
|
+
|
36
|
+
timestamp = Time.now.to_i.to_s
|
37
|
+
method = env[:method].to_s.upcase
|
38
|
+
path = env[:url].path + (env[:url].query ? '?' + env[:url].query : '')
|
39
|
+
body = env[:body] || ''
|
40
|
+
encoded_payload = Base64.strict_encode64(body)
|
41
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'), @secret, encoded_payload)
|
42
|
+
env[:request_headers]['X-COINRAIL-PAYLOAD'] = encoded_payload
|
43
|
+
env[:request_headers]['X-COINRAIL-SIGNATURE'] = signature
|
44
|
+
@app.call env
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module CoinRail
|
2
|
+
module HTTP
|
3
|
+
module Private
|
4
|
+
class Client
|
5
|
+
def initialize(key, secret)
|
6
|
+
@connection = Connection.new(key, secret)
|
7
|
+
@key = key
|
8
|
+
end
|
9
|
+
|
10
|
+
def balance
|
11
|
+
puts @key
|
12
|
+
body = {timestamp: (Time.now.to_i * 1000).to_s,
|
13
|
+
access_key: @key}
|
14
|
+
@connection.post('/balance', body.to_json).body
|
15
|
+
end
|
16
|
+
|
17
|
+
# def coin_ins
|
18
|
+
# @connection.get('/v1/me/getcoinins').body
|
19
|
+
# end
|
20
|
+
|
21
|
+
# def coin_outs
|
22
|
+
# @connection.get('/v1/me/getcoinouts').body
|
23
|
+
# end
|
24
|
+
|
25
|
+
# def bank_accounts
|
26
|
+
# @connection.get('/v1/me/getbankaccounts').body
|
27
|
+
# end
|
28
|
+
|
29
|
+
# def deposits
|
30
|
+
# @connection.get('/v1/me/getdeposits').body
|
31
|
+
# end
|
32
|
+
|
33
|
+
# def withdraw(currency_code: 'KRW', bank_account_id: nil, amount: nil, code: nil)
|
34
|
+
# body = {
|
35
|
+
# currency_code: currency_code,
|
36
|
+
# bank_account_id: bank_account_id,
|
37
|
+
# amount: amount,
|
38
|
+
# code: code
|
39
|
+
# }.delete_if { |_, v| v.nil? }
|
40
|
+
# @connection.post('/v1/me/withdraw', body).body
|
41
|
+
# end
|
42
|
+
|
43
|
+
# def withdrawals
|
44
|
+
# @connection.get('/v1/me/getwithdrawals').body
|
45
|
+
# end
|
46
|
+
|
47
|
+
# def send_child_order(product_code: 'BTC_JPY', child_order_type: nil, side: nil, price: nil, size: nil, minute_to_expire: nil, time_in_force: 'GTC')
|
48
|
+
# body = {
|
49
|
+
# product_code: product_code,
|
50
|
+
# child_order_type: child_order_type,
|
51
|
+
# side: side,
|
52
|
+
# price: price,
|
53
|
+
# size: size,
|
54
|
+
# minute_to_expire: minute_to_expire,
|
55
|
+
# time_in_force: time_in_force
|
56
|
+
# }.delete_if { |_, v| v.nil? }
|
57
|
+
# @connection.post('/v1/me/sendchildorder', body).body
|
58
|
+
# end
|
59
|
+
|
60
|
+
# def cancel_child_order(product_code: 'BTC_JPY', child_order_id: nil, child_order_acceptance_id: nil)
|
61
|
+
# body = {
|
62
|
+
# product_code: product_code,
|
63
|
+
# child_order_id: child_order_id,
|
64
|
+
# child_order_acceptance_id: child_order_acceptance_id
|
65
|
+
# }.delete_if { |_, v| v.nil? }
|
66
|
+
# @connection.post('/v1/me/cancelchildorder', body).body
|
67
|
+
# end
|
68
|
+
|
69
|
+
# def send_parent_order(order_method: nil, minute_to_expire: nil, time_in_force: 'GTC', parameters: {})
|
70
|
+
# body = {
|
71
|
+
# order_method: order_method,
|
72
|
+
# minute_to_expire: minute_to_expire,
|
73
|
+
# time_in_force: time_in_force,
|
74
|
+
# parameters: parameters
|
75
|
+
# }.delete_if { |_, v| v.nil? }
|
76
|
+
# @connection.post('/v1/me/sendparentorder', body).body
|
77
|
+
# end
|
78
|
+
|
79
|
+
# def cancel_parent_order(product_code: 'BTC_JPY', parent_order_id: nil, parent_order_acceptance_id: nil)
|
80
|
+
# body = {
|
81
|
+
# product_code: product_code,
|
82
|
+
# parent_order_id: parent_order_id,
|
83
|
+
# parent_order_acceptance_id: parent_order_acceptance_id
|
84
|
+
# }.delete_if { |_, v| v.nil? }
|
85
|
+
# @connection.post('/v1/me/cancelparentorder', body).body
|
86
|
+
# end
|
87
|
+
|
88
|
+
# def cancel_all_child_orders(product_code: 'BTC_JPY')
|
89
|
+
# @connection.post('/v1/me/cancelallchildorders', { product_code: product_code }).body
|
90
|
+
# end
|
91
|
+
|
92
|
+
# def child_orders(product_code: 'BTC_JPY', count: nil, before: nil, after: nil, child_order_state: nil, parent_order_id: nil)
|
93
|
+
# query = {
|
94
|
+
# product_code: product_code,
|
95
|
+
# count: count,
|
96
|
+
# before: before,
|
97
|
+
# after: after,
|
98
|
+
# child_order_state: child_order_state,
|
99
|
+
# parent_order_id: parent_order_id
|
100
|
+
# }.delete_if { |_, v| v.nil? }
|
101
|
+
# @connection.get('/v1/me/getchildorders', query).body
|
102
|
+
# end
|
103
|
+
|
104
|
+
# def parent_orders(product_code: 'BTC_JPY', count: nil, before: nil, after: nil, parent_order_state: nil)
|
105
|
+
# query = {
|
106
|
+
# product_code: product_code,
|
107
|
+
# count: count,
|
108
|
+
# before: before,
|
109
|
+
# after: after,
|
110
|
+
# parent_order_state: parent_order_state
|
111
|
+
# }.delete_if { |_, v| v.nil? }
|
112
|
+
# @connection.get('/v1/me/getparentorders', query).body
|
113
|
+
# end
|
114
|
+
|
115
|
+
# def parent_order(parent_order_id: nil, parent_order_acceptance_id: nil)
|
116
|
+
# query = {
|
117
|
+
# parent_order_id: parent_order_id,
|
118
|
+
# parent_order_acceptance_id: parent_order_acceptance_id
|
119
|
+
# }.delete_if { |_, v| v.nil? }
|
120
|
+
# @connection.get('/v1/me/getparentorder', query).body
|
121
|
+
# end
|
122
|
+
|
123
|
+
def trade_completed(currency: 'btc-krw', count: nil, offset: nil, timestamp: nil)
|
124
|
+
query = {
|
125
|
+
currency: currency,
|
126
|
+
count: count,
|
127
|
+
offset: offset,
|
128
|
+
timestamp: timestamp
|
129
|
+
}.delete_if { |_, v| v.nil? }
|
130
|
+
@connection.get('/trade/completed', query).body
|
131
|
+
end
|
132
|
+
|
133
|
+
alias_method :executions, :trade_completed
|
134
|
+
|
135
|
+
def trade_pending(currency: 'btc-krw')
|
136
|
+
@connection.get('/trade/pending', { currency: currency }).body
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CoinRail
|
2
|
+
module HTTP
|
3
|
+
module Public
|
4
|
+
class Client
|
5
|
+
def initialize
|
6
|
+
@connection = Connection.new(nil, nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
def orderbook(currency = 'btc-krw')
|
10
|
+
@connection.get('/public/orderbook', {currency: currency }).body
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :board, :orderbook
|
14
|
+
|
15
|
+
def last_transaction(currency = 'btc-krw')
|
16
|
+
@connection.get('/last/transaction',
|
17
|
+
{ currency: currency.to_lower }).body
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :executions, :last_transaction
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'pubnub'
|
2
|
+
|
3
|
+
module CoinRail
|
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
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coinrail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Park Jiin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-21 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.12.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.12.0
|
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: CoinRail API wrapper
|
98
|
+
email:
|
99
|
+
- tisphie@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
|
+
- coinrail.gemspec
|
111
|
+
- lib/coinrail.rb
|
112
|
+
- lib/coinrail/http.rb
|
113
|
+
- lib/coinrail/http/private.rb
|
114
|
+
- lib/coinrail/http/public.rb
|
115
|
+
- lib/coinrail/realtime.rb
|
116
|
+
- lib/coinrail/realtime/client.rb
|
117
|
+
- lib/coinrail/version.rb
|
118
|
+
homepage: https://github.com/mithrandir/coinrail
|
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.0.14.1
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: CoinRail API wrapper
|
142
|
+
test_files: []
|