cryptoexchange 0.9.0 → 0.10.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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -4
  3. data/lib/cryptoexchange/exchanges/bithumb/services/market.rb +1 -1
  4. data/lib/cryptoexchange/exchanges/btcc/services/market.rb +1 -1
  5. data/lib/cryptoexchange/exchanges/bx_thailand/market.rb +8 -0
  6. data/lib/cryptoexchange/exchanges/bx_thailand/services/market.rb +49 -0
  7. data/lib/cryptoexchange/exchanges/bx_thailand/services/pairs.rb +25 -0
  8. data/lib/cryptoexchange/exchanges/chbtc/services/market.rb +1 -1
  9. data/lib/cryptoexchange/exchanges/gemini/services/market.rb +1 -1
  10. data/lib/cryptoexchange/exchanges/huobi/market.rb +9 -0
  11. data/lib/cryptoexchange/exchanges/huobi/services/market.rb +50 -0
  12. data/lib/cryptoexchange/exchanges/huobi/services/pairs.rb +29 -0
  13. data/lib/cryptoexchange/exchanges/mercado_bitcoin/market.rb +8 -0
  14. data/lib/cryptoexchange/exchanges/mercado_bitcoin/mercado_bitcoin.yml +7 -0
  15. data/lib/cryptoexchange/exchanges/mercado_bitcoin/services/market.rb +39 -0
  16. data/lib/cryptoexchange/exchanges/mercado_bitcoin/services/pairs.rb +22 -0
  17. data/lib/cryptoexchange/exchanges/quadrigacx/market.rb +8 -0
  18. data/lib/cryptoexchange/exchanges/quadrigacx/quadrigacx.yml +13 -0
  19. data/lib/cryptoexchange/exchanges/quadrigacx/services/market.rb +40 -0
  20. data/lib/cryptoexchange/exchanges/quadrigacx/services/pairs.rb +22 -0
  21. data/lib/cryptoexchange/exchanges/szzc/market.rb +8 -0
  22. data/lib/cryptoexchange/exchanges/szzc/services/market.rb +39 -0
  23. data/lib/cryptoexchange/exchanges/szzc/services/pairs.rb +27 -0
  24. data/lib/cryptoexchange/exchanges/tidex/services/market.rb +1 -1
  25. data/lib/cryptoexchange/exchanges/viabtc/services/market.rb +1 -1
  26. data/lib/cryptoexchange/exchanges/yuanbao/market.rb +8 -0
  27. data/lib/cryptoexchange/exchanges/yuanbao/services/market.rb +38 -0
  28. data/lib/cryptoexchange/exchanges/yuanbao/services/pairs.rb +21 -0
  29. data/lib/cryptoexchange/exchanges/yuanbao/yuanbao.yml +83 -0
  30. data/lib/cryptoexchange/services/pairs.rb +2 -2
  31. data/lib/cryptoexchange/version.rb +1 -1
  32. metadata +23 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bab1c59d48b9604529a0494b1d7885a47309b1b
4
- data.tar.gz: 06b32ff2be8cf9ad5615484c5466ff37cfda884f
3
+ metadata.gz: 9d4175dc19107087664005ba71c0e80e044b6d9f
4
+ data.tar.gz: a7c0f474912bb15248ac12a8d0a0202e99e4caf5
5
5
  SHA512:
6
- metadata.gz: 32d34a5844b13a0674839aaa63a0d55b1487037a870085d6bb5b9eaa81d5fd6ba6fc5b55fb6408333bf34eb5f12b98799afd159683ac4c0c1765ae1ccde01eb3
7
- data.tar.gz: 7532ad0aca0c6e0e1ec3f9fc1030ca0f507a9b7bf029c778f19977ad989a2cdbaf944bf1382f2a8e983dcba8fd32fe2b15b38b14010b9c89e24899ce38336ad9
6
+ metadata.gz: fb8fb9fbb6857cdecaa1bbfe848b938783574b5223d75125cd32d7dd40d903a26bb15d248b4af4bada4e07cea6ca4cc6730541686f7e04a89fab613246535971
7
+ data.tar.gz: 6b053cde84855441e94227cd419468c3d0647247163a59583caacbc4bdf9b8571239d64ba07b634a3056db2614d97fe940c4b9df080ad2e1a5643b58b513aa3a
data/README.md CHANGED
@@ -26,12 +26,13 @@ Or install it yourself as:
26
26
  | ----------------- | ------- | ---------- | ------- | ------- | ----------- |
