kucoin_ruby 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +60 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/kucoin_ruby.gemspec +30 -0
- data/lib/kucoin_ruby/currency.rb +7 -0
- data/lib/kucoin_ruby/inviting.rb +15 -0
- data/lib/kucoin_ruby/language.rb +13 -0
- data/lib/kucoin_ruby/market.rb +61 -0
- data/lib/kucoin_ruby/net.rb +49 -0
- data/lib/kucoin_ruby/operations.rb +35 -0
- data/lib/kucoin_ruby/trading.rb +33 -0
- data/lib/kucoin_ruby/user.rb +7 -0
- data/lib/kucoin_ruby/util.rb +27 -0
- data/lib/kucoin_ruby/version.rb +3 -0
- data/lib/kucoin_ruby.rb +17 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba8140ccb8633dc2dff5dcd614711a9027835458
|
4
|
+
data.tar.gz: 6f235e978533519a0ce639291e0a63ba7dbb39a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 762756f1aa6c87695cc02a6522d7a5c5297422cc3b346c93862dffdb06ca59657ee3b78e221cc0f99149c5eb7b12c340355a60d11e54295d245085bc0ab8a981
|
7
|
+
data.tar.gz: f5117a46c123fd978380c47815fcd54685684287b2e0a18a1cfdf9e19cf1b1491678cac0d0e7c3a4a3ec3ea3ed68eef0d93cc766a1e3be5ee26ad6e728b0be2a
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at abelardogilm@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kucoin_ruby (0.1.2)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
httparty (0.15.6)
|
12
|
+
multi_xml (>= 0.5.2)
|
13
|
+
multi_xml (0.6.0)
|
14
|
+
openssl (2.0.6)
|
15
|
+
rake (10.5.0)
|
16
|
+
rspec (3.7.0)
|
17
|
+
rspec-core (~> 3.7.0)
|
18
|
+
rspec-expectations (~> 3.7.0)
|
19
|
+
rspec-mocks (~> 3.7.0)
|
20
|
+
rspec-core (3.7.0)
|
21
|
+
rspec-support (~> 3.7.0)
|
22
|
+
rspec-expectations (3.7.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.7.0)
|
25
|
+
rspec-mocks (3.7.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.7.0)
|
28
|
+
rspec-support (3.7.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.16)
|
35
|
+
kucoin_ruby!
|
36
|
+
openssl
|
37
|
+
rake (~> 10.0)
|
38
|
+
rspec
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 lalo
|
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,60 @@
|
|
1
|
+
<h1 align="center">KuCoin API Client</h1>
|
2
|
+
|
3
|
+
<p align="center">
|
4
|
+
A Ruby client for the [KuCoin](https://www.kucoin.com/) API.
|
5
|
+
</p>
|
6
|
+
|
7
|
+
## Overview
|
8
|
+
|
9
|
+
This Ruby Gem attempts to add a layer to communicate with [KuCoin API documentation](http://docs.kucoinapidocs.apiary.io/) making easy connect with it. 31 endpoits are implemented but some of them
|
10
|
+
are not working correctly yet
|
11
|
+
|
12
|
+
## Getting started
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
Add gem to your Gemfile
|
17
|
+
`gem 'kucoin_ruby'`
|
18
|
+
|
19
|
+
Define your KuCoin API credentials as ENV vars of your project:
|
20
|
+
|
21
|
+
```
|
22
|
+
KUCOIN_KEY=YOUR_KEY
|
23
|
+
KUCOIN_SECRET=YOUR_SECRET
|
24
|
+
```
|
25
|
+
|
26
|
+
### Usage
|
27
|
+
|
28
|
+
All Kucoin methods are class methods, just call it with expected parameters
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Kucoin::Currency.exanges
|
32
|
+
```
|
33
|
+
|
34
|
+
WIP
|
35
|
+
|
36
|
+
## Donations
|
37
|
+
|
38
|
+
ETH **0x033c3f91a009f55236cf1b74811d118870bc6ebe**
|
39
|
+
|
40
|
+
BTC **1AiVzBv3B1813wmfAJzFhHHLur2FzJaDyM**
|
41
|
+
|
42
|
+
LTC **LPz1pegDmdaSDWBaxBMEqV9Qn4vw2hLSN6**
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
47
|
+
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/abelardogilm/kucoin_ruby. 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.
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
57
|
+
|
58
|
+
## Code of Conduct
|
59
|
+
|
60
|
+
Everyone interacting in the KucoinRuby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/abelardogilm/kucoin_ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "kucoin_ruby"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/kucoin_ruby.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "kucoin_ruby/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kucoin_ruby"
|
8
|
+
spec.version = KucoinRuby::VERSION
|
9
|
+
spec.authors = ["lalo"]
|
10
|
+
spec.email = ["abelardogilm@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{KuCoin API Gem}
|
13
|
+
spec.description = %q{KuCoin Ruby API Gem}
|
14
|
+
spec.homepage = "https://github.com/abelardogilm/kucoin_ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "openssl"
|
28
|
+
|
29
|
+
spec.add_dependency "httparty"
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module KucoinRuby
|
2
|
+
module Inviting
|
3
|
+
def self.invitation_count
|
4
|
+
KucoinRuby::Net.signed_get('/v1/referrer/descendant/count')
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.promotion_reward
|
8
|
+
KucoinRuby::Net.signed_get('/v1/account/promotion/info')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.promotion_summary
|
12
|
+
KucoinRuby::Net.signed_get('/v1/account/promotion/sum')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module KucoinRuby
|
2
|
+
module Language
|
3
|
+
def self.lang_list
|
4
|
+
KucoinRuby::Net.get('/v1/open/lang-list')
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.change_lang(lang)
|
8
|
+
endpoint = '/v1/user/change-lang'
|
9
|
+
payload = {lang: lang}
|
10
|
+
KucoinRuby::Net.signed_post(endpoint, payload)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module KucoinRuby
|
2
|
+
module Market
|
3
|
+
def tick(symbol = nil)
|
4
|
+
endpoint = "/v1/open/tick"
|
5
|
+
endpoint += "?symbol=#{symbol}" if symbol
|
6
|
+
KucoinRuby::Net.get(endpoint)
|
7
|
+
end
|
8
|
+
|
9
|
+
def orders(symbol)
|
10
|
+
KucoinRuby::Net.get("/v1/open/orders?symbol=#{symbol}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def buy_orders(symbol, group, limit)
|
14
|
+
endpoint = "/v1/open/orders-buy?symbol=#{symbol}&group=#{group}&limit=#{limit}"
|
15
|
+
KucoinRuby::Net.get(endpoint)
|
16
|
+
end
|
17
|
+
|
18
|
+
def sell_orders(symbol, group, limit)
|
19
|
+
endpoint = "/v1/open/orders-sell?symbol=#{symbol}&group=#{group}&limit=#{limit}"
|
20
|
+
KucoinRuby::Net.get(endpoint)
|
21
|
+
end
|
22
|
+
|
23
|
+
def recent_deal_orders(symbol, limit, since)
|
24
|
+
endpoint = "/v1/open/deal-orders?symbol=#{symbol}&synce=#{synce}&limit=#{limit}"
|
25
|
+
KucoinRuby::Net.get(endpoint)
|
26
|
+
end
|
27
|
+
|
28
|
+
def trading_symbols
|
29
|
+
KucoinRuby::Net.get('/v1/market/open/symbols')
|
30
|
+
end
|
31
|
+
|
32
|
+
def trending_symbols
|
33
|
+
KucoinRuby::Net.get('/v1/market/open/coins-trending')
|
34
|
+
end
|
35
|
+
|
36
|
+
def kline_data(symbol, type, from, to, limit)
|
37
|
+
KucoinRuby::Net.get("/v1/open/kline?symbol=#{symbol}&type=#{type}&from=#{from}&to=#{to}&limit=#{limit}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def kline_config()
|
41
|
+
KucoinRuby::Net.get('/v1/open/chart/config')
|
42
|
+
end
|
43
|
+
|
44
|
+
def chart_symbol(symbol)
|
45
|
+
KucoinRuby::Net.get("/v1/open/chart/symbol?symbol=#{symbol}")
|
46
|
+
end
|
47
|
+
|
48
|
+
def history_kline_data(symbol, resolution, from, to)
|
49
|
+
endpoint = "/v1/open/chart/history?symbol=#{symbol}&resolution=#{resolution}&from=#{from}&to=#{to}"
|
50
|
+
KucoinRuby::Net.get(endpoint)
|
51
|
+
end
|
52
|
+
|
53
|
+
def coin_info(coin)
|
54
|
+
KucoinRuby::Net.get("/v1/market/open/coin-info?coin=#{coin}")
|
55
|
+
end
|
56
|
+
|
57
|
+
def coins
|
58
|
+
KucoinRuby::Net.get("/v1/market/open/coins")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "kucoin_ruby/version"
|
2
|
+
|
3
|
+
module KucoinRuby
|
4
|
+
class Net
|
5
|
+
API_HOST = 'https://api.kucoin.com'
|
6
|
+
|
7
|
+
def self.key
|
8
|
+
ENV['KUCOIN_KEY']
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.secret
|
12
|
+
ENV['KUCOIN_SECRET']
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.headers(nonce, signature)
|
16
|
+
{
|
17
|
+
'Content-Type': 'application/json',
|
18
|
+
'KC-API-KEY': key,
|
19
|
+
'KC-API-NONCE': nonce,
|
20
|
+
'KC-API-SIGNATURE': signature,
|
21
|
+
"Accept-Language": 'en_EN'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get(endpoint)
|
26
|
+
uri = "#{API_HOST}#{endpoint}"
|
27
|
+
HTTParty.get(uri)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.signed_get(endpoint, query_string = nil)
|
31
|
+
nonce, signature = KucoinRuby::Util.sign_message(endpoint, query_string)
|
32
|
+
uri = "#{API_HOST}#{endpoint}?#{query_string}"
|
33
|
+
HTTParty.get(
|
34
|
+
uri,
|
35
|
+
headers: headers(nonce, signature)
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.signed_post(endpoint, payload = nil)
|
40
|
+
nonce, signature = KucoinRuby::Util.sign_message(endpoint)
|
41
|
+
uri = "#{API_HOST}#{endpoint}"
|
42
|
+
HTTParty.post(
|
43
|
+
uri,
|
44
|
+
headers: headers(nonce, signature),
|
45
|
+
body: payload
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module KucoinRuby
|
2
|
+
module Operations
|
3
|
+
def self.get_coin_address(coin)
|
4
|
+
endpoint = "/v1/account/#{coin}/wallet/address"
|
5
|
+
KucoinRuby::Net.signed_get(endpoint)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.create_withdrawal(coin, amount, address)
|
9
|
+
endpoint = "/v1/account/#{coin}/withdraw/apply"
|
10
|
+
payload = {coin: coin, amount: amount, address: address}
|
11
|
+
KucoinRuby::Net.signed_post(endpoint, payload)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.cancel_withdrawal(coin, txOid)
|
15
|
+
endpoint = "/v1/account/#{coin}/withdraw/apply"
|
16
|
+
payload = {coin: coin, txOid: txOid}
|
17
|
+
KucoinRuby::Net.signed_post(endpoint, payload)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.wallet_records(coin, type, status, limit=nil, page=nil)
|
21
|
+
#TODO
|
22
|
+
endpoint = "/v1/account/#{coin}/wallet/records"
|
23
|
+
query_string = {limit: limit, page: page, status: status, type: type}
|
24
|
+
KucoinRuby::Net.signed_get(endpoint, query_string)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.coin_balance(coin)
|
28
|
+
KucoinRuby::Net.signed_get("/v1/account/#{coin}/balance")
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.balance
|
32
|
+
KucoinRuby::Net.signed_get("/v1/account/balance")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module KucoinRuby
|
2
|
+
module Trading
|
3
|
+
def create_order(symbol, type, price, amount)
|
4
|
+
endpoint = '/v1/order'
|
5
|
+
payload = {symbol: symbol, type: type, price: price, amount: amount}
|
6
|
+
KucoinRuby::Net.signed_post(endpoint, payload)
|
7
|
+
end
|
8
|
+
|
9
|
+
def active_orders(symbol = nil)
|
10
|
+
endpoint = '/v1/order/active'
|
11
|
+
query_string = {symbol: symbol}
|
12
|
+
KucoinRuby::Net.signed_get(endpoint, query_string)
|
13
|
+
end
|
14
|
+
|
15
|
+
def cancel_order(symbol, order_id, type)
|
16
|
+
endpoint = '/v1/cancel-order'
|
17
|
+
payload = {symbol: symbol, type: type, order_id: order_id}
|
18
|
+
KucoinRuby::Net.signed_post(endpoint, payload)
|
19
|
+
end
|
20
|
+
|
21
|
+
def dealt_orders(symbol, type, limit, page, since, before)
|
22
|
+
endpoint = '/v1/order/dealt'
|
23
|
+
query_string = {before: before, limit: limit, page: page, since: since, symbol: symbol, type: type}
|
24
|
+
KucoinRuby::Net.signed_get(endpoint, query_string)
|
25
|
+
end
|
26
|
+
|
27
|
+
def symbol_dealt_order(symbol, type, limit, page )
|
28
|
+
endpoint = '/v1/deal-orders'
|
29
|
+
query_string = {limit: limit, page: page, symbol: symbol, type: type}
|
30
|
+
KucoinRuby::Net.signed_get(endpoint, query_string)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module KucoinRuby
|
2
|
+
class Util
|
3
|
+
def self.nonce
|
4
|
+
(Time.now.to_f * 1000).to_i.to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.build_message(endpoint, nonce, queryString = '')
|
8
|
+
"#{endpoint}/#{nonce}/#{queryString.to_param}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.sign(string)
|
12
|
+
base = Base64.strict_encode64(string)
|
13
|
+
sign_hmac(base)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.sign_message(endpoint, queryString = '')
|
17
|
+
nc = nonce
|
18
|
+
[nc, sign(build_message(endpoint, nc, queryString.to_param))]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.sign_hmac(string)
|
24
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), KucoinRuby::NetConfig.secret, string)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/kucoin_ruby.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "kucoin_ruby/version"
|
2
|
+
require "kucoin_ruby/util"
|
3
|
+
require "kucoin_ruby/net"
|
4
|
+
require "kucoin_ruby/currency"
|
5
|
+
require "kucoin_ruby/language"
|
6
|
+
require "kucoin_ruby/user"
|
7
|
+
require "kucoin_ruby/inviting"
|
8
|
+
require "kucoin_ruby/operations"
|
9
|
+
require "kucoin_ruby/trading"
|
10
|
+
require "kucoin_ruby/market"
|
11
|
+
|
12
|
+
require "openssl"
|
13
|
+
require "httparty"
|
14
|
+
|
15
|
+
module KucoinRuby
|
16
|
+
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kucoin_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lalo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: openssl
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: KuCoin Ruby API Gem
|
84
|
+
email:
|
85
|
+
- abelardogilm@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- CODE_OF_CONDUCT.md
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- kucoin_ruby.gemspec
|
100
|
+
- lib/kucoin_ruby.rb
|
101
|
+
- lib/kucoin_ruby/currency.rb
|
102
|
+
- lib/kucoin_ruby/inviting.rb
|
103
|
+
- lib/kucoin_ruby/language.rb
|
104
|
+
- lib/kucoin_ruby/market.rb
|
105
|
+
- lib/kucoin_ruby/net.rb
|
106
|
+
- lib/kucoin_ruby/operations.rb
|
107
|
+
- lib/kucoin_ruby/trading.rb
|
108
|
+
- lib/kucoin_ruby/user.rb
|
109
|
+
- lib/kucoin_ruby/util.rb
|
110
|
+
- lib/kucoin_ruby/version.rb
|
111
|
+
homepage: https://github.com/abelardogilm/kucoin_ruby
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.6.12
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: KuCoin API Gem
|
135
|
+
test_files: []
|