cryptoexchange 0.18.3 → 0.19.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 +4 -4
- data/lib/cryptoexchange/client.rb +35 -29
- data/lib/cryptoexchange/error.rb +16 -0
- data/lib/cryptoexchange/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e40d1c225c7d444ca1828e21e6d4dc9ddce78958
|
4
|
+
data.tar.gz: 75a3b19e390fe87240537ada42c8750b2aa86194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 694037122d89b0ebf9c68302f60c29fc2e398e81ff07738bcee1fa669dec54f222e1d677b2ecd30cc2f7803cd9b8d1f02c7e491322a6477b98a293a93d52eeda
|
7
|
+
data.tar.gz: f1c4536088635c26156fe8b10fd270a5b1d5105e0bab434a14d2d02a242b7151b6c0ae2a564401376c56b9a1505b935e0af6e4ae649802e7cacf3b6031acffbf
|
@@ -5,41 +5,47 @@ module Cryptoexchange
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def pairs(exchange)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
begin
|
9
|
+
pairs_classname = "Cryptoexchange::Exchanges::#{StringHelper.camelize(exchange)}::Services::Pairs"
|
10
|
+
pairs_class = Object.const_get(pairs_classname)
|
11
|
+
pairs_object = pairs_class.new
|
12
|
+
pairs_object.fetch
|
13
|
+
rescue HTTP::ConnectionError => e
|
14
|
+
raise Cryptoexchange::HttpConnectionError, e
|
15
|
+
rescue HTTP::TimeoutError => e
|
16
|
+
raise Cryptoexchange::HttpTimeoutError, e
|
17
|
+
rescue JSON::ParserError => e
|
18
|
+
raise Cryptoexchange::JsonParseError, e
|
19
|
+
rescue TypeError => e
|
20
|
+
raise Cryptoexchange::TypeFormatError, e
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def ticker(market_pair)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
begin
|
26
|
+
exchange = market_pair.market
|
27
|
+
market_classname = "Cryptoexchange::Exchanges::#{StringHelper.camelize(exchange)}::Services::Market"
|
28
|
+
market_class = Object.const_get(market_classname)
|
29
|
+
market = market_class.new
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
if market_class.supports_individual_ticker_query?
|
32
|
+
market.fetch(market_pair)
|
33
|
+
else
|
34
|
+
tickers = market.fetch
|
35
|
+
tickers.find do |t|
|
36
|
+
t.base.casecmp(market_pair.base) == 0 &&
|
37
|
+
t.target.casecmp(market_pair.target) == 0
|
38
|
+
end
|
33
39
|
end
|
40
|
+
rescue HTTP::ConnectionError => e
|
41
|
+
raise Cryptoexchange::HttpConnectionError, e
|
42
|
+
rescue HTTP::TimeoutError => e
|
43
|
+
raise Cryptoexchange::HttpTimeoutError, e
|
44
|
+
rescue JSON::ParserError => e
|
45
|
+
raise Cryptoexchange::JsonParseError, e
|
46
|
+
rescue TypeError => e
|
47
|
+
raise Cryptoexchange::TypeFormatError, e
|
34
48
|
end
|
35
|
-
rescue HTTP::ConnectionError => e
|
36
|
-
return { error: "#{exchange}'s service has connection error", message: e.to_s }
|
37
|
-
rescue HTTP::TimeoutError => e
|
38
|
-
return { error: "#{exchange}'s service time out", message: e.to_s }
|
39
|
-
rescue JSON::ParserError => e
|
40
|
-
return { error: "#{exchange}'s service does not send JSON", message: e.to_s }
|
41
|
-
rescue TypeError => e
|
42
|
-
return { error: "#{exchange}'s service does not respond with right format", message: e.to_s }
|
43
49
|
end
|
44
50
|
|
45
51
|
def available_exchanges
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptoexchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TM Lee
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- cryptoexchange.gemspec
|
159
159
|
- lib/cryptoexchange.rb
|
160
160
|
- lib/cryptoexchange/client.rb
|
161
|
+
- lib/cryptoexchange/error.rb
|
161
162
|
- lib/cryptoexchange/exchanges/abucoins/market.rb
|
162
163
|
- lib/cryptoexchange/exchanges/abucoins/services/market.rb
|
163
164
|
- lib/cryptoexchange/exchanges/abucoins/services/order_book.rb
|