27
27
  | ANX | Y | | | | User-Defined|
28
28
  | Gatecoin | Y | | | | Y |
29
- | Bitso | Y | | | | Y
29
+ | Bitso | Y | | | | Y |
30
30
  | BTCC | Y | | | | User-Defined|
31
31
  | OKCoin | Y | | | | User-Defined|
32
32
  | LakeBTC | Y | | | | Y |
33
- | Huobi | | | | | |
33
+ | Huobi | Y | | | | Y |
34
34
  | Yunbi | Y | | | | Y |
35
+ | Yuanbao | Y | | | | User-Defined|
35
36
  | BTC38 | | | | | |
36
37
  | CHBTC | Y | | | | User-Defined|
37
38
  | Bitstamp | Y | | | | User-Defined|
@@ -43,7 +44,7 @@ Or install it yourself as:
43
44
  | Coincheck | Y | | | | User-Defined|
44
45
  | Bitflyer | Y | | | | Y |
45
46
  | Quoine | Y | | | | Y |
46
- | QuadrigaCX | | | | | |
47
+ | QuadrigaCX | Y | | | | User-Defined|
47
48
  | Unocoin | | | | | |
48
49
  | Coinone | Y | | | | Y |
49
50
  | Korbit | Y | | | | User-Defined|
@@ -69,10 +70,12 @@ Or install it yourself as:
69
70
  | Coinmate | | | | | |
70
71
  | Itbit | | | | | |
71
72
  | Jubi | Y | | | | Y |
72
- | MercadoBitcoin | | | | | |
73
+ | MercadoBitcoin | Y | | | | User-Defined|
73
74
  | Viabtc | Y | | | | User-Defined|
74
75
  | Tidex | Y | | | | Y |
75
76
  | Bitbay | Y | | | | User-Defined|
77
+ | SZZC | Y | | | | Y |
78
+ | BX Thailand | Y | | | | Y |
76
79
 
77
80
  ## Usage
78
81
 
@@ -30,7 +30,7 @@ module Cryptoexchange::Exchanges
30
30
  ticker.low = NumericHelper.to_d(market['min_price'])
31
31
  #use 1day volume instead of 7days
32
32
  ticker.volume = NumericHelper.to_d(market['volume_1day'])
33
- ticker.timestamp = market['date'].to_i
33
+ ticker.timestamp = market['date'].to_i / 1000
34
34
  ticker.payload = market
35
35
  ticker
36
36
  end
@@ -32,7 +32,7 @@ module Cryptoexchange::Exchanges
32
32
  ticker.high = NumericHelper.to_d(output['ticker']['High'])
33
33
  ticker.low = NumericHelper.to_d(output['ticker']['Low'])
34
34
  ticker.volume = NumericHelper.to_d(output['ticker']['Volume'])
35
- ticker.timestamp = output['ticker']['Timestamp'].to_i
35
+ ticker.timestamp = output['ticker']['Timestamp'].to_i / 1000
36
36
  ticker.payload = output
37
37
  ticker
38
38
  end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module BxThailand
