bitstamp_client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/README.md +11 -1
- data/lib/bitstamp_client.rb +3 -0
- data/lib/bitstamp_client/client.rb +1 -0
- data/lib/bitstamp_client/models/exchange_rate.rb +16 -0
- data/lib/bitstamp_client/requests/exchange_rate_request.rb +13 -0
- data/lib/bitstamp_client/responses/exchange_rate_response.rb +22 -0
- data/lib/bitstamp_client/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd9e417a1496a625f66757c0f3be12cb0a9baae
|
4
|
+
data.tar.gz: 0d67f87996b744d1e082d4793b0ceb4397a2e6aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6dd9300980b8d2000aa16c4304755a15f58a16429145a312a9300b22175a7efb7650becb4852fea348773396765ee43541278edac78034511f4f1dbaebc68e
|
7
|
+
data.tar.gz: f071d386e1b6faf6eaa189f23a32e0e74287c25c4eca3f38cab5bbc029a91eb94b3b76b46b4ef2084461a4dc70fc81aab0d151aeab6720e9e1855accdbfef474
|
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
|
+
## [0.2.0]
|
8
|
+
### Added
|
9
|
+
- Add functionality to grab exchange rates
|
10
|
+
|
7
11
|
## [0.1.0]
|
8
12
|
### Added
|
9
13
|
- Initial release. Pull order book
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,17 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
```ruby
|
26
|
+
client = BitstampClient.new
|
27
|
+
response = client.order_book("btcusd")
|
28
|
+
response.success? # true
|
29
|
+
order_book = response.order_book
|
30
|
+
order_book.timestamp # unix timestamp
|
31
|
+
order_book.bids # Array of Order instances
|
32
|
+
order_book.asks # Array of Order instances
|
33
|
+
```
|
34
|
+
|
35
|
+
For more, see the files in `spec/acceptance`.
|
26
36
|
|
27
37
|
## Development
|
28
38
|
|
data/lib/bitstamp_client.rb
CHANGED
@@ -3,11 +3,14 @@ require "typhoeus"
|
|
3
3
|
require "bitstamp_client/version"
|
4
4
|
require "bitstamp_client/client"
|
5
5
|
require "bitstamp_client/models/base_model"
|
6
|
+
require "bitstamp_client/models/exchange_rate"
|
6
7
|
require "bitstamp_client/models/order"
|
7
8
|
require "bitstamp_client/models/order_book"
|
8
9
|
require "bitstamp_client/requests/base_request"
|
10
|
+
require "bitstamp_client/requests/exchange_rate_request"
|
9
11
|
require "bitstamp_client/requests/order_book_request"
|
10
12
|
require "bitstamp_client/responses/base_response"
|
13
|
+
require "bitstamp_client/responses/exchange_rate_response"
|
11
14
|
require "bitstamp_client/responses/order_book_response"
|
12
15
|
|
13
16
|
module BitstampClient
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module BitstampClient
|
2
|
+
class ExchangeRate < BaseModel
|
3
|
+
|
4
|
+
attribute :base_currency, String
|
5
|
+
attribute :counter_currency, String
|
6
|
+
attribute :mid_rate, Float
|
7
|
+
attribute :buy, Float
|
8
|
+
attribute :sell, Float
|
9
|
+
attribute :timestamp, Integer
|
10
|
+
|
11
|
+
def currency_pair
|
12
|
+
[base_currency, counter_currency].join
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BitstampClient
|
2
|
+
class ExchangeRateResponse < BaseResponse
|
3
|
+
|
4
|
+
attribute(:exchange_rate, ExchangeRate, {
|
5
|
+
lazy: true,
|
6
|
+
default: :default_exchange_rate,
|
7
|
+
})
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def default_exchange_rate
|
12
|
+
json = JSON.parse(body)
|
13
|
+
ExchangeRate.new(
|
14
|
+
buy: json["ask"],
|
15
|
+
sell: json["bid"],
|
16
|
+
mid_rate: [json["ask"].to_f, json["bid"].to_f].sum / 2,
|
17
|
+
timestamp: json["timestamp"],
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
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: 0.2.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-
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_client_base
|
@@ -158,11 +158,14 @@ files:
|
|
158
158
|
- lib/bitstamp_client.rb
|
159
159
|
- lib/bitstamp_client/client.rb
|
160
160
|
- lib/bitstamp_client/models/base_model.rb
|
161
|
+
- lib/bitstamp_client/models/exchange_rate.rb
|
161
162
|
- lib/bitstamp_client/models/order.rb
|
162
163
|
- lib/bitstamp_client/models/order_book.rb
|
163
164
|
- lib/bitstamp_client/requests/base_request.rb
|
165
|
+
- lib/bitstamp_client/requests/exchange_rate_request.rb
|
164
166
|
- lib/bitstamp_client/requests/order_book_request.rb
|
165
167
|
- lib/bitstamp_client/responses/base_response.rb
|
168
|
+
- lib/bitstamp_client/responses/exchange_rate_response.rb
|
166
169
|
- lib/bitstamp_client/responses/order_book_response.rb
|
167
170
|
- lib/bitstamp_client/version.rb
|
168
171
|
homepage: https://github.com/imacchiato/bitstamp_client-ruby
|
@@ -186,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
189
|
version: '0'
|
187
190
|
requirements: []
|
188
191
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.6.
|
192
|
+
rubygems_version: 2.6.11
|
190
193
|
signing_key:
|
191
194
|
specification_version: 4
|
192
195
|
summary: Ruby wrapper for Bitstamp's API
|