cryptoexchange 0.4.1 → 0.5.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: 1aae6f5b3fcc4d10605073217ab01c10b18ab7bf
4
- data.tar.gz: 24325829c3a386113f04afbbd19cff4741c0c027
3
+ metadata.gz: 5c3c5092969d161c818141bf62cd47ff1d06566c
4
+ data.tar.gz: 9e4b6006845a7b059436d4403168eff080db35eb
5
5
  SHA512:
6
- metadata.gz: dcd3bddc19b047facf316a0f7b098a40d34b097ed0158d55ef2fc1622230e450c20069de07f7a1bed3decbfde9811fec1fee3465d9dd8109d8c3c14f81877018
7
- data.tar.gz: fdb417d20b945868a7c553584cd05f19297a10467ce678f3dc29bc2eb6c35e2ab0f63c41b3d423b0bf3898581a30ea706bf8438a74838cea652494e45fdd3f6f
6
+ metadata.gz: 212c4eb457261902793e931496bc458878f39cef023c79779bc5fb460c885170aeaf146ebc6e22944649f77f9e9ddecf170069f23268a6f7605b84812cafa1b5
7
+ data.tar.gz: d5adf2fc535d3178c73855225052d5480532c6558edbce2faaab19e411aea1eff969d84656d81dda8250fa20ca0cddff9dab58beac34b7987931b98b31d6d249
data/README.md CHANGED
@@ -30,7 +30,7 @@ Or install it yourself as:
30
30
  | OKCoin | Y | | | | User-Defined|
31
31
  | LakeBTC | Y | | | | Y |
32
32
  | Huobi | | | | | |
33
- | Yunbi | | | | | |
33
+ | Yunbi | Y | | | | Y |
34
34
  | BTC38 | | | | | |
35
35
  | CHBTC | | | | | |
36
36
  | Bitstamp | Y | | | | User-Defined|
@@ -69,6 +69,7 @@ Or install it yourself as:
69
69
  | Itbit | | | | | |
70
70
  | Jubi | | | | | |
71
71
  | MercadoBitcoin | | | | | |
72
+ | Viabtc | Y | | | | User-Defined|
72
73
 
73
74
  ## Usage
74
75
 
@@ -2,7 +2,7 @@ module Cryptoexchange::Exchanges
2
2
  module Bitflyer
3
3
  class Market
4
4
  NAME = 'bitflyer'
5
- API_URL = 'https://api.bitflyer.jp/v1/'
5
+ API_URL = 'https://api.bitflyer.jp/v1'
6
6
  end
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@ module Cryptoexchange::Exchanges
2
2
  module Coincheck
3
3
  class Market
4
4
  NAME = 'coincheck'
5
- API_URL = 'https://coincheck.com/api/'
5
+ API_URL = 'https://coincheck.com/api'
6
6
  end
7
7
  end
8
8
  end
@@ -33,7 +33,7 @@ module Cryptoexchange::Exchanges
33
33
  ticker.ask = NumericHelper.to_d(market['ask'])
34
34
  ticker.high = NumericHelper.to_d(market['high24h'])
35
35
  ticker.low = NumericHelper.to_d(market['low24h'])
36
- ticker.volume = NumericHelper.to_d(market['volume24h'])
36
+ ticker.volume = NumericHelper.to_d(market['volume24h']) / ticker.last
37
37
  ticker.timestamp = Time.now.to_i
38
38
  ticker.payload = market