3
+ class Market
4
+ NAME = 'bx_thailand'
5
+ API_URL = 'https://bx.in.th/api/'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,49 @@
1
+ module Cryptoexchange::Exchanges
2
+ module BxThailand
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(ticker_url)
13
+ adapt_all(output)
14
+ end
15
+
16
+ def ticker_url
17
+ Cryptoexchange::Exchanges::BxThailand::Market::API_URL
18
+ end
19
+
20
+ def adapt_all(output)
21
+ output.values.map do |ticker|
22
+ base = ticker['secondary_currency']
23
+ target = ticker['primary_currency']
24
+ market_pair = Cryptoexchange::Models::MarketPair.new(
25
+ base: base,
26
+ target: target,
27
+ market: BxThailand::Market::NAME
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 = BxThailand::Market::NAME
38
+ ticker.ask = NumericHelper.to_d(HashHelper.dig(output, 'orderbook', 'asks', 'highbid'))
39
+ ticker.bid = NumericHelper.to_d(HashHelper.dig(output, 'orderbook', 'bids', 'highbid'))
40
+ ticker.last = NumericHelper.to_d(output['last_price'])
41
+ ticker.volume = NumericHelper.to_d(output['volume_24hours'])
42
+ ticker.timestamp = Time.now.to_i
43
+ ticker.payload = output
44
+ ticker
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,25 @@
1
+ module Cryptoexchange::Exchanges
2
+ module BxThailand
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::BxThailand::Market::API_URL}"
6
+
7
+
8
+ def fetch
9
+ output = super
10
+ adapt(output)
11
+ end
12
+
13
+ def adapt(output)
14
+ output.values.map do |pair|
15
+ Cryptoexchange::Models::MarketPair.new(
16
+ base: pair['secondary_currency'],
17
+ target: pair['primary_currency'],
18
+ market: BxThailand::Market::NAME
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -31,7 +31,7 @@ module Cryptoexchange::Exchanges
31
31
  ticker.high = NumericHelper.to_d(ticker_data['high'])
32
32
  ticker.low = NumericHelper.to_d(ticker_data['low'])
33
33
  ticker.volume = NumericHelper.to_d(ticker_data['vol'])
34
- ticker.timestamp = output['date'].to_i
34
+ ticker.timestamp = output['date'].to_i / 1000
35
35
  ticker.payload = output
36
36
  ticker
37
37
  end
@@ -39,7 +39,7 @@ module Cryptoexchange::Exchanges
39
39
  ticker.bid = NumericHelper.to_d(output['bid'])
40
40
  # this is Base currency's volume
41
41
  ticker.volume = NumericHelper.to_d(output['volume'][market_pair.base])
42
- ticker.timestamp = output['volume']['timestamp'].to_i
42
+ ticker.timestamp = output['volume']['timestamp'].to_i / 1000
43
43
  ticker.payload = output
44
44
  ticker
45
45
  end
@@ -0,0 +1,9 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Huobi
3
+ class Market
4
+ NAME = 'huobi'
5
+ DOT_COM_API_URL = 'https://be.huobi.com'
6
+ DOT_PRO_API_URL = 'https://api.huobi.pro'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,50 @@
1
+ require 'bigdecimal'
2
+
3
+ module Cryptoexchange::Exchanges
4
+ module Huobi
5
+ module Services
6
+ class Market < Cryptoexchange::Services::Market
7
+ class << self
8
+ def supports_individual_ticker_query?
9
+ true
10
+ end
11
+ end
12
+
13
+ def fetch(market_pair)
14
+ output = super(ticker_url(market_pair))
15
+ adapt(output, market_pair)
16
+ end
17
+
18
+ def ticker_url(market_pair)
19
+ name = "#{market_pair.base}#{market_pair.target}".downcase
20
+
21
+ if market_pair.target == 'CNY'
22
+ base = Cryptoexchange::Exchanges::Huobi::Market::DOT_COM_API_URL
23
+ else
24
+ base = Cryptoexchange::Exchanges::Huobi::Market::DOT_PRO_API_URL
25
+ end
26
+
27
+ "#{base}/market/detail/merged?symbol=#{name}"
28
+ end
29
+
30
+ def adapt(output, market_pair)
31
+ market = output['tick']
32
+
33
+ ticker = Cryptoexchange::Models::Ticker.new
34
+ ticker.base = market_pair.base
35
+ ticker.target = market_pair.target
36
+ ticker.market = Huobi::Market::NAME
37
+ ticker.last = NumericHelper.to_d(market['close'])
38
+ ticker.bid = NumericHelper.to_d(market['bid'][0])
39
+ ticker.ask = NumericHelper.to_d(market['ask'][0])
40
+ ticker.high = NumericHelper.to_d(market['high'])
41
+ ticker.low = NumericHelper.to_d(market['low'])
42
+ ticker.volume = NumericHelper.to_d(market['amount'])
43
+ ticker.timestamp = market['ts'].to_i / 1000
44
+ ticker.payload = market
45
+ ticker
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,29 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Huobi
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URLS = [
6
+ "#{Cryptoexchange::Exchanges::Huobi::Market::DOT_COM_API_URL}/v1/common/symbols",
7
+ "#{Cryptoexchange::Exchanges::Huobi::Market::DOT_PRO_API_URL}/v1/common/symbols"
8
+ ]
9
+
10
+ def fetch
11
+ PAIRS_URLS.map do |endpoint|
12
+ output = fetch_via_api(endpoint)
13
+ adapt(output)
14
+ end.flatten
15
+ end
16
+
17
+ def adapt(output)
18
+ output['data'].map do |pair|
19
+ Cryptoexchange::Models::MarketPair.new({
20
+ base: pair['base-currency'],
21
+ target: pair['quote-currency'],
22
+ market: Huobi::Market::NAME
23
+ })
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module MercadoBitcoin
3
+ class Market
4
+ NAME = 'mercado_bitcoin'
5
+ API_URL = 'https://www.mercadobitcoin.net/api'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ :pairs:
2
+ - :base: BTC
3
+ :target: BRL
4
+ - :base: LTC
5
+ :target: BRL
6
+ - :base: BCH
7
+ :target: BRL
@@ -0,0 +1,39 @@
1
+ module Cryptoexchange::Exchanges
2
+ module MercadoBitcoin
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
+ "#{Cryptoexchange::Exchanges::MercadoBitcoin::Market::API_URL}/#{market_pair.base}/ticker/"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ ticker = Cryptoexchange::Models::Ticker.new
22
+ ticker_json = output['ticker']
23
+ ticker.base = market_pair.base
24
+ ticker.target = market_pair.target
25
+ ticker.market = MercadoBitcoin::Market::NAME
26
+ ticker.ask = NumericHelper.to_d(ticker_json['sell'])
27
+ ticker.bid = NumericHelper.to_d(ticker_json['buy'])
28
+ ticker.last = NumericHelper.to_d(ticker_json['last'])
29
+ ticker.high = NumericHelper.to_d(ticker_json['high'])
30
+ ticker.low = NumericHelper.to_d(ticker_json['low'])
31
+ ticker.volume = NumericHelper.to_d(ticker_json['vol'])
32
+ ticker.timestamp = ticker_json['date']
33
+ ticker.payload = output
34
+ ticker
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,22 @@
1
+ module Cryptoexchange::Exchanges
2
+ module MercadoBitcoin
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+
6
+ def fetch
7
+ adapt(super)
8
+ end
9
+
10
+ def adapt(output)
11
+ output.map do |pair|
12
+ Cryptoexchange::Models::MarketPair.new(
13
+ base: pair[:base],
14
+ target: pair[:target],
15
+ market: MercadoBitcoin::Market::NAME
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Quadrigacx
3
+ class Market
4
+ NAME = 'quadrigacx'
5
+ API_URL = 'https://api.quadrigacx.com/v2'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ :pairs:
2
+ - :base: BTC
3
+ :target: CAD
4
+ - :base: BTC
5
+ :target: USD
6
+ - :base: ETH
7
+ :target: BTC
8
+ - :base: ETH
9
+ :target: CAD
10
+ - :base: LTC
11
+ :target: CAD
12
+ - :base: BCH
13
+ :target: CAD
@@ -0,0 +1,40 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Quadrigacx
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(market_pair, output)
14
+ end
15
+
16
+ def ticker_url(market_pair)
17
+ book = "#{market_pair.base}_#{market_pair.target}"
18
+ "#{Cryptoexchange::Exchanges::Quadrigacx::Market::API_URL}/ticker?book=#{book}"
19
+ end
20
+
21
+ def adapt(market_pair, output)
22
+ ticker = Cryptoexchange::Models::Ticker.new
23
+
24
+ ticker.base = market_pair.base
25
+ ticker.target = market_pair.target
26
+ ticker.market = Quadrigacx::Market::NAME
27
+ ticker.ask = NumericHelper.to_d(output['ask'])
28
+ ticker.bid = NumericHelper.to_d(output['bid'])
29
+ ticker.last = NumericHelper.to_d(output['last'])
30
+ ticker.high = NumericHelper.to_d(output['high'])
31
+ ticker.low = NumericHelper.to_d(output['low'])
32
+ ticker.volume = NumericHelper.to_d(output['volume'])
33
+ ticker.timestamp = output['timestamp'].to_i
34
+ ticker.payload = output
35
+ ticker
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Quadrigacx
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ def fetch
6
+ output = super
7
+ adapt(output)
8
+ end
9
+
10
+ def adapt(output)
11
+ output.map do |pair|
12
+ Cryptoexchange::Models::MarketPair.new({
13
+ base: pair[:base],
14
+ target: pair[:target],
15
+ market: Quadrigacx::Market::NAME
16
+ })
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Szzc
3
+ class Market
4
+ NAME = 'szzc'
5
+ API_URL = 'https://szzc.com/api/public'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,39 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Szzc
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
+ "#{Cryptoexchange::Exchanges::Szzc::Market::API_URL}/ticker/#{market_pair.base}#{market_pair.target}"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ result = output['result']
22
+ ticker = Cryptoexchange::Models::Ticker.new
23
+ ticker.base = market_pair.base
24
+ ticker.target = market_pair.target
25
+ ticker.market = Szzc::Market::NAME
26
+ ticker.ask = NumericHelper.to_d(result['sell'] / 1e8)
27
+ ticker.bid = NumericHelper.to_d(result['buy'] / 1e8)
28
+ ticker.last = NumericHelper.to_d(result['last'] / 1e8)
29
+ ticker.high = NumericHelper.to_d(result['high'] / 1e8)
30
+ ticker.low = NumericHelper.to_d(result['low'] / 1e8)
31
+ ticker.volume = NumericHelper.to_d(result['vol'] / 1e8)
32
+ ticker.timestamp = NumericHelper.to_d(result['date']) / 1_000
33
+ ticker.payload = output
34
+ ticker
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Szzc
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Szzc::Market::API_URL}/trading_pairs"
6
+
7
+
8
+ def fetch
9
+ adapt(super)
10
+ end
11
+
12
+ def adapt(output)
13
+ market_pairs = []
14
+ HashHelper.dig(output, 'status', 'message').each do |name, pair|
15
+ market_pairs << Cryptoexchange::Models::MarketPair.new(
16
+ base: pair['bid_asset_symbol'],
17
+ target: pair['ask_asset_symbol'],
18
+ market: Szzc::Market::NAME
19
+ )
20
+ end
21
+
22
+ market_pairs
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -35,7 +35,7 @@ module Cryptoexchange::Exchanges
35
35
  ticker.high = NumericHelper.to_d(market['high'])
36
36
  ticker.low = NumericHelper.to_d(market['low'])
37
37
  ticker.volume = NumericHelper.to_d(market['vol_cur'])
38
- ticker.timestamp = NumericHelper.to_d(market['updated'])
38
+ ticker.timestamp = market['updated'].to_i
39
39
  ticker.payload = market
40
40
  ticker
41
41
  end
@@ -31,7 +31,7 @@ module Cryptoexchange::Exchanges
31
31
  ticker.high = NumericHelper.to_d(output_data_ticker['high'])
32
32
  ticker.low = NumericHelper.to_d(output_data_ticker['low'])
33
33
  ticker.volume = NumericHelper.to_d(output_data_ticker['vol'])
34
- ticker.timestamp = output_data['date'].to_i
34
+ ticker.timestamp = output_data['date'].to_i / 1000
35
35
  ticker.payload = output
36
36
  ticker
37
37
  end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yuanbao
3
+ class Market
4
+ NAME = 'yuanbao'
5
+ API_URL = 'https://www.yuanbao.com/api_market/getinfo_cny/coin'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yuanbao
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)
14
+ end
15
+
16
+ def ticker_url(market_pair)
17
+ "#{Cryptoexchange::Exchanges::Yuanbao::Market::API_URL}/#{market_pair.base.downcase}"
18
+ end
19
+
20
+ def adapt(output)
21
+ ticker = Cryptoexchange::Models::Ticker.new
22
+ ticker.base = output['name']
23
+ ticker.target = 'CNY'
24
+ ticker.market = Yuanbao::Market::NAME
25
+ ticker.ask = NumericHelper.to_d(output['sale'])
26
+ ticker.bid = NumericHelper.to_d(output['buy'])
27
+ ticker.last = NumericHelper.to_d(output['price'])
28
+ ticker.high = NumericHelper.to_d(output['max'])
29
+ ticker.low = NumericHelper.to_d(output['min'])
30
+ ticker.volume = NumericHelper.to_d(output['volume_24h'])
31
+ ticker.timestamp = Time.now.to_i
32
+ ticker.payload = output
33
+ ticker
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yuanbao
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ def fetch
6
+ adapt(super)
7
+ end
8
+
9
+ def adapt(output)
10
+ output.map do |pair|
11
+ Cryptoexchange::Models::MarketPair.new(
12
+ base: pair[:base],
13
+ target: pair[:target],
14
+ market: Yuanbao::Market::NAME
15
+ )
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,83 @@
1
+ :pairs:
2
+ - :base: BTC
3
+ :target: CNY
4
+ - :base: NEO
5
+ :target: CNY
6
+ - :base: XRP
7
+ :target: CNY
8
+ - :base: ETH
9
+ :target: CNY
10
+ - :base: QTUM
11
+ :target: CNY
12
+ - :base: DCT
13
+ :target: CNY
14
+ - :base: XLM
15
+ :target: CNY
16
+ - :base: ABC
17
+ :target: CNY
18
+ - :base: LTC
19
+ :target: CNY
20
+ - :base: ETC
21
+ :target: CNY
22
+ - :base: DOGE
23
+ :target: CNY
24
+ - :base: YBC
25
+ :target: CNY
26
+ - :base: ZEC
27
+ :target: CNY
28
+ - :base: FCT
29
+ :target: CNY
30
+ - :base: TMC
31
+ :target: CNY
32
+ - :base: XSI
33
+ :target: CNY
34
+ - :base: NAS
35
+ :target: CNY
36
+ - :base: LEC
37
+ :target: CNY
38
+ - :base: MCC
39
+ :target: CNY
40
+ - :base: EOS
41
+ :target: CNY
42
+ - :base: XAS
43
+ :target: CNY
44
+ - :base: SMC
45
+ :target: CNY
46
+ - :base: LMC
47
+ :target: CNY
48
+ - :base: GAME
49
+ :target: CNY
50
+ - :base: SHC
51
+ :target: CNY
52
+ - :base: ARC
53
+ :target: CNY
54
+ - :base: XKC
55
+ :target: CNY
56
+ - :base: MXI
57
+ :target: CNY
58
+ - :base: YBY
59
+ :target: CNY
60
+ - :base: BASH
61
+ :target: CNY
62
+ - :base: MC
63
+ :target: CNY
64
+ - :base: UDB
65
+ :target: CNY
66
+ - :base: MRYC
67
+ :target: CNY
68
+ - :base: RHKC
69
+ :target: CNY
70
+ - :base: BTE
71
+ :target: CNY
72
+ - :base: JC
73
+ :target: CNY
74
+ - :base: CIC
75
+ :target: CNY
76
+ - :base: GP
77
+ :target: CNY
78
+ - :base: AXF
79
+ :target: CNY
80
+ - :base: GOOC
81
+ :target: CNY
82
+ - :base: VASH
83
+ :target: CNY
@@ -17,8 +17,8 @@ module Cryptoexchange
17
17
  return fetch_via_override(default_override_path) if default_override_exist?
