kucoin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +59 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +62 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +31 -0
  12. data/bin/setup +8 -0
  13. data/credentials.yml.example +7 -0
  14. data/kucoin.gemspec +34 -0
  15. data/lib/kucoin.rb +77 -0
  16. data/lib/kucoin/configuration.rb +24 -0
  17. data/lib/kucoin/constants.rb +34 -0
  18. data/lib/kucoin/errors.rb +11 -0
  19. data/lib/kucoin/extensions/hash.rb +27 -0
  20. data/lib/kucoin/extensions/string.rb +13 -0
  21. data/lib/kucoin/models/balance.rb +13 -0
  22. data/lib/kucoin/models/base.rb +26 -0
  23. data/lib/kucoin/models/coin.rb +20 -0
  24. data/lib/kucoin/models/coin_address.rb +17 -0
  25. data/lib/kucoin/models/deal.rb +20 -0
  26. data/lib/kucoin/models/ohlcv.rb +35 -0
  27. data/lib/kucoin/models/order_book.rb +53 -0
  28. data/lib/kucoin/models/ticker.rb +24 -0
  29. data/lib/kucoin/models/trade.rb +38 -0
  30. data/lib/kucoin/models/user.rb +31 -0
  31. data/lib/kucoin/rest/authentication.rb +38 -0
  32. data/lib/kucoin/rest/client.rb +99 -0
  33. data/lib/kucoin/rest/errors.rb +30 -0
  34. data/lib/kucoin/rest/private/balances.rb +34 -0
  35. data/lib/kucoin/rest/private/invitations.rb +24 -0
  36. data/lib/kucoin/rest/private/languages.rb +14 -0
  37. data/lib/kucoin/rest/private/trading.rb +113 -0
  38. data/lib/kucoin/rest/private/transfers.rb +25 -0
  39. data/lib/kucoin/rest/private/user.rb +15 -0
  40. data/lib/kucoin/rest/public/currencies.rb +13 -0
  41. data/lib/kucoin/rest/public/klines.rb +85 -0
  42. data/lib/kucoin/rest/public/languages.rb +13 -0
  43. data/lib/kucoin/rest/public/markets.rb +33 -0
  44. data/lib/kucoin/rest/public/orders.rb +39 -0
  45. data/lib/kucoin/rest/public/ticker.rb +14 -0
  46. data/lib/kucoin/rest/public/trades.rb +22 -0
  47. data/lib/kucoin/utilities/encoding.rb +15 -0
  48. data/lib/kucoin/utilities/parsing.rb +70 -0
  49. data/lib/kucoin/version.rb +3 -0
  50. metadata +218 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '06881a46d3828d1c9ab08cdba0362e3b4ba9468c0b60ca202147ba179ad19acb'
