bitstamp_client 0.3.1 → 1.0.0

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
- SHA1:
3
- metadata.gz: fb60248b754280e2c8661c6418d01dc711b230d6
4
- data.tar.gz: 7062fb2d28080243a378a53324d97d13161e3428
2
+ SHA256:
3
+ metadata.gz: 284b6c7a1d6d71cf415e7ecaef262865e0ead1c22395d6bcdb5041b86e096aab
4
+ data.tar.gz: 0214c9d3d809a5401e48cdec9b9b4e1b8121fb72382dfdcc0ba10cde53a7bedb
5
5
  SHA512:
6
- metadata.gz: 279053193e95a28b0bccb74b9207c4ffcb4cd0fdaaffe5473a659dd79e04a0b382839872335c2803923b93702980f95fc68d50940f2fcca7df3c8b36dafc1c0b
7
- data.tar.gz: a48f05852b6428d202df59e3ee285180beb5637f4e6dc2af05eb66209b133e58898119fe281747ddc78933ee3c60325392ef95a83a2b905d76a64e193f2ef21e
6
+ metadata.gz: c9c859fd3c2d78225e8698269707bd7b301cd1f42f75e4928f339d1f55e8159dea59158f94a32aef0fc95b4d072bc33d344a6dd95d1b19b32ff1a81414fbbcf1
7
+ data.tar.gz: f22dd6da2654178191dc569c643fb7ef6bea9665a407ea962db8e6372f4df7e888de7de7d01b2c22d29ad5a20cc59d2a5cc7694e7203f13fd37ec513cd8f1e5c
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /doc/
7
7
  /pkg/
8
8
  /spec/reports/
9
+ /spec/config.yml
9
10
  /tmp/
10
11
 
11
12
  # rspec failure tracking
@@ -0,0 +1 @@
1
+ ruby-2.5.3
@@ -1,5 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.1
4
+ - 2.5.3
5
+ before_script:
6
+ - cp spec/config.yml{.sample,}
5
7
  before_install: gem install bundler -v 1.14.6
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [1.0.0] - 2019-01-04
8
+ ### Added
9
+ - Place market orders
10
+
7
11
  ## [0.3.1] - 2017-08-10
8
12
  ### Added
9
13
  - FactoryGirl factories
data/README.md CHANGED
@@ -36,9 +36,9 @@ For more, see the files in `spec/acceptance`.
36
36
 
37
37
  ## Development
38
38
 
39
- 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.
40
-
41
- 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).
39
+ - Setup `spec/config.yml` (see `spec/config.yml.sample`). Since Bitstamp does not have a test API, you'll need to put real credentials for the tests here. Best to create a subaccount that has a limited set of funds.
40
+ - Make changes
41
+ - `rspec spec` to run the specs
42
42
 
43
43
  ## Factories
44
44
 
@@ -46,7 +46,7 @@ You may include FactoryGirl factories in the gem in your tests to easily build m
46
46
 
47
47
  ## Contributing
48
48
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bitstamp_client. 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.
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bloom-solutions/bitstamp_client. 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.
50
50
 
51
51
 
