bitex 0.6.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bitex.rb +1 -1
- data/lib/bitex/api.rb +2 -0
- data/lib/bitex/market_data.rb +7 -0
- data/lib/bitex/version.rb +1 -1
- data/spec/market_spec.rb +34 -32
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80cac6737caca0072c5dbabd5cf2108af955715
|
4
|
+
data.tar.gz: 0b190989454c5d7ef169931e51143c9e45dd1692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc6b05dba9426cf40092f439247fa52d62b22e8692156406160d99a49a3f42e10ebe1c790c71cb31f76b74af57db2f9001d66b0be8594d69059dc7f8ee5a2b2
|
7
|
+
data.tar.gz: 81c42a6e20d19cd49deadf0d25df749f95b648dfc13f00a2cfc866c94e7b47bdab2bb7553d0ebf57504e229831655d80af8940eeb0b303588358cbd71a7908d9
|
data/lib/bitex.rb
CHANGED
@@ -18,7 +18,7 @@ module Bitex
|
|
18
18
|
mattr_accessor :debug
|
19
19
|
mattr_accessor :ssl_version
|
20
20
|
|
21
|
-
ORDER_BOOKS = { btc_usd: 1, btc_ars: 5, btc_pyg: 10, btc_clp: 11, btc_uyu: 12 }.freeze
|
21
|
+
ORDER_BOOKS = { btc_usd: 1, btc_ars: 5, bch_usd: 8, btc_pyg: 10, btc_clp: 11, btc_uyu: 12 }.freeze
|
22
22
|
class UnknownOrderBook < StandardError
|
23
23
|
end
|
24
24
|
end
|
data/lib/bitex/api.rb
CHANGED
@@ -37,6 +37,7 @@ module Bitex
|
|
37
37
|
end
|
38
38
|
fields += options.map do |k, v|
|
39
39
|
next unless v
|
40
|
+
|
40
41
|
Curl::PostField.content(k.to_s, v)
|
41
42
|
end.compact
|
42
43
|
curl.send("http_#{verb.downcase}", *fields)
|
@@ -61,6 +62,7 @@ module Bitex
|
|
61
62
|
|
62
63
|
def self.private(verb, path, options = {}, files = {})
|
63
64
|
raise StandardError, 'No api_key available to make private key calls' if Bitex.api_key.nil?
|
65
|
+
|
64
66
|
response = curl(verb, path, options.merge(api_key: Bitex.api_key), files)
|
65
67
|
JSON.parse(response.body)
|
66
68
|
end
|
data/lib/bitex/market_data.rb
CHANGED
data/lib/bitex/version.rb
CHANGED
data/spec/market_spec.rb
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Bitex::MarketData do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
%w(last_24_hours last_7_days last_30_days).each do |method|
|
29
|
-
it "gets aggregated data for #{method}" do
|
30
|
-
stub_get("/btc/market/#{method}", 'aggregated_data')
|
31
|
-
Bitex::BitcoinMarketData.send(method).should == [
|
32
|
-
[1403668800, 570.0, 574.0, 570.0, 574.0, 1.06771929, 571.0, 570.917848641659],
|
33
|
-
[1403683200, 560.0, 570.0, 560.0, 570.0, 1.14175147, 565.0, 565.753596095655],
|
34
|
-
[1403697600, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0],
|
35
|
-
[1403712000, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0]
|
4
|
+
{ btc: Bitex::BitcoinMarketData, bch: Bitex::BitcoinCashMarketData }.each do |crypto_currency, market|
|
5
|
+
it "gets the ticker" do
|
6
|
+
stub_get("/#{crypto_currency}/market/ticker", 'market_ticker')
|
7
|
+
market.ticker.should == {
|
8
|
+
last: 639.0, high: 659.0, low: 639.0, vwap: 647.195852839369,
|
9
|
+
volume: 4.80579022, bid: 637.0, ask: 638.5
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "gets the order book" do
|
14
|
+
stub_get("/#{crypto_currency}/market/order_book", 'order_book')
|
15
|
+
market.order_book.should == {
|
16
|
+
bids: [[639.21,1.95],[637.0,0.47],[630.0,1.58]],
|
17
|
+
asks: [[642.4,0.4],[643.3,0.95],[644.3,0.25]]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
it "gets the transactions" do
|
22
|
+
stub_get("/#{crypto_currency}/market/transactions", 'transactions')
|
23
|
+
market.transactions.should == [
|
24
|
+
[1404259180, 1272, 650.0, 0.5],
|
25
|
+
[1404259179, 1271, 639.0, 0.46948356]
|
36
26
|
]
|
37
27
|
end
|
28
|
+
|
29
|
+
%w(last_24_hours last_7_days last_30_days).each do |method|
|
30
|
+
it "gets aggregated data for #{method}" do
|
31
|
+
stub_get("/#{crypto_currency}/market/#{method}", 'aggregated_data')
|
32
|
+
market.send(method).should == [
|
33
|
+
[1403668800, 570.0, 574.0, 570.0, 574.0, 1.06771929, 571.0, 570.917848641659],
|
34
|
+
[1403683200, 560.0, 570.0, 560.0, 570.0, 1.14175147, 565.0, 565.753596095655],
|
35
|
+
[1403697600, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0],
|
36
|
+
[1403712000, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0]
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nubis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|