cryptoexchange 0.4.0 → 0.4.1

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: b4d08d974d4145bf2068ed0056f31bfe9e2c8419
4
- data.tar.gz: fc0e014ad4cbdb93d1f84f1b409f2e0279844538
3
+ metadata.gz: 1aae6f5b3fcc4d10605073217ab01c10b18ab7bf
4
+ data.tar.gz: 24325829c3a386113f04afbbd19cff4741c0c027
5
5
  SHA512:
6
- metadata.gz: 5f6e9330b3c3d3acfc3afb9210e71d853e63d47663121baf2b61ffb7308f3cc2143c61aa3a51d40ab5d0ffc299f20007925f678f28a611c60720617ce53b22cc
7
- data.tar.gz: 5d55cd4bf6cc41d3c969617b558db0bf3f1a84e23e0e0f76e89cd9737bd0a650279a6a3f74d54e6ea0cc7fe4afa51b9775dfb8d7e36bed58abf73d7b8813df7c
6
+ metadata.gz: dcd3bddc19b047facf316a0f7b098a40d34b097ed0158d55ef2fc1622230e450c20069de07f7a1bed3decbfde9811fec1fee3465d9dd8109d8c3c14f81877018
7
+ data.tar.gz: fdb417d20b945868a7c553584cd05f19297a10467ce678f3dc29bc2eb6c35e2ab0f63c41b3d423b0bf3898581a30ea706bf8438a74838cea652494e45fdd3f6f
data/README.md CHANGED
@@ -35,10 +35,10 @@ Or install it yourself as:
35
35
  | CHBTC | | | | | |
36
36
  | Bitstamp | Y | | | | User-Defined|
37
37
  | Bittrex | Y | | | | Y |
38
- | GDAX | | | | | |
38
+ | GDAX | Y | | | | Y |
39
39
  | Gemini | Y | | | | Y |
40
+ | Poloniex | Y | | | | Y |
40
41
  | Kraken | Y | | | | Y |
41
- | Poloniex | | | | | |
42
42
  | Coincheck | Y | | | | User-Defined|
43
43
  | Bitflyer | Y | | | | Y |
44
44
  | Quoine | | | | | |
@@ -50,7 +50,7 @@ Or install it yourself as:
50
50
  | Luno | | | | | |
51
51
  | BTC-e | | | | | |
52
52
  | Bleutrade | Y | | | | Y |
53
- | Yobit | | | | | |
53
+ | Yobit | Y | | | | Y |
54
54
  | Bitfinex | Y | | | | Y |
55
55
  | BTER | Y | | | | Y |
56
56
  | Cryptopia | Y | | | | Y |
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Gdax
3
+ class Market
4
+ NAME = 'gdax'
5
+ API_URL = 'https://api.gdax.com'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Gdax
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::Gdax::Market::API_URL}/products/#{base}-#{target}/ticker"
20
+ end
21
+
22
+ def adapt(output, market_pair)
23
+ ticker = Cryptoexchange::Models::Ticker.new
24
+ ticker.base = market_pair.base
25
+ ticker.target = market_pair.target
26
+ ticker.market = Gdax::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['price'])
30
+ ticker.volume = NumericHelper.to_d(output['volume'])
31
+ ticker.timestamp = Time.parse(output['time']).to_i
32
+ ticker.payload = output
33
+ ticker
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,29 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Gdax
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Gdax::Market::API_URL}/products"
6
+
7
+ def fetch
8
+ output = super
9
+ adapt(output)
10
+ end
11
+
12
+ def adapt(output)
13
+ market_pairs = []
14
+ output.each do |product|
15
+ base = product['base_currency']
16
+ target = product['quote_currency']
17
+
18
+ market_pair = Cryptoexchange::Models::MarketPair.new
19
+ market_pair.base = base
20
+ market_pair.target = target
21
+ market_pair.market = Gdax::Market::NAME
22
+ market_pairs << market_pair
23
+ end
24
+ market_pairs
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -13,14 +13,28 @@ module Cryptoexchange::Exchanges
13
13
  market_pairs = []
14
14
  output['result'].each do |key, pair|
15
15
  market_pairs << Cryptoexchange::Models::MarketPair.new(
16
- base: pair['base'],
17
- target: pair['quote'],
16
+ base: symbol_from_assets(pair['base']),
17
+ target: symbol_from_assets(pair['quote']),
18
18
  market: Kraken::Market::NAME
19
19
  )
20
20
  end
21
21
 
22
22
  market_pairs
23
23
  end
24
+
25
+ private
26
+
27
+ # Custom to Kraken
28
+ ASSETS_URL = "#{Cryptoexchange::Exchanges::Kraken::Market::API_URL}/Assets"
29
+
30
+ def assets
31
+ fetch_response = HTTP.get(self.class::ASSETS_URL)
32
+ JSON.parse(fetch_response.to_s)['result']
33
+ end
34
+
35
+ def symbol_from_assets(kraken_symbol)
36
+ assets[kraken_symbol]['altname']
37
+ end
24
38
  end
25
39
  end
26
40
  end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Poloniex
