cryptoexchange 0.6.3 → 0.7.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: 12a9a070d782d90d27457f820f61355beb3e3c9e
4
- data.tar.gz: 484346c7899f14f6d0a4f0f005ec978ff50c6f00
3
+ metadata.gz: 1e2eb4f1df95929e2a318e25f14d3470c5cc88f2
4
+ data.tar.gz: 477c991a4337aedc3ff38b708202cab7fcdacfbc
5
5
  SHA512:
6
- metadata.gz: 5961a15d0ce491a34792e29ee79441c6914c71f2118b6a6feccd0ba2828c61fc99dd64bb8931a3abab444c9ce0f97be128ae0f8c002d47cf32de00d01d32e371
7
- data.tar.gz: 563054fd95e229a1e59440460110432c45b596a3266ec7b579fd68eb990a144e6bcc8326395b4349cf614c3a87ac08bc668d37124e42c8b16a1fa6c1c7a2b4f3
6
+ metadata.gz: 1a834077db0e1e2d44ddc4b96638014c6cbdebc73b04695048d24ad526f0a71bb725a23b7c1c4a1c99cc146a880c61001b8cc72b63ee031a98413a3cb8089945
7
+ data.tar.gz: 6de66fe05b62640b2a50bceeefd90bb44e0001dd371aa725009d778236607179da2c57bf6a26a4b8f9ef81e2b4b2205e1da02aff084bf54b1c9bfa93e71c48d9
data/README.md CHANGED
@@ -70,6 +70,7 @@ Or install it yourself as:
70
70
  | Jubi | Y | | | | Y |
71
71
  | MercadoBitcoin | | | | | |
72
72
  | Viabtc | Y | | | | User-Defined|
73
+ | Tidex | Y | | | | Y |
73
74
 
74
75
  ## Usage
75
76
 
@@ -10,28 +10,29 @@ module Cryptoexchange::Exchanges
10
10
 
11
11
  def fetch(market_pair)
12
12
  output = super(ticker_url(market_pair))
13
- adapt(output)
13
+ adapt(output, market_pair)
14
14
  end
15
15
 
16
16
  def ticker_url(market_pair)
17
17
  base = market_pair.base
18
18
  target = market_pair.target
19
- "#{Cryptoexchange::Exchanges::Bittrex::Market::API_URL}/public/getmarketsummary?market=#{base}-#{target}"
19
+ # Bittrex pair has BTC comes first, when BTC is typically a Target not a Base
20
+ "#{Cryptoexchange::Exchanges::Bittrex::Market::API_URL}/public/getmarketsummary?market=#{target}-#{base}"
20
21
  end
21
22
 
22
- def adapt(output)
23
+ def adapt(output, market_pair)
23
24
  ticker = Cryptoexchange::Models::Ticker.new
24
25
  market = output['result'][0]
25
26
 
26
- ticker.base = market['MarketName'].split("-")[0]
27
- ticker.target = market['MarketName'].split("-")[1]
27
+ ticker.base = market_pair.base
28
+ ticker.target = market_pair.target
28
29
  ticker.market = Bittrex::Market::NAME
29
30
  ticker.last = NumericHelper.to_d(market['Last'])
30
31
  ticker.high = NumericHelper.to_d(market['High'])
31
32
  ticker.low = NumericHelper.to_d(market['Low'])
32
33
  ticker.ask = NumericHelper.to_d(market['Ask'])
33
34
  ticker.bid = NumericHelper.to_d(market['Bid'])
34
- ticker.volume = NumericHelper.to_d(market['BaseVolume'])
35
+ ticker.volume = NumericHelper.to_d(market['Volume'])
35
36
  ticker.timestamp = DateTime.now.to_time.to_i
36
37
  ticker.payload = market
37
38
  ticker
@@ -14,8 +14,8 @@ module Cryptoexchange::Exchanges
14
14
  market_pairs = []
15
15
  pairs.each do |pair|
16
16
  market_pairs << Cryptoexchange::Models::MarketPair.new(
17
- base: pair['BaseCurrency'],
18
- target: pair['MarketCurrency'],
17
+ base: pair['MarketCurrency'],
18
+ target: pair['BaseCurrency'],
19
19
  market: Bittrex::Market::NAME
20
20
  )
21
21
  end
@@ -19,10 +19,10 @@ module Cryptoexchange::Exchanges
19
19
 