18
18
  end
19
19
 
20
- def fetch_via_api
21
- fetch_response = HTTP.timeout(:write => 2, :connect => 5, :read => 8).get(self.class::PAIRS_URL)
20
+ def fetch_via_api(endpoint = self.class::PAIRS_URL)
21
+ fetch_response = HTTP.timeout(:write => 2, :connect => 5, :read => 8).get(endpoint)
22
22
  JSON.parse(fetch_response.to_s)
23
23
  end
24
24
 
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.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.9.0
4
+ version: 0.10.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-22 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -171,6 +171,9 @@ files:
171
171
  - lib/cryptoexchange/exchanges/bter/market.rb
172
172
  - lib/cryptoexchange/exchanges/bter/services/market.rb
173
173
  - lib/cryptoexchange/exchanges/bter/services/pairs.rb
174
+ - lib/cryptoexchange/exchanges/bx_thailand/market.rb
175
+ - lib/cryptoexchange/exchanges/bx_thailand/services/market.rb
176
+ - lib/cryptoexchange/exchanges/bx_thailand/services/pairs.rb
174
177
  - lib/cryptoexchange/exchanges/ccex/market.rb
175
178
  - lib/cryptoexchange/exchanges/ccex/services/market.rb
176
179
  - lib/cryptoexchange/exchanges/ccex/services/pairs.rb
