quoinex 0.1.1 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 467b541c5bdf83957fe28d81eecdcbe34c42bfd8
4
- data.tar.gz: fbf694e099f0309e5f6d33f23b5ef53b752609cf
3
+ metadata.gz: e9dd8c4f97072452b97db4d7995e9a69f1041bcc
4
+ data.tar.gz: 6162b912992051d660ad6541bbe938cd3a6c935a
5
5
  SHA512:
6
- metadata.gz: 6c347a21fd320975600e16f219b1d45a8381988f0050a7c28ab106eb23e95e4c3c1eaa7b5336d2bd56c3bb52e98bf7c4999c3958e4534094c528a2870e1598b2
7
- data.tar.gz: 0de4cd3764a35ea9b4ad296de84e4055b353d6f46e113782b5370a072ba9c0c9650b1e2e2cccf9c2a428de36305264be8b5aa567255b819b9ec66ad220bfe40e
6
+ metadata.gz: 7978786f53bbecc879610a304f1ad22a6e882300339e017fc91c93fe61bb02cf222e545f495e5c549efcf30a38710f9cdc7dbc63dbf5197a7fe72308094e92da
7
+ data.tar.gz: 9689338f41e479ce5170bd7761e61bd431ecfd1d3c35943f0a503c456fa0c1e17c9ccc049123fdf3feb88a2371d5ddeda1d91083ae177f2137541416795417ba
data/.gitignore ADDED
@@ -0,0 +1,44 @@
1
+ # Parts of this file were adapted from
2
+ # GitHub’s collection of .gitignore file templates
3
+ # which are Copyright (c) 2016 GitHub, Inc.
4
+ # and released under the MIT License.
5
+ # For more details, visit the project page:
6
+ # https://github.com/github/gitignore
7
+
8
+ *.gem
9
+ *.rbc
10
+ /.config
11
+ /coverage/
12
+ /InstalledFiles
13
+ /pkg/
14
+ /spec/reports/
15
+ /spec/examples.txt
16
+ /test/tmp/
17
+ /test/version_tmp/
18
+ /tmp/
19
+
20
+ ## Specific to RubyMotion:
21
+ .dat*
22
+ .repl_history
23
+ build/
24
+
25
+ ## Documentation cache and generated files:
26
+ /.yardoc/
27
+ /_yardoc/
28
+ /doc/
29
+ /rdoc/
30
+
31
+ ## Environment normalization:
32
+ /.bundle/
33
+ /vendor/bundle
34
+ /lib/bundler/man/
35
+
36
+ # for a library or gem, you might want to ignore these files since the code is
37
+ # intended to run in multiple environments; otherwise, check them in:
38
+ Gemfile.lock
39
+ .ruby-version
40
+ .ruby-gemset
41
+
42
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
43
+ .rvmrc
44
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,9 @@
1
+ AllCops:
2
+ Include:
3
+ - Gemfile
4
+ - Guardfile
5
+ - Rakefile
6
+
7
+ Style/RegexpLiteral:
8
+ Exclude:
9
+ - Guardfile
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ language: ruby
3
+ sudo: required
4
+ dist: trusty
5
+ cache: bundler
6
+ rvm:
7
+ - 2
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --markup=markdown
2
+ lib/**/*.rb
3
+ -
4
+ README.md
5
+ CHANGELOG.md
6
+ LICENSE.txt
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+ This change log follows the conventions of
6
+ [keep a CHANGELOG](http://keepachangelog.com/).
7
+
8
+ ## [Unreleased]
9
+
10
+ [Unreleased]: https://github.com/heelhook/quoinex/compare/v0.0.1...HEAD
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in quoinex.gemspec.
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,23 @@
1
+ scope groups: [:doc, :lint, :unit]
2
+
3
+ group :doc do
4
+ guard :yard do
5
+ watch(%r{^lib/(.+)\.rb$})
6
+ end
7
+ end
8
+
9
+ group :lint do
10
+ guard :rubocop do
11
+ watch(%r{.+\.rb$})
12
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
13
+ end
14
+ end
15
+
16
+ group :unit do
17
+ guard :rspec, cmd: 'bundle exec rspec --color --format Fuubar' do
18
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
19
+ watch(%r{^lib/quoinex/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
20
+ watch(%r{^spec/.+_spec\.rb$})
21
+ watch('spec/spec_helper.rb') { 'spec' }
22
+ end
23
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Pablo Fernandez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # quoinex
2
+
3
+ [![Gem](https://img.shields.io/gem/v/quoinex.svg)](https://rubygems.org/gems/quoinex)
4
+ [![GitHub license](https://img.shields.io/github/license/heelhook/quoinex.svg)](./LICENSE.txt)
5
+ [![Gemnasium](https://img.shields.io/gemnasium/heelhook/quoinex.svg)](https://gemnasium.com/heelhook/quoinex)
6
+ [![Travis](https://img.shields.io/travis/heelhook/quoinex.svg)](https://travis-ci.org/heelhook/quoinex)
7
+ [![Codecov](https://img.shields.io/codecov/c/github/heelhook/quoinex.svg)](https://codecov.io/github/heelhook/quoinex)
8
+ [![Code Climate](https://img.shields.io/codeclimate/github/heelhook/quoinex.svg)](https://codeclimate.com/github/heelhook/quoinex)
9
+
10
+ > Built from [makenew/ruby-gem](https://github.com/makenew/ruby-gem).n
11
+ ## Description
12
+
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's [Gemfile][Bundler]
17
+
18
+ ```ruby
19
+ gem 'quoinex'
20
+ ```
21
+
22
+ and update your bundle with
23
+
24
+ ```
25
+ $ bundle
26
+ ```
27
+
28
+ Or install it yourself with
29
+
30
+ ```
31
+ $ gem install quoinex
32
+ ```
33
+
34
+ [Bundler]: http://bundler.io/
35
+
36
+ ## Usage
37
+
38
+ ```
39
+ client = Quoinex::API.new(passphrase: ..., key: ..., secret: ...)
40
+ ```
41
+
42
+ ### Fetching accounts
43
+
44
+ ```
45
+ client.accounts
46
+ ```
47
+
48
+ ### Listing orders
49
+
50
+ ```
51
+ client.orders
52
+ ```
53
+
54
+ ### Order detils
55
+
56
+ ```
57
+ client.order(id)
58
+ ```
59
+
60
+ ### Placing an order
61
+
62
+ ```
63
+ client.create_order(
64
+ side: :buy,
65
+ size: 1.0,
66
+ price: 10000,
67
+ product_id: 'BTCEUR',
68
+ type: 'limit',
69
+ )
70
+ ```
71
+
72
+ ### Cancel an order
73
+
74
+ ```
75
+ client.cancel_order(id)
76
+ ```
77
+
78
+ ## Documentation
79
+
80
+ - [YARD documentation][RubyDoc] is hosted by RubyDoc.info.
81
+ - [Interactive documentation][Omniref] is hosted by Omniref.
82
+
83
+ [RubyDoc]: http://www.rubydoc.info/gems/quoinex
84
+ [Omniref]: https://www.omniref.com/ruby/gems/quoinex
85
+
86
+ ## Development and Testing
87
+
88
+ ### Source Code
89
+
90
+ The [quoinex source] is hosted on GitHub.
91
+ Clone the project with
92
+
93
+ ```
94
+ $ git clone https://github.com/heelhook/quoinex.git
95
+ ```
96
+
97
+ [quoinex source]: https://github.com/heelhook/quoinex
98
+
99
+ ### Requirements
100
+
101
+ You will need [Ruby] with [Bundler].
102
+
103
+ Install the development dependencies with
104
+
105
+ ```
106
+ $ bundle
107
+ ```
108
+
109
+ [Bundler]: http://bundler.io/
110
+ [Ruby]: https://www.ruby-lang.org/
111
+
112
+ ### Rake
113
+
114
+ Run `$ rake -T` to see all Rake tasks.
115
+
116
+ ```
117
+ rake build # Build quoinex-2.0.1.gem into the pkg directory
118
+ rake bump:current[tag] # Show current gem version
119
+ rake bump:major[tag] # Bump major part of gem version
120
+ rake bump:minor[tag] # Bump minor part of gem version
121
+ rake bump:patch[tag] # Bump patch part of gem version
122
+ rake bump:pre[tag] # Bump pre part of gem version
123
+ rake bump:set # Sets the version number using the VERSION environment variable
124
+ rake clean # Remove any temporary products
125
+ rake clobber # Remove any generated files
126
+ rake install # Build and install quoinex-2.0.1.gem into system gems
127
+ rake install:local # Build and install quoinex-2.0.1.gem into system gems without network access
128
+ rake release[remote] # Create tag v2.0.1 and build and push quoinex-2.0.1.gem to Rubygems
129
+ rake rubocop # Run RuboCop
130
+ rake rubocop:auto_correct # Auto-correct RuboCop offenses
131
+ rake spec # Run RSpec code examples
132
+ rake test # Run test suite
133
+ rake yard # Generate YARD Documentation
134
+ ```
135
+
136
+ ### Guard
137
+
138
+ Guard tasks have been separated into the following groups:
139
+ `doc`, `lint`, and `unit`.
140
+ By default, `$ guard` will generate documentation, lint, and run unit tests.
141
+
142
+ ## Contributing
143
+
144
+ Please submit and comment on bug reports and feature requests.
145
+
146
+ To submit a patch:
147
+
148
+ 1. Fork it (https://github.com/heelhook/quoinex/fork).
149
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
150
+ 3. Make changes. Write and run tests.
151
+ 4. Commit your changes (`git commit -am 'Add some feature'`).
152
+ 5. Push to the branch (`git push origin my-new-feature`).
153
+ 6. Create a new Pull Request.
154
+
155
+ ## License
156
+
157
+ This Ruby gem is licensed under the MIT license.
158
+
159
+ ## Warranty
160
+
161
+ This software is provided "as is" and without any express or
162
+ implied warranties, including, without limitation, the implied
163
+ warranties of merchantibility and fitness for a particular
164
+ purpose.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'bump/tasks'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+ require 'rubocop/rake_task'
5
+ require 'yard'
6
+
7
+ task default: [:test, :yard]
8
+
9
+ desc 'Run test suite'
10
+ task test: [:rubocop, :spec]
11
+
12
+ RSpec::Core::RakeTask.new
13
+
14
+ RuboCop::RakeTask.new do |t|
15
+ t.formatters = ['progress']
16
+ end
17
+
18
+ YARD::Rake::YardocTask.new
data/lib/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: ../.rubocop.yml
data/lib/quoinex.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'quoinex/version'
2
+ require 'quoinex/quoinex'
3
+ require 'quoinex/exceptions'
@@ -0,0 +1,4 @@
1
+ module Quoinex
2
+ class CreateOrderException < RuntimeError; end
3
+ class CancelOrderException < RuntimeError; end
4
+ end
@@ -0,0 +1,132 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+ require 'base64'
4
+ require 'byebug'
5
+ require 'jwt'
6
+
7
+ module Quoinex
8
+ class API
9
+ attr_reader :key,
10
+ :secret,
11
+ :url
12
+
13
+ def initialize(key:, secret:, url: 'https://api.quoine.com/')
14
+ @key = key
15
+ @secret = secret
16
+ @url = url
17
+ end
18
+
19
+ def balances
20
+ get('/accounts/balance')
21
+ end
22
+
23
+ def order(id)
24
+ get("/orders/#{id}")
25
+ end
26
+
27
+ def orders
28
+ get('/orders')
29
+ end
30
+
31
+ def cancel_order(id)
32
+ status = put("/orders/#{id}/cancel")
33
+ return status
34
+
35
+ if status['responseStatus'] && status['responseStatus']['errorCode']
36
+ error = status['responseStatus']['message']
37
+ error ||= status['responseStatus']
38
+ raise Quoinex::CancelOrderException.new(error)
39
+ end
40
+
41
+ status
42
+ rescue => e
43
+ raise Quoinex::CancelOrderException.new(e.message)
44
+ end
45
+
46
+ def create_order(side:, size:, price:, product_id:)
47
+ opts = {
48
+ order_type: :limit,
49
+ product_id: product_id,
50
+ side: side,
51
+ quantity: size.to_f.to_s,
52
+ price: price.to_f.to_s,
53
+ }
54
+ order = post('/orders', opts)
55
+
56
+ if !order['id']
57
+ error ||= order
58
+ raise Quoinex::CreateOrderException.new(error)
59
+ end
60
+
61
+ order
62
+ rescue => e
63
+ raise Quoinex::CreateOrderException.new(e.message)
64
+ end
65
+
66
+ # private
67
+
68
+ def signature(path)
69
+ auth_payload = {
70
+ path: path,
71
+ nonce: DateTime.now.strftime('%Q'),
72
+ token_id: @key
73
+ }
74
+
75
+ JWT.encode(auth_payload, @secret, 'HS256')
76
+ end
77
+
78
+ def get(path, opts = {})
79
+ uri = URI.parse("#{@url}#{path}")
80
+ uri.query = URI.encode_www_form(opts[:params]) if opts[:params]
81
+
82
+ response = RestClient.get(uri.to_s, auth_headers(uri.request_uri))
83
+
84
+ if !opts[:skip_json]
85
+ JSON.parse(response.body)
86
+ else
87
+ response.body
88
+ end
89
+ end
90
+
91
+ def post(path, payload, opts = {})
92
+ data = JSON.unparse(payload)
93
+ response = RestClient.post("#{@url}#{path}", data, auth_headers(path))
94
+
95
+ if !opts[:skip_json]
96
+ JSON.parse(response.body)
97
+ else
98
+ response.body
99
+ end
100
+ end
101
+
102
+ def put(path, opts = {})
103
+ response = RestClient.put("#{@url}#{path}", auth_headers(path))
104
+
105
+ if !opts[:skip_json]
106
+ JSON.parse(response.body)
107
+ else
108
+ response.body
109
+ end
110
+ end
111
+
112
+ def delete(path, opts = {})
113
+ response = RestClient.delete("#{@url}#{path}", auth_headers(path))
114
+
115
+ if !opts[:skip_json]
116
+ JSON.parse(response.body)
117
+ else
118
+ response.body
119
+ end
120
+ end
121
+
122
+ def auth_headers(path)
123
+ sign = signature(path)
124
+
125
+ {
126
+ 'Content-Type' => 'application/json',
127
+ 'X-Quoine-API-Version' => 2,
128
+ 'X-Quoine-Auth' => sign,
129
+ }
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # Primary module for this gem.
3
+ module Quoinex
4
+ # Current Quoinex version.
5
+ VERSION = '0.1.4'.freeze
6
+ end
data/quoinex.gemspec ADDED
@@ -0,0 +1,45 @@
1
+ lib = File.expand_path(File.join('..', 'lib'), __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'quoinex/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'quoinex'
7
+ spec.version = Quoinex::VERSION
8
+ spec.authors = ['Pablo Fernandez']
9
+ spec.email = ['pfer@me.com']
10
+ spec.description = ''
11
+ spec.summary = ''
12
+ spec.homepage = 'https://github.com/heelhook/quoinex'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(features|spec|test)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.required_ruby_version = '>= 2.0.1'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.6'
23
+ spec.add_development_dependency 'rake', '~> 11.2'
24
+ spec.add_development_dependency 'bump', '~> 0.5'
25
+
26
+ spec.add_development_dependency 'guard', '~> 2.11'
27
+ spec.add_development_dependency 'guard-yard', '~> 2.1'
28
+ spec.add_development_dependency 'guard-rubocop', '~> 1.2'
29
+ spec.add_development_dependency 'guard-rspec', '~> 4.5'
30
+
31
+ spec.add_development_dependency 'rubocop', '~> 0.52.1'
32
+ spec.add_development_dependency 'rspec', '~> 3.1'
33
+ spec.add_development_dependency 'simplecov', '~> 0.9'
34
+ spec.add_development_dependency 'codecov', '~> 0.1'
35
+ spec.add_development_dependency 'fuubar', '~> 2.0'
36
+
37
+ spec.add_development_dependency 'yard', '~> 0.9.5'
38
+ spec.add_development_dependency 'redcarpet', '~> 3.2'
39
+ spec.add_development_dependency 'github-markup', '~> 1.3'
40
+
41
+ spec.add_development_dependency 'byebug', '~> 9.1'
42
+
43
+ spec.add_dependency 'rest-client', '~> 2'
44
+ spec.add_dependency 'jwt', '~> 2.1'
45
+ end
data/spec/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from: ../.rubocop.yml
2
+
3
+ Style/StringLiterals:
4
+ Enabled: false
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Quoinex::API do
4
+ subject(:ruby_gem) { Quoinex::API.new }
5
+
6
+ describe ".new" do
7
+ it "makes a new instance" do
8
+ expect(ruby_gem).to be_a Quoinex::API
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start
4
+
5
+ if ENV['CI'] == 'true'
6
+ require 'codecov'
7
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
8
+ else
9
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
10
+ end
11
+
12
+ require 'quoinex'
13
+
14
+ RSpec.configure do |c|
15
+ c.expect_with(:rspec) { |e| e.syntax = :expect }
16
+ c.before(:each) do
17
+ allow(FileUtils).to receive(:remove_entry_secure).with(anything)
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quoinex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Fernandez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -268,7 +268,27 @@ email:
268
268
  executables: []
269
269
  extensions: []
270
270
  extra_rdoc_files: []
271
- files: []
271
+ files:
272
+ - ".gitignore"
273
+ - ".rspec"
274
+ - ".rubocop.yml"
275
+ - ".travis.yml"
276
+ - ".yardopts"
277
+ - CHANGELOG.md
278
+ - Gemfile
279
+ - Guardfile
280
+ - LICENSE.txt
281
+ - README.md
282
+ - Rakefile
283
+ - lib/.rubocop.yml
284
+ - lib/quoinex.rb
285
+ - lib/quoinex/exceptions.rb
286
+ - lib/quoinex/quoinex.rb
287
+ - lib/quoinex/version.rb
288
+ - quoinex.gemspec
289
+ - spec/.rubocop.yml
290
+ - spec/ruby_gem_spec.rb
291
+ - spec/spec_helper.rb
272
292
  homepage: https://github.com/heelhook/quoinex
273
293
  licenses:
274
294
  - MIT
@@ -293,4 +313,7 @@ rubygems_version: 2.6.14
293
313
  signing_key:
294
314
  specification_version: 4
295
315
  summary: ''
296
- test_files: []
316
+ test_files:
317
+ - spec/.rubocop.yml
318
+ - spec/ruby_gem_spec.rb
319
+ - spec/spec_helper.rb