cryptoexchange 0.5.2 → 0.6.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
2
  SHA1:
3
- metadata.gz: 62e21ac1114453a0d2142de290427e10c71fc935
4
- data.tar.gz: ed76b62159b3f148729d82215e43a25030dfccaf
3
+ metadata.gz: 9a41f865eb28d874977c2fca50d3793699903573
4
+ data.tar.gz: d1c11a43c53feeb6db9f1e3cdcc91420d65eae7c
5
5
  SHA512:
6
- metadata.gz: df9d2780eea6f9d38834f2420c169477617fb682c4384fc1399430305c6b8da71572b9fe816c3c4ecebe7f94ad09233abe0523d183831e5ee48c4f0bd91a15db
7
- data.tar.gz: 5eb9253ac3265b7c101194a6b9e1e2d372c16126430d110fdab43e393ebdd15ac850432d92d13fe202bdab4a069151355a330c364da07bacc9b422bf4304370b
6
+ metadata.gz: 160cc7215c3cb9c7a92a9d92714f80272982d4c61577ed61cdcb0de8708e211b862fa6d1b10090e802429cbc3f124d476943eb3b8bfa7b95768cb7e26c23f890
7
+ data.tar.gz: 9f2f14134e5f43452a269ed55634c22a279bcd3f2783212ee842c1ea8148675c353afa390e683038d8405fdaf101113b9ed666d8a4e6397f5d383d85565cba56
data/README.md CHANGED
@@ -32,7 +32,7 @@ Or install it yourself as:
32
32
  | Huobi | | | | | |
33
33
  | Yunbi | Y | | | | Y |
34
34
  | BTC38 | | | | | |
35
- | CHBTC | | | | | |
35
+ | CHBTC | Y | | | | User-Defined|
36
36
  | Bitstamp | Y | | | | User-Defined|
37
37
  | Bittrex | Y | | | | Y |
38
38
  | GDAX | Y | | | | Y |
@@ -41,7 +41,7 @@ Or install it yourself as:
41
41
  | Kraken | Y | | | | Y |
42
42
  | Coincheck | Y | | | | User-Defined|
43
43
  | Bitflyer | Y | | | | Y |
44
- | Quoine | | | | | |
44
+ | Quoine | Y | | | | Y |
45
45
  | QuadrigaCX | | | | | |
46
46
  | Unocoin | | | | | |
47
47
  | Coinone | Y | | | | Y |
@@ -67,7 +67,7 @@ Or install it yourself as:
67
67
  | BTCChina | | | | | |
68
68
  | Coinmate | | | | | |
69
69
  | Itbit | | | | | |
70
- | Jubi | | | | | |
70
+ | Jubi | Y | | | | Y |
71
71
  | MercadoBitcoin | | | | | |
72
72
  | Viabtc | Y | | | | User-Defined|
73
73
 