20
20
  def adapt_all(output)
21
21
  output['result'].map do |ticker|
22
- currency_pair = ticker['MarketName'].split("_")
22
+ base, target = ticker['MarketName'].split("_")
23
23
  market_pair = Cryptoexchange::Models::MarketPair.new(
24
- base: currency_pair[1],
25
- target: currency_pair[0],
24
+ base: base,
25
+ target: target,
26
26
  market: Bleutrade::Market::NAME
27
27
  )
28
28
  adapt(ticker, market_pair)
@@ -39,7 +39,7 @@ module Cryptoexchange::Exchanges
39
39
  ticker.last = NumericHelper.to_d(output['Last'])
40
40
  ticker.high = NumericHelper.to_d(output['High'])
41
41
  ticker.low = NumericHelper.to_d(output['Low'])
42
- ticker.volume = NumericHelper.to_d(output['BaseVolume'])
42
+ ticker.volume = NumericHelper.to_d(output['Volume'])
43
43
  ticker.timestamp = Time.parse(output['TimeStamp']).to_i
44
44
  ticker.payload = output
45
45
  ticker
@@ -4,7 +4,6 @@ module Cryptoexchange::Exchanges
4
4
  class Pairs < Cryptoexchange::Services::Pairs
5
5
  PAIRS_URL = "#{Cryptoexchange::Exchanges::Bleutrade::Market::API_URL}/public/getmarkets"
6
6
 
7
-
8
7
  def fetch
9
8
  output = super
10
9
  adapt(output)
@@ -13,9 +12,10 @@ module Cryptoexchange::Exchanges
13
12
  def adapt(output)
14
13
  market_pairs = []
15
14
  output['result'].each do |pair|
15
+ base, target = pair['MarketName'].split("_")
16
16
  market_pairs << Cryptoexchange::Models::MarketPair.new(
17
- base: pair['BaseCurrency'],
18
- target: pair['MarketCurrency'],
17
+ base: base,
18
+ target: target,
19
19
  market: Bleutrade::Market::NAME
20
20
  )
21
21
  end
@@ -32,7 +32,7 @@ module Cryptoexchange::Exchanges
32
32
  ticker.ask = NumericHelper.to_d(data['AskPrice'])
33
33
  ticker.high = NumericHelper.to_d(data['High'])
34
34
  ticker.low = NumericHelper.to_d(data['Low'])
35
- ticker.volume = NumericHelper.to_d(data['BaseVolume'])
35
+ ticker.volume = NumericHelper.to_d(data['Volume'])
36
36
  ticker.change = NumericHelper.to_d(data['Change'])
37
37
  ticker.timestamp = Time.now.to_i
38
38
  ticker.payload = data
@@ -20,7 +20,7 @@ module Cryptoexchange::Exchanges
20
20
  end
21
21
 
22
22
  def adapt(output, market_pair)
23
- name = "#{market_pair.base}_#{market_pair.target}"
23
+ name = "#{market_pair.target}_#{market_pair.base}"
24
24
  market = output[name]
25
25
 
26
26
  ticker = Cryptoexchange::Models::Ticker.new
@@ -30,7 +30,7 @@ module Cryptoexchange::Exchanges
30
30
  ticker.last = NumericHelper.to_d(market['last'].to_s)
31
31
  ticker.bid = NumericHelper.to_d(market['bid'].to_s)
32
32
  ticker.ask = NumericHelper.to_d(market['ask'].to_s)
33
- ticker.volume = NumericHelper.to_d(market['baseVolume'].to_s)
33
+ ticker.volume = NumericHelper.to_d(market['quoteVolume'].to_s)
34
34
  ticker.timestamp = DateTime.now.to_time.to_i
35
35
  ticker.payload = market
36
36
  ticker
@@ -11,7 +11,9 @@ module Cryptoexchange::Exchanges
11
11
 
12
12
  def adapt(output)
13
13
  output.keys.map do |pair|
14
- base, target = pair.split('_')
14
+ # format example: ETH_ZRX
15
+ # ETH is the Target, ZRX is the Base
16
+ target, base = pair.split('_')
15
17
 
