bitstamp_client 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -1
- data/CHANGELOG.md +4 -0
- data/README.md +4 -4
- data/bitstamp_client.gemspec +3 -1
- data/lib/bitstamp_client.rb +7 -0
- data/lib/bitstamp_client/client.rb +5 -1
- data/lib/bitstamp_client/models/market_order.rb +11 -0
- data/lib/bitstamp_client/requests/base_request.rb +4 -0
- data/lib/bitstamp_client/requests/place_market_order_request.rb +39 -0
- data/lib/bitstamp_client/responses/place_market_order_response.rb +31 -0
- data/lib/bitstamp_client/services/gen_signature.rb +12 -0
- data/lib/bitstamp_client/version.rb +1 -1
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 284b6c7a1d6d71cf415e7ecaef262865e0ead1c22395d6bcdb5041b86e096aab
|
4
|
+
data.tar.gz: 0214c9d3d809a5401e48cdec9b9b4e1b8121fb72382dfdcc0ba10cde53a7bedb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9c859fd3c2d78225e8698269707bd7b301cd1f42f75e4928f339d1f55e8159dea59158f94a32aef0fc95b4d072bc33d344a6dd95d1b19b32ff1a81414fbbcf1
|
7
|
+
data.tar.gz: f22dd6da2654178191dc569c643fb7ef6bea9665a407ea962db8e6372f4df7e888de7de7d01b2c22d29ad5a20cc59d2a5cc7694e7203f13fd37ec513cd8f1e5c
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.5.3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
40
|
-
|
41
|
-
|
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/
|
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
|
data/bitstamp_client.gemspec
CHANGED
@@ -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/
|
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
|
|
data/lib/bitstamp_client.rb
CHANGED
@@ -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,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
|
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.
|
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:
|
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/
|
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: '
|
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.
|
212
|
+
rubygems_version: 2.7.8
|
208
213
|
signing_key:
|
209
214
|
specification_version: 4
|
210
215
|
summary: Ruby wrapper for Bitstamp's API
|