52
52
  ## License
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["ramon.tayag@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Ruby wrapper for Bitstamp's API}
13
- spec.homepage = "https://github.com/imacchiato/bitstamp_client-ruby"
13
+ spec.homepage = "https://github.com/bloom-solutions/bitstamp_client-ruby"
14
14
  spec.license = "MIT"
15
15
 
16
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -29,6 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
+ spec.required_ruby_version = '>= 2.4'
33
+
32
34
  spec.add_dependency "api_client_base", "~> 1.0"
33
35
  spec.add_dependency "typhoeus", "~> 1.0"
34
36
 
@@ -4,14 +4,18 @@ require "bitstamp_client/version"
4
4
  require "bitstamp_client/client"
5
5
  require "bitstamp_client/models/base_model"
6
6
  require "bitstamp_client/models/exchange_rate"
7
+ require "bitstamp_client/models/market_order"
7
8
  require "bitstamp_client/models/order"
8
9
  require "bitstamp_client/models/order_book"
9
10
  require "bitstamp_client/requests/base_request"
10
11
  require "bitstamp_client/requests/exchange_rate_request"
11
12
  require "bitstamp_client/requests/order_book_request"
13
+ require "bitstamp_client/requests/place_market_order_request"
12
14
  require "bitstamp_client/responses/base_response"
13
15
  require "bitstamp_client/responses/exchange_rate_response"
14
16
  require "bitstamp_client/responses/order_book_response"
17
+ require "bitstamp_client/responses/place_market_order_response"
18
+ require "bitstamp_client/services/gen_signature"
15
19
 
16
20
  module BitstampClient
17
21
 
@@ -19,6 +23,9 @@ module BitstampClient
19
23
 
20
24
  with_configuration do
21
25
  has :host, classes: String, default: "https://www.bitstamp.net"
26
+ has :key, classes: [String, NilClass]
27
+ has :secret, classes: [String, NilClass]
28
+ has :customer_id, classes: [String, NilClass]
22
29
  end
23
30
 
24
31
  end
@@ -3,13 +3,17 @@ module BitstampClient
3
3
 
4
4
  include APIClientBase::Client.module(default_opts: :default_opts)
5
5
  attribute :host, String
6
+ attribute :key, String
7
+ attribute :secret, String
8
+ attribute :customer_id, String
6
9
  api_action :order_book, args: [:currency_pair]
7
10
  api_action :exchange_rate, args: [:currency_pair]
11
+ api_action :place_market_order
8
12
 
9
13
  private
10
14
 
11
15
  def default_opts
12
- { host: host }
16
+ { host: host, key: key, secret: secret, customer_id: customer_id }
13
17
  end
14
18
 
15
19
  end
@@ -0,0 +1,11 @@
1
+ module BitstampClient
2
+ class MarketOrder < BaseModel
3
+
4
+ attribute :id, String
5
+ attribute :datetime, DateTime
6
+ attribute :type, String
7
+ attribute :price, BigDecimal
8
+ attribute :amount, BigDecimal
9
+
10
+ end
11
+ end
@@ -2,6 +2,10 @@ module BitstampClient
2
2
  class BaseRequest
3
3
 
4
4
  include APIClientBase::Request.module
5
+ attribute :key, String
6
+ attribute :secret, String
7
+ attribute :nonce, String
8
+ attribute :customer_id, String
5
9
 
6
10
  private
7
11
 
@@ -0,0 +1,39 @@
1
+ module BitstampClient
2
+ class PlaceMarketOrderRequest < BaseRequest
3
+
4
+ attribute :trade_type, String
5
+ attribute :currency_pair, String
6
+ attribute :nonce, Integer
7
+ attribute :amount, String
8
+ attribute :signature, String, default: :default_signature
9
+
10
+ private
11
+
12
+ def path
13
+ "/api/v2/:trade_type/market/:currency_pair/"
14
+ end
15
+
16
+ def default_action
17
+ :post
18
+ end
19
+
20
+ def body
21
+ {
22
+ key: key,
23
+ signature: signature,
24
+ nonce: nonce,
25
+ amount: amount,
26
+ }
27
+ end
28
+
29
+ def headers
30
+ { 'Content-Type' => 'application/x-www-form-urlencoded' }
31
+ end
32
+
33
+ def default_signature
34
+ GenSignature.
35
+ (key: key, secret: secret, nonce: nonce, customer_id: customer_id)
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,31 @@
1
+ module BitstampClient
2
+ class PlaceMarketOrderResponse < BaseResponse
3
+
4
+ attribute(:order, BitstampClient::MarketOrder, {
5
+ lazy: true,
6
+ default: :default_order,
7
+ })
8
+ attribute :status, String, lazy: true, default: :default_status
9
+ attribute :reason, String, lazy: true, default: :default_reason
10
+ attribute :parsed_body, Hash, lazy: true, default: :default_parsed_body
11
+
12
+ private
13
+
14
+ def default_order
15
+ MarketOrder.new(parsed_body)
16
+ end
17
+
18
+ def default_status
19
+ parsed_body["status"]
20
+ end
21
+
22
+ def default_reason
23
+ parsed_body["reason"]
24
+ end
25
+
26
+ def default_parsed_body
27
+ JSON.parse(body)
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ module BitstampClient
2
+ class GenSignature
3
+
4
+ def self.call(key:, secret:, nonce:, customer_id:)
5
+ digest = OpenSSL::Digest.new('sha256')
6
+ data = nonce.to_s + customer_id + key
7
+ hex = OpenSSL::HMAC.hexdigest(digest, secret, data)
8
+ hex.upcase
9
+ end
10
+
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module BitstampClient
2
- VERSION = "0.3.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitstamp_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-10 00:00:00.000000000 Z
11
+ date: 2019-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client_base
@@ -159,6 +159,7 @@ extra_rdoc_files: []
159
159
  files:
160
160
  - ".gitignore"
161
161
  - ".rspec"
162
+ - ".ruby-version"
162
163
  - ".travis.yml"
163
164
  - CHANGELOG.md
164
165
  - CODE_OF_CONDUCT.md
@@ -174,16 +175,20 @@ files:
174
175
  - lib/bitstamp_client/factories.rb
175
176
  - lib/bitstamp_client/models/base_model.rb
176
177
  - lib/bitstamp_client/models/exchange_rate.rb
178
+ - lib/bitstamp_client/models/market_order.rb
177
179
  - lib/bitstamp_client/models/order.rb
178
180
  - lib/bitstamp_client/models/order_book.rb
179
181
  - lib/bitstamp_client/requests/base_request.rb
180
182
  - lib/bitstamp_client/requests/exchange_rate_request.rb
181
183
  - lib/bitstamp_client/requests/order_book_request.rb
184
+ - lib/bitstamp_client/requests/place_market_order_request.rb
182
185
  - lib/bitstamp_client/responses/base_response.rb
183
186
  - lib/bitstamp_client/responses/exchange_rate_response.rb
184
187
  - lib/bitstamp_client/responses/order_book_response.rb
188
+ - lib/bitstamp_client/responses/place_market_order_response.rb
189
+ - lib/bitstamp_client/services/gen_signature.rb
185
190
  - lib/bitstamp_client/version.rb
186
- homepage: https://github.com/imacchiato/bitstamp_client-ruby
191
+ homepage: https://github.com/bloom-solutions/bitstamp_client-ruby
187
192
  licenses:
188
193
  - MIT
189
194
  metadata:
@@ -196,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
201
  requirements:
197
202
  - - ">="
198
203
  - !ruby/object:Gem::Version
199
- version: '0'
204
+ version: '2.4'
200
205
  required_rubygems_version: !ruby/object:Gem::Requirement
201
206
  requirements:
202
207
  - - ">="
@@ -204,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
209
  version: '0'
205
210
  requirements: []
206
211
  rubyforge_project:
207
- rubygems_version: 2.6.8
212
+ rubygems_version: 2.7.8
208
213
  signing_key:
209
214
  specification_version: 4
210
215
  summary: Ruby wrapper for Bitstamp's API