4
+ data.tar.gz: 4f8446da98f48191191156883dbbfccff95fbe69dc491090ebae2169b7cd4f46
5
+ SHA512:
6
+ metadata.gz: 39360039bfdccae95c1707c739fc046bea43bde9b636fb6c5b555a840d4215d326de8f650054130d5da3404ea55895ff6958fcce38e7a97e08da1611216f4ed4
7
+ data.tar.gz: 4628d521bac0895dbb9b4727875e64fda92ab0e7998eaf7b9e0406906012f0d1a341eeae62de18fecc487cc5ebffd16162c3aa4c821283bf8299c6e3b21e0b5e
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ .DS_Store
14
+
15
+ credentials.yml
16
+ .ruby-version
17
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -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 sebastian.johnsson@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
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in kucoin.gemspec
6
+ gemspec
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kucoin (0.1.0)
5
+ addressable (>= 2.5.2)
6
+ faraday (>= 0.13)
7
+ faraday_middleware (>= 0.12.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.5.2)
13
+ public_suffix (>= 2.0.2, < 4.0)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
16
+ diff-lcs (1.3)
17
+ faraday (0.14.0)
18
+ multipart-post (>= 1.2, < 3)
19
+ faraday_middleware (0.12.2)
20
+ faraday (>= 0.7.4, < 1.0)
21
+ hashdiff (0.3.7)
22
+ multipart-post (2.0.0)
23
+ public_suffix (3.0.2)
24
+ rake (10.5.0)
25
+ rdoc (6.0.1)
26
+ rspec (3.7.0)
27
+ rspec-core (~> 3.7.0)
28
+ rspec-expectations (~> 3.7.0)
29
+ rspec-mocks (~> 3.7.0)
30
+ rspec-core (3.7.1)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-expectations (3.7.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.7.0)
35
+ rspec-mocks (3.7.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.7.0)
38
+ rspec-support (3.7.1)
39
+ safe_yaml (1.0.4)
40
+ vcr (4.0.0)
41
+ webmock (3.3.0)
42
+ addressable (>= 2.3.6)
43
+ crack (>= 0.3.2)
44
+ hashdiff
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ bundler (~> 1.16)
51
+ kucoin!
52
+ rake (~> 10.0)
53
+ rdoc (~> 6.0)
54
+ rspec (~> 3.0)
55
+ vcr (~> 4.0)
56
+ webmock (~> 3.1)
57
+
58
+ BUNDLED WITH
59
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Sebastian
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,62 @@
1
+ # KuCoin REST Client in Ruby
2
+
3
+ This gem provides a REST client to interface with KuCoin's API. As of right now a Websocket service isn't provided by KuCoin and as such, all API calls are made over REST.
4
+
5
+ ## Getting started
6
+
7
+ First of all you'll need to get an account on KuCoin, [click here to get one](https://www.kucoin.com).
8
+
9
+ After setting up your account, head to "Account", locate the "API Keys" section and click on "Create".
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'kucoin'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install kucoin
26
+
27
+ ## Setup
28
+
29
+ ```ruby
30
+ Kucoin.configure do |config|
31
+ config.key = YOUR_API_KEY
32
+ config.secret = YOUR_API_SECRET
33
+ end
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ REST Client (see specs/source code for available methods/endpoints):
39
+
40
+ ```ruby
41
+ client = Kucoin::Rest::Client.new
42
+ client.ticker("HPB-ETH")
43
+ ```
44
+
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ 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).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kucoin. 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.
55
+
56
+ ## License
57
+
58
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
59
+
60
+ ## Code of Conduct
61
+
62
+ Everyone interacting in the Kucoin project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/kucoin/blob/master/CODE_OF_CONDUCT.md).
@@ -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,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kucoin"
5
+ require "yaml"
6
+
7
+ cfg_path = File.join(File.dirname(__FILE__), "../credentials.yml")
8
+
9
+ if ::File.exists?(cfg_path)
10
+ cfg = YAML.load_file(cfg_path).fetch("full_permissions", {})
11
+
12
+ Kucoin.configure do |config|
13
+ config.key = cfg["key"]
14
+ config.secret = cfg["secret"]
15
+
16
+ config.faraday = {
17
+ user_agent: "Kucoin Ruby",
18
+ verbose: true
19
+ }
20
+ end
21
+ end
22
+
23
+ # You can add fixtures and/or initialization code here to make experimenting
24
+ # with your gem easier. You can also use a different console, if you like.
25
+
26
+ # (If you use this, don't forget to add pry to your Gemfile!)
27
+ # require "pry"
28
+ # Pry.start
29
+
30
+ require "irb"
31
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ partial_permissions:
2
+ key: "PARTIAL_PERMISSIONS_KEY"
3
+ secret: "PARTIAL_PERMISSIONS_SECRET"
4
+
5
+ full_permissions:
6
+ key: "FULL_PERMISSIONS_KEY"
7
+ secret: "FULL_PERMISSIONS_SECRET"
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "kucoin/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kucoin"
8
+ spec.version = Kucoin::VERSION
9
+ spec.authors = ["Sebastian"]
10
+ spec.email = ["sebastian.johnsson@gmail.com"]
11
+
12
+ spec.summary = %q{KuCoin Ruby API Client}
13
+ spec.description = %q{KuCoin Ruby REST API Client}
14
+ spec.homepage = "https://github.com/SebastianJ/kucoin"
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_dependency "faraday", ">= 0.13"
25
+ spec.add_dependency "faraday_middleware", ">= 0.12.2"
26
+ spec.add_dependency "addressable", ">= 2.5.2"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ spec.add_development_dependency "rdoc", "~> 6.0"
32
+ spec.add_development_dependency "vcr", "~> 4.0"
33
+ spec.add_development_dependency "webmock", "~> 3.1"
34
+ end
@@ -0,0 +1,77 @@
1
+ # Rest API
2
+ require "faraday"
3
+ require "faraday_middleware"
4
+
5
+ # Shared
6
+ require "openssl"
7
+ require "base64"
8
+ require "addressable/uri"
9
+ require "json"
10
+ require "date"
11
+
12
+ require "kucoin/version"
13
+
14
+ require "kucoin/configuration"
15
+ require "kucoin/errors"
16
+ require "kucoin/constants"
17
+
18
+ require "kucoin/utilities/parsing"
19
+ require "kucoin/utilities/encoding"
20
+
21
+ require "kucoin/models/base"
22
+ require "kucoin/models/ticker"
23
+ require "kucoin/models/order_book"
24
+ require "kucoin/models/trade"
25
+ require "kucoin/models/ohlcv"
26
+ require "kucoin/models/coin"
27
+ require "kucoin/models/coin_address"
28
+ require "kucoin/models/balance"
29
+ require "kucoin/models/deal"
30
+ require "kucoin/models/user"
31
+
32
+ require "kucoin/rest/public/currencies"
33
+ require "kucoin/rest/public/languages"
34
+ require "kucoin/rest/public/ticker"
35
+ require "kucoin/rest/public/orders"
36
+ require "kucoin/rest/public/trades"
37
+ require "kucoin/rest/public/markets"
38
+ require "kucoin/rest/public/klines"
39
+
40
+ require "kucoin/rest/private/user"
41
+ require "kucoin/rest/private/languages"
42
+ require "kucoin/rest/private/invitations"
43
+ require "kucoin/rest/private/transfers"
44
+ require "kucoin/rest/private/balances"
45
+ require "kucoin/rest/private/trading"
46
+
47
+ require "kucoin/rest/errors"
48
+ require "kucoin/rest/authentication"
49
+ require "kucoin/rest/client"
50
+
51
+ if !String.instance_methods(false).include?(:underscore)
52
+ require "kucoin/extensions/string"
53
+ end
54
+
55
+ if !Hash.instance_methods(false).include?(:symbolize_keys)
56
+ require "kucoin/extensions/hash"
57
+ end
58
+
59
+ module Kucoin
60
+
61
+ class << self
62
+ attr_writer :configuration
63
+ end
64
+
65
+ def self.configuration
66
+ @configuration ||= ::Kucoin::Configuration.new
67
+ end
68
+
69
+ def self.reset
70
+ @configuration = ::Kucoin::Configuration.new
71
+ end
72
+
73
+ def self.configure
74
+ yield(configuration)
75
+ end
76
+
77
+ end
@@ -0,0 +1,24 @@
1
+ module Kucoin
2
+ class Configuration
3
+ attr_accessor :api_url, :api_version, :key, :secret, :faraday
4
+
5
+ def initialize
6
+ self.api_url = "https://api.kucoin.com"
7
+ self.api_version = 1
8
+
9
+ self.key = nil
10
+ self.secret = nil
11
+
12
+ self.faraday = {
13
+ adapter: :net_http,
14
+ user_agent: 'KuCoin Ruby',
15
+ verbose: false
16
+ }
17
+ end
18
+
19
+ def verbose_faraday?
20
+ self.faraday.fetch(:verbose, false)
21
+ end
22
+
23
+ end
24
+ end