16
18
  Cryptoexchange::Models::MarketPair.new({
17
19
  base: base,
@@ -19,7 +19,9 @@ module Cryptoexchange::Exchanges
19
19
 
20
20
  def adapt_all(output)
21
21
  output.map do |pair, ticker|
22
- base, target = pair.split('_')
22
+ # Target comes first in Poloniex ie. BTC-BCN
23
+ # BTC cannot be a base in this pair
24
+ target, base = pair.split('_')
23
25
  market_pair = Cryptoexchange::Models::MarketPair.new(
24
26
  base: base,
25
27
  target: target,
@@ -40,7 +42,7 @@ module Cryptoexchange::Exchanges
40
42
  ticker.ask = NumericHelper.to_d(output['lowestAsk'])
41
43
  ticker.high = NumericHelper.to_d(output['high24hr'])
42
44
  ticker.low = NumericHelper.to_d(output['low24hr'])
43
- ticker.volume = NumericHelper.to_d(output['baseVolume'])
45
+ ticker.volume = NumericHelper.to_d(output['quoteVolume'])
44
46
  ticker.timestamp = Time.now.to_i
45
47
  ticker.payload = output
46
48
  ticker
@@ -13,7 +13,9 @@ module Cryptoexchange::Exchanges
13
13
  market_pairs = []
14
14
  output.each do |pair, ticker|
15
15
  market_pair = Cryptoexchange::Models::MarketPair.new
16
- base, target = pair.split('_')
16
+ # Target comes first in Poloniex ie. BTC-BCN
17
+ # BTC cannot be a base in this pair
18
+ target, base = pair.split('_')
17
19
  market_pair.base = base
18
20
  market_pair.target = target
19
21
  market_pair.market = Poloniex::Market::NAME
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Tidex
3
+ class Market
4
+ NAME = 'tidex'
5
+ API_URL = 'https://api.tidex.com/api/3'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,45 @@
1
+ require 'bigdecimal'
2
+
3
+ module Cryptoexchange::Exchanges
4
+ module Tidex
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
+ "#{Cryptoexchange::Exchanges::Tidex::Market::API_URL}/ticker/#{name}"
22
+ end
23
+
24
+ def adapt(output, market_pair)
25
+ name = "#{market_pair.base}_#{market_pair.target}".downcase
26
+ market = output[name]
27
+
28
+ ticker = Cryptoexchange::Models::Ticker.new
29
+ ticker.base = market_pair.base
30
+ ticker.target = market_pair.target
31
+ ticker.market = Tidex::Market::NAME
32
+ ticker.last = NumericHelper.to_d(market['last'])
33
+ ticker.bid = NumericHelper.to_d(market['buy'])
34
+ ticker.ask = NumericHelper.to_d(market['sell'])
35
+ ticker.high = NumericHelper.to_d(market['high'])
36
+ ticker.low = NumericHelper.to_d(market['low'])
37
+ ticker.volume = NumericHelper.to_d(market['vol_cur'])
38
+ ticker.timestamp = NumericHelper.to_d(market['updated'])
39
+ ticker.payload = market
40
+ ticker
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Tidex
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Tidex::Market::API_URL}/info"
6
+
7
+ def fetch
8
+ output = super
9
+ adapt(output)
10
+ end
11
+
12
+ def adapt(output)
13
+ output['pairs'].keys.map do |pair|
14
+ base, target = pair.split("_")
15
+ Cryptoexchange::Models::MarketPair.new({
16
+ base: base,
17
+ target: target,
18
+ market: Tidex::Market::NAME
19
+ })
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.6.3"
2
+ VERSION = "0.7.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.6.3
4
+ version: 0.7.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-18 00:00:00.000000000 Z
11
+ date: 2017-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -230,6 +230,9 @@ files:
230
230
  - lib/cryptoexchange/exchanges/quoine/market.rb
231
231
  - lib/cryptoexchange/exchanges/quoine/services/market.rb
232
232
  - lib/cryptoexchange/exchanges/quoine/services/pairs.rb
233
+ - lib/cryptoexchange/exchanges/tidex/market.rb
234
+ - lib/cryptoexchange/exchanges/tidex/services/market.rb
235
+ - lib/cryptoexchange/exchanges/tidex/services/pairs.rb
233
236
  - lib/cryptoexchange/exchanges/viabtc/market.rb
234
237
  - lib/cryptoexchange/exchanges/viabtc/services/market.rb
235
238
  - lib/cryptoexchange/exchanges/viabtc/services/pairs.rb