39
39
  ticker
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Viabtc
3
+ class Market
4
+ NAME = 'viabtc'
5
+ API_URL = 'https://www.viabtc.com/api/v1'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,41 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Viabtc
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::Viabtc::Market::API_URL}/market/ticker?market=#{market_pair.base}#{market_pair.target}"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ ticker = Cryptoexchange::Models::Ticker.new
22
+ output_data = output['data']
23
+ output_data_ticker = output_data['ticker']
24
+
25
+ ticker.base = market_pair.base
26
+ ticker.target = market_pair.target
27
+ ticker.market = Viabtc::Market::NAME
28
+ ticker.ask = NumericHelper.to_d(output_data_ticker['sell'])
29
+ ticker.bid = NumericHelper.to_d(output_data_ticker['buy'])
30
+ ticker.last = NumericHelper.to_d(output_data_ticker['last'])
31
+ ticker.high = NumericHelper.to_d(output_data_ticker['high'])
32
+ ticker.low = NumericHelper.to_d(output_data_ticker['low'])
33
+ ticker.volume = NumericHelper.to_d(output_data_ticker['vol'])
34
+ ticker.timestamp = output_data['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 Viabtc
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: Viabtc::Market::NAME
18
+ )
19
+ end
20
+ market_pairs
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ :pairs:
2
+ - :base: BTC
3
+ :target: CNY
4
+ - :base: BCC
5
+ :target: CNY
6
+ - :base: BCC
7
+ :target: BTC
8
+ - :base: LTC
9
+ :target: CNY
10
+ - :base: ETH
11
+ :target: CNY
12
+ - :base: ZEC
13
+ :target: CNY
14
+ - :base: 148
15
+ :target: ETH
16
+
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yunbi
3
+ class Market
4
+ NAME = 'yunbi'
5
+ API_URL = 'https://yunbi.com/api/v2'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,40 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yunbi
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(self.ticker_url(market_pair))
13
+ adapt(output, market_pair)
14
+ end
15
+
16
+ def ticker_url(market_pair)
17
+ parameter = "#{market_pair.base.downcase}#{market_pair.target.downcase}"
18
+ "#{Cryptoexchange::Exchanges::Yunbi::Market::API_URL}/tickers/#{parameter}"
19
+ end
20
+
21
+ def adapt(output, market_pair)
22
+ data_ticker = output['ticker']
23
+ ticker = Cryptoexchange::Models::Ticker.new
24
+ ticker.base = market_pair.base
25
+ ticker.target = market_pair.target
26
+ ticker.market = Yunbi::Market::NAME
27
+ ticker.last = NumericHelper.to_d(data_ticker['last'])
28
+ ticker.bid = NumericHelper.to_d(data_ticker['buy'])
29
+ ticker.ask = NumericHelper.to_d(data_ticker['sell'])
30
+ ticker.high = NumericHelper.to_d(data_ticker['high'])
31
+ ticker.low = NumericHelper.to_d(data_ticker['low'])
32
+ ticker.volume = NumericHelper.to_d(data_ticker['vol'])
33
+ ticker.timestamp = output['at'].to_i
34
+ ticker.payload = output
35
+ ticker
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yunbi
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Yunbi::Market::API_URL}/markets"
6
+
7
+ def fetch
8
+ output = super
9
+ adapt(output)
10
+ end
11
+
12
+ def adapt(output)
13
+ market_pairs = []
14
+ output.each do |pair|
15
+ market_pair = Cryptoexchange::Models::MarketPair.new
16
+ base, target = pair['name'].split('/')
17
+
18
+ # Workaround for bad unicode {"id":"1stcny","name":"1SŦ/CNY"}
19
+ target.downcase!
20
+ base = pair['id'].match(/(.+)#{target}/)[1]
21
+
22
+ market_pair.base = base
23
+ market_pair.target = target
24
+ market_pair.market = Yunbi::Market::NAME
25
+ market_pairs << market_pair
26
+ end
27
+ market_pairs
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.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.4.1
4
+ version: 0.5.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-03 00:00:00.000000000 Z
11
+ date: 2017-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -223,9 +223,16 @@ files:
223
223
  - lib/cryptoexchange/exchanges/quoine/market.rb
224
224
  - lib/cryptoexchange/exchanges/quoine/services/market.rb
225
225
  - lib/cryptoexchange/exchanges/quoine/services/pairs.rb
226
+ - lib/cryptoexchange/exchanges/viabtc/market.rb
227
+ - lib/cryptoexchange/exchanges/viabtc/services/market.rb
228
+ - lib/cryptoexchange/exchanges/viabtc/services/pairs.rb
229
+ - lib/cryptoexchange/exchanges/viabtc/viabtc.yml
226
230
  - lib/cryptoexchange/exchanges/yobit/market.rb
227
231
  - lib/cryptoexchange/exchanges/yobit/services/market.rb
228
232
  - lib/cryptoexchange/exchanges/yobit/services/pairs.rb
233
+ - lib/cryptoexchange/exchanges/yunbi/market.rb
234
+ - lib/cryptoexchange/exchanges/yunbi/services/market.rb
235
+ - lib/cryptoexchange/exchanges/yunbi/services/pairs.rb
229
236
  - lib/cryptoexchange/helpers/hash_helper.rb
230
237
  - lib/cryptoexchange/helpers/numeric_helper.rb
231
238
  - lib/cryptoexchange/helpers/string_helper.rb