@@ -206,6 +209,9 @@ files:
206
209
  - lib/cryptoexchange/exchanges/hitbtc/market.rb
207
210
  - lib/cryptoexchange/exchanges/hitbtc/services/market.rb
208
211
  - lib/cryptoexchange/exchanges/hitbtc/services/pairs.rb
212
+ - lib/cryptoexchange/exchanges/huobi/market.rb
213
+ - lib/cryptoexchange/exchanges/huobi/services/market.rb
214
+ - lib/cryptoexchange/exchanges/huobi/services/pairs.rb
209
215
  - lib/cryptoexchange/exchanges/jubi/market.rb
210
216
  - lib/cryptoexchange/exchanges/jubi/services/market.rb
211
217
  - lib/cryptoexchange/exchanges/jubi/services/pairs.rb
@@ -225,6 +231,10 @@ files:
225
231
  - lib/cryptoexchange/exchanges/livecoin/market.rb
226
232
  - lib/cryptoexchange/exchanges/livecoin/services/market.rb
227
233
  - lib/cryptoexchange/exchanges/livecoin/services/pairs.rb
234
+ - lib/cryptoexchange/exchanges/mercado_bitcoin/market.rb
235
+ - lib/cryptoexchange/exchanges/mercado_bitcoin/mercado_bitcoin.yml
236
+ - lib/cryptoexchange/exchanges/mercado_bitcoin/services/market.rb
237
+ - lib/cryptoexchange/exchanges/mercado_bitcoin/services/pairs.rb
228
238
  - lib/cryptoexchange/exchanges/novaexchange/market.rb