3
+ class Market
4
+ NAME = 'poloniex'
5
+ API_URL = 'https://poloniex.com/public'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,51 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Poloniex
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::Poloniex::Market::API_URL}?command=returnTicker"
18
+ end
19
+
20
+ def adapt_all(output)
21
+ output.map do |pair, ticker|
22
+ base, target = pair.split('_')
23
+ market_pair = Cryptoexchange::Models::MarketPair.new(
24
+ base: base,
25
+ target: target,
26
+ market: Poloniex::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 = Poloniex::Market::NAME
38
+ ticker.last = NumericHelper.to_d(output['last'])
39
+ ticker.bid = NumericHelper.to_d(output['highestBid'])
40
+ ticker.ask = NumericHelper.to_d(output['lowestAsk'])
41
+ ticker.high = NumericHelper.to_d(output['high24hr'])
42
+ ticker.low = NumericHelper.to_d(output['low24hr'])
43
+ ticker.volume = NumericHelper.to_d(output['baseVolume'])
44
+ ticker.timestamp = Time.now.to_i
45
+ ticker.payload = output
46
+ ticker
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,27 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Poloniex
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Poloniex::Market::API_URL}?command=returnTicker"
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, ticker|
15
+ market_pair = Cryptoexchange::Models::MarketPair.new
16
+ base, target = pair.split('_')
17
+ market_pair.base = base
18
+ market_pair.target = target
19
+ market_pair.market = Poloniex::Market::NAME
20
+ market_pairs << market_pair
21
+ end
22
+ market_pairs
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yobit
3
+ class Market
4
+ NAME = 'yobit'
5
+ API_URL = 'https://yobit.net/api/3'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,40 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yobit
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::Yobit::Market::API_URL}/ticker/#{parameter}"
19
+ end
20
+
21
+ def adapt(output, market_pair)
22
+ data = output["#{market_pair.base.downcase}_#{market_pair.target.downcase}"]
23
+ ticker = Cryptoexchange::Models::Ticker.new
24
+ ticker.base = market_pair.base
25
+ ticker.target = market_pair.target
26
+ ticker.market = Yobit::Market::NAME
27
+ ticker.last = NumericHelper.to_d(data['last'])
28
+ ticker.bid = NumericHelper.to_d(data['buy'])
29
+ ticker.ask = NumericHelper.to_d(data['sell'])
30
+ ticker.high = NumericHelper.to_d(data['high'])
31
+ ticker.low = NumericHelper.to_d(data['low'])
32
+ ticker.volume = NumericHelper.to_d(data['vol_cur'])
33
+ ticker.timestamp = data['updated'].to_i
34
+ ticker.payload = data
35
+ ticker
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,27 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Yobit
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Yobit::Market::API_URL}/info"
6
+
7
+ def fetch
8
+ output = super
9
+ adapt(output)
10
+ end
11
+
12
+ def adapt(output)
13
+ market_pairs = []
14
+ output['pairs'].each do |pair, info|
15
+ market_pair = Cryptoexchange::Models::MarketPair.new
16
+ base, target = pair.split('_')
17
+ market_pair.base = base
18
+ market_pair.target = target
19
+ market_pair.market = Yobit::Market::NAME
20
+ market_pairs << market_pair
21
+ end
22
+ market_pairs
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TM Lee
@@ -185,6 +185,9 @@ files:
185
185
  - lib/cryptoexchange/exchanges/gatecoin/market.rb
186
186
  - lib/cryptoexchange/exchanges/gatecoin/services/market.rb
187
187
  - lib/cryptoexchange/exchanges/gatecoin/services/pairs.rb
188
+ - lib/cryptoexchange/exchanges/gdax/market.rb
189
+ - lib/cryptoexchange/exchanges/gdax/services/market.rb
190
+ - lib/cryptoexchange/exchanges/gdax/services/pairs.rb
188
191
  - lib/cryptoexchange/exchanges/gemini/market.rb
189
192
  - lib/cryptoexchange/exchanges/gemini/services/market.rb
190
193
  - lib/cryptoexchange/exchanges/gemini/services/pairs.rb
@@ -214,9 +217,15 @@ files:
214
217
  - lib/cryptoexchange/exchanges/okcoin/okcoin.yml
215
218
  - lib/cryptoexchange/exchanges/okcoin/services/market.rb
216
219
  - lib/cryptoexchange/exchanges/okcoin/services/pairs.rb
220
+ - lib/cryptoexchange/exchanges/poloniex/market.rb
221
+ - lib/cryptoexchange/exchanges/poloniex/services/market.rb
222
+ - lib/cryptoexchange/exchanges/poloniex/services/pairs.rb
217
223
  - lib/cryptoexchange/exchanges/quoine/market.rb
218
224
  - lib/cryptoexchange/exchanges/quoine/services/market.rb
219
225
  - lib/cryptoexchange/exchanges/quoine/services/pairs.rb
226
+ - lib/cryptoexchange/exchanges/yobit/market.rb
227
+ - lib/cryptoexchange/exchanges/yobit/services/market.rb
228
+ - lib/cryptoexchange/exchanges/yobit/services/pairs.rb
220
229
  - lib/cryptoexchange/helpers/hash_helper.rb
221
230
  - lib/cryptoexchange/helpers/numeric_helper.rb
222
231
  - lib/cryptoexchange/helpers/string_helper.rb