@@ -0,0 +1,16 @@
1
+ :pairs:
2
+ - :base: ETH
3
+ :target: CNY
4
+ - :base: BTC
5
+ :target: CNY
6
+ - :base: QTUM
7
+ :target: CNY
8
+ - :base: ETC
9
+ :target: CNY
10
+ - :base: BTS
11
+ :target: CNY
12
+ - :base: LTC
13
+ :target: CNY
14
+ - :base: EOS
15
+ :target: CNY
16
+
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Chbtc
3
+ class Market
4
+ NAME = 'chbtc'
5
+ API_URL = 'http://api.chbtc.com/data/v1'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,41 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Chbtc
3
+ module Services
4
+ class Market < Cryptoexchange::Services::Market
5
+ class << self
6
+ def supports_individual_ticker_query?
7
+ true
8
+ end
9
+ end
10
+
11
+ def fetch(market_pair)
12
+ output = super(ticker_url(market_pair))
13
+ adapt(output, market_pair)
14
+ end
15
+
16
+ def ticker_url(market_pair)
17
+ base = market_pair.base.downcase
18
+ target = market_pair.target.downcase
19
+ "#{Cryptoexchange::Exchanges::Chbtc::Market::API_URL}/ticker?currency=#{base}_#{target}"
20
+ end
21
+
22
+ def adapt(output, market_pair)
23
+ ticker_data = output['ticker']
24
+ ticker = Cryptoexchange::Models::Ticker.new
25
+ ticker.base = market_pair.base
26
+ ticker.target = market_pair.target
27
+ ticker.market = Chbtc::Market::NAME
28
+ ticker.ask = NumericHelper.to_d(ticker_data['sell'])
29
+ ticker.bid = NumericHelper.to_d(ticker_data['buy'])
30
+ ticker.last = NumericHelper.to_d(ticker_data['last'])
31
+ ticker.high = NumericHelper.to_d(ticker_data['high'])
32
+ ticker.low = NumericHelper.to_d(ticker_data['low'])
33
+ ticker.volume = NumericHelper.to_d(ticker_data['vol'])
34
+ ticker.timestamp = output['date'].to_i
35
+ ticker.payload = output
36
+ ticker
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Chbtc
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+
6
+ def fetch
7
+ output = super
8
+ adapt(output)
9
+ end
10
+
11
+ def adapt(output)
12
+ market_pairs = []
13
+ output.each do |pair|
14
+ market_pairs << Cryptoexchange::Models::MarketPair.new(
15
+ base: pair[:base],
16
+ target: pair[:target],
17
+ market: Chbtc::Market::NAME
18
+ )
19
+ end
20
+ market_pairs
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Jubi
3
+ class Market
4
+ NAME = 'jubi'
5
+ API_URL = 'http://www.jubi.com/api/v1'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,51 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Jubi
3
+ module Services
4
+ class Market < Cryptoexchange::Services::Market
5
+ class << self
6
+ def supports_individual_ticker_query?
7
+ false
8
+ end
9
+ end
10
+
11
+ def fetch
12
+ output = super(self.ticker_url)
13
+ adapt_all(output)
14
+ end
15
+
16
+ def ticker_url
17
+ "#{Cryptoexchange::Exchanges::Jubi::Market::API_URL}/allticker"
18
+ end
19
+
20
+ def adapt_all(output)
21
+ default_target = 'CNY'
22
+ output.map do |base, ticker|
23
+ market_pair = Cryptoexchange::Models::MarketPair.new(
24
+ base: base,
25
+ target: default_target,
26
+ market: Jubi::Market::NAME
27
+ )
28
+
29
+ adapt(ticker, market_pair)
30
+ end
31
+ end
32
+
33
+ def adapt(output, market_pair)
34
+ ticker = Cryptoexchange::Models::Ticker.new
35
+ ticker.base = market_pair.base
36
+ ticker.target = market_pair.target
37
+ ticker.market = Jubi::Market::NAME
38
+ ticker.last = NumericHelper.to_d(output['last'])
39
+ ticker.bid = NumericHelper.to_d(output['buy'])
40
+ ticker.ask = NumericHelper.to_d(output['sell'])
41
+ ticker.high = NumericHelper.to_d(output['high'])
42
+ ticker.low = NumericHelper.to_d(output['low'])
43
+ ticker.volume = NumericHelper.to_d(output['vol'])
44
+ ticker.timestamp = DateTime.now.to_time.to_i
45
+ ticker.payload = output
46
+ ticker
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,25 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Jubi
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Jubi::Market::API_URL}/allticker"
6
+
7
+ def fetch
8
+ output = super
9
+ adapt(output)
10
+ end
11
+
12
+ def adapt(output)
13
+ default_target = 'CNY'
14
+ output.keys.map do |base|
15
+ Cryptoexchange::Models::MarketPair.new({
16
+ base: base,
17
+ target: default_target,
18
+ market: Jubi::Market::NAME
19
+ })
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -10,11 +10,11 @@ module Cryptoexchange
10
10
  end
11
11
 
12
12
  def target
13
- @target.upcase
13
+ @target.to_s.upcase
14
14
  end
15
15
 
16
16
  def base
17
- @base.upcase
17
+ @base.to_s.upcase
18
18
  end
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptoexchange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TM Lee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -166,6 +166,10 @@ files:
166
166
  - lib/cryptoexchange/exchanges/ccex/market.rb
167
167
  - lib/cryptoexchange/exchanges/ccex/services/market.rb
168
168
  - lib/cryptoexchange/exchanges/ccex/services/pairs.rb
169
+ - lib/cryptoexchange/exchanges/chbtc/chbtc.yml
170
+ - lib/cryptoexchange/exchanges/chbtc/market.rb
171
+ - lib/cryptoexchange/exchanges/chbtc/services/market.rb
172
+ - lib/cryptoexchange/exchanges/chbtc/services/pairs.rb
169
173
  - lib/cryptoexchange/exchanges/coin_exchange/market.rb
170
174
  - lib/cryptoexchange/exchanges/coin_exchange/services/market.rb
171
175
  - lib/cryptoexchange/exchanges/coin_exchange/services/pairs.rb
@@ -194,6 +198,9 @@ files:
194
198
  - lib/cryptoexchange/exchanges/hitbtc/market.rb
195
199
  - lib/cryptoexchange/exchanges/hitbtc/services/market.rb
196
200
  - lib/cryptoexchange/exchanges/hitbtc/services/pairs.rb
201
+ - lib/cryptoexchange/exchanges/jubi/market.rb
202
+ - lib/cryptoexchange/exchanges/jubi/services/market.rb
203
+ - lib/cryptoexchange/exchanges/jubi/services/pairs.rb
197
204
  - lib/cryptoexchange/exchanges/korbit/korbit.yml
198
205
  - lib/cryptoexchange/exchanges/korbit/market.rb
199
206
  - lib/cryptoexchange/exchanges/korbit/services/market.rb