229
239
  - lib/cryptoexchange/exchanges/novaexchange/services/market.rb
230
240
  - lib/cryptoexchange/exchanges/novaexchange/services/pairs.rb
@@ -235,9 +245,16 @@ files:
235
245
  - lib/cryptoexchange/exchanges/poloniex/market.rb
236
246
  - lib/cryptoexchange/exchanges/poloniex/services/market.rb
237
247
  - lib/cryptoexchange/exchanges/poloniex/services/pairs.rb
248
+ - lib/cryptoexchange/exchanges/quadrigacx/market.rb
249
+ - lib/cryptoexchange/exchanges/quadrigacx/quadrigacx.yml
250
+ - lib/cryptoexchange/exchanges/quadrigacx/services/market.rb
251
+ - lib/cryptoexchange/exchanges/quadrigacx/services/pairs.rb
238
252
  - lib/cryptoexchange/exchanges/quoine/market.rb
239
253
  - lib/cryptoexchange/exchanges/quoine/services/market.rb
240
254
  - lib/cryptoexchange/exchanges/quoine/services/pairs.rb
255
+ - lib/cryptoexchange/exchanges/szzc/market.rb
256
+ - lib/cryptoexchange/exchanges/szzc/services/market.rb
257
+ - lib/cryptoexchange/exchanges/szzc/services/pairs.rb
241
258
  - lib/cryptoexchange/exchanges/tidex/market.rb
242
259
  - lib/cryptoexchange/exchanges/tidex/services/market.rb
243
260
  - lib/cryptoexchange/exchanges/tidex/services/pairs.rb
@@ -248,6 +265,10 @@ files:
248
265
  - lib/cryptoexchange/exchanges/yobit/market.rb
249
266
  - lib/cryptoexchange/exchanges/yobit/services/market.rb
250
267
  - lib/cryptoexchange/exchanges/yobit/services/pairs.rb
268
+ - lib/cryptoexchange/exchanges/yuanbao/market.rb
269
+ - lib/cryptoexchange/exchanges/yuanbao/services/market.rb
270
+ - lib/cryptoexchange/exchanges/yuanbao/services/pairs.rb
271
+ - lib/cryptoexchange/exchanges/yuanbao/yuanbao.yml
251
272
  - lib/cryptoexchange/exchanges/yunbi/market.rb
252
273
  - lib/cryptoexchange/exchanges/yunbi/services/market.rb
253
274
  - lib/cryptoexchange/exchanges/yunbi/services/pairs.rb