cryptoexchange 0.16.1 → 0.17.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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -3
  3. data/lib/cryptoexchange/exchanges/abucoins/services/trades.rb +1 -1
  4. data/lib/cryptoexchange/exchanges/acx/market.rb +8 -0
  5. data/lib/cryptoexchange/exchanges/acx/services/market.rb +40 -0
  6. data/lib/cryptoexchange/exchanges/acx/services/order_book.rb +48 -0
  7. data/lib/cryptoexchange/exchanges/acx/services/pairs.rb +24 -0
  8. data/lib/cryptoexchange/exchanges/acx/services/trades.rb +38 -0
  9. data/lib/cryptoexchange/exchanges/binance/services/order_book.rb +1 -1
  10. data/lib/cryptoexchange/exchanges/bitstamp/services/order_book.rb +44 -0
  11. data/lib/cryptoexchange/exchanges/bitstamp/services/trades.rb +32 -0
  12. data/lib/cryptoexchange/exchanges/gemini/services/trades.rb +1 -1
  13. data/lib/cryptoexchange/exchanges/huobi/services/market.rb +1 -1
  14. data/lib/cryptoexchange/exchanges/okex/market.rb +8 -0
  15. data/lib/cryptoexchange/exchanges/okex/okex.yml +43 -0
  16. data/lib/cryptoexchange/exchanges/okex/services/market.rb +40 -0
  17. data/lib/cryptoexchange/exchanges/okex/services/order_book.rb +46 -0
  18. data/lib/cryptoexchange/exchanges/okex/services/pairs.rb +24 -0
  19. data/lib/cryptoexchange/exchanges/okex/services/trades.rb +32 -0
  20. data/lib/cryptoexchange/exchanges/wex/market.rb +8 -0
  21. data/lib/cryptoexchange/exchanges/wex/services/market.rb +44 -0
  22. data/lib/cryptoexchange/exchanges/wex/services/order_book.rb +50 -0
  23. data/lib/cryptoexchange/exchanges/wex/services/pairs.rb +27 -0
  24. data/lib/cryptoexchange/exchanges/wex/services/trades.rb +38 -0
  25. data/lib/cryptoexchange/exchanges/zaif/market.rb +8 -0
  26. data/lib/cryptoexchange/exchanges/zaif/services/market.rb +38 -0
  27. data/lib/cryptoexchange/exchanges/zaif/services/order_book.rb +44 -0
  28. data/lib/cryptoexchange/exchanges/zaif/services/pairs.rb +27 -0
  29. data/lib/cryptoexchange/exchanges/zaif/services/trades.rb +32 -0
  30. data/lib/cryptoexchange/version.rb +1 -1
  31. metadata +25 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 676fe2d5dfa611487a5eee294b6c0c2d37e2f378
4
- data.tar.gz: f204c06cfd0673215b056bc0a5f32177d1d3eb8d
3
+ metadata.gz: f05ebf8131e8107046a6a7893c2407de3d563c59
4
+ data.tar.gz: 05184ce6f50078417f8fcbe62f12760df8daeb01
5
5
  SHA512:
6
- metadata.gz: 625b2d4991295688683c57d95fe078de579d8ff6869d94c7dbaded101497537cf6535f92025d0191d4afa68dfea3ca9209c05c2007e08ed1d89e53383f09c9ab
7
- data.tar.gz: a7aca272c524e8934be400fe3e9649c3ac1e7dd9995923582e34d8965f13434db9fc79ec64d21c3c27df2573ae7ca11ae2ac748a85649caf4c70c18f70547c5e
6
+ metadata.gz: e8d5a17dc883537bee6f7badb78b4c003195fd4c5a6e0caddbe25331e712934fb62e679276aa642dab99fdf8c4ea67e5c3bfb4d379dbe6eb8722b6efe35ead9e
7
+ data.tar.gz: 80be3c919cd8e0b33d1f4db18536b7e689b952b3baeaf90e7eacca0440e773c09ae0e2b4c47955dbcdfff50b7986f7818f847ee3294dbe7912699511f7e81a76
data/README.md CHANGED
@@ -25,6 +25,7 @@ Or install it yourself as:
25
25
  | Exchange | Ticker | Order Book | Trade | Account | Market List |
26
26
  | ----------------- | ------- | ---------- | ------- | ------- | ----------- |
27
27
  | Abucoins | Y | Y | Y | | Y |
28
+ | ACX | Y | Y | Y | | Y |
28
29
  | Allcoin | Y | Y | | | User-Defined|
29
30
  | ANX | Y | | | | User-Defined|
30
31
  | Bit-Z | Y | | | | Y |
@@ -37,7 +38,7 @@ Or install it yourself as:
37
38
  | Bithumb | Y | | | | Y |
38
39
  | Bitkonan | Y | | | | User-Defined|
39
40
  | Bitso | Y | | | | Y |
40
- | Bitstamp | Y | | | | User-Defined|
41
+ | Bitstamp | Y | Y | Y | | User-Defined|
41
42
  | Bittrex | Y | | | | Y |
42
43
  | Bleutrade | Y | | | | Y |
43
44
  | BTC-e | | | | | |
@@ -73,11 +74,13 @@ Or install it yourself as:
73
74
  | Liqui | Y | | | | Y |
74
75
  | LiteBit.eu | Y | | | | Y |
75
76
  | Livecoin | Y | | | | Y |
77
+ | LocalBitcoins | Y | Y | Y | | Y |
76
78
  | Luno | Y | | | | Y |
77
79
  | MercadoBitcoin | Y | | | | User-Defined|
78
80
  | Mercatox | Y | N | N | N | Y |
79
81
  | Nova Exchange | Y | | | | Y |
80
82
  | OKCoin | Y | | | | User-Defined|
83
+ | OKEx | Y | Y | Y | | User-Defined|
81
84
  | Poloniex | Y | | | | Y |
82
85
  | Qryptos | Y | | | | Y |
83
86
  | QuadrigaCX | Y | | | | User-Defined|
@@ -89,9 +92,11 @@ Or install it yourself as:
89
92
  | TuxExchange | Y | | | | Y |
90
93
  | Unocoin | | | | | |
91
94
  | Viabtc | Y | | | | User-Defined|
95
+ | Wex | Y | Y | Y | | Y |
92
96
  | Yobit | Y | | | | Y |
93
97
  | Yuanbao | Y | | | | User-Defined|
94
98
  | Yunbi | Y | | | | Y |
99
+ | Zaif | Y | Y | Y | | Y |
95
100
 
96
101
  ## Usage
97
102
 
@@ -111,7 +116,7 @@ Or install it yourself as:
111
116
  ### Query the Ticker API
112
117
  ```
113
118
  pair = client.pairs('bitflyer').first
114
- ticker = client.ticker(pairs.last)
119
+ ticker = client.ticker(pair)
115
120
  ticker.base
116
121
  ticker.target
117
122
  ticker.last
@@ -121,7 +126,7 @@ Or install it yourself as:
121
126
  ```
122
127
  # Check if exchange has support for OrderBook
123
128
  pair = client.pairs('bitflyer').first
124
- order_book = client.order_book(pairs.last)
129
+ order_book = client.order_book(pair)
125
130
  order_book.base
126
131
  order_book.target
127
132
  order_book.bids
@@ -20,7 +20,7 @@ module Cryptoexchange::Exchanges
20
20
  tr.type = trade['side']
21
21
  tr.price = trade['price']
22
22
  tr.amount = trade['size']
23
- tr.timestamp = Time.now.to_i
23
+ tr.timestamp = Time.parse(trade['time']).to_i
24
24
  tr.payload = trade
25
25
  tr.market = Abucoins::Market::NAME
26
26
  tr
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Acx
3
+ class Market
4
+ NAME = 'acx'
5
+ API_URL = 'https://acx.io/api/v2'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,40 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Acx
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::Acx::Market::API_URL}/tickers/#{base}#{target}.json"
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 = Acx::Market::NAME
27
+ ticker.ask = NumericHelper.to_d(output['ticker']['buy'])
28
+ ticker.bid = NumericHelper.to_d(output['ticker']['sell'])
29
+ ticker.high = NumericHelper.to_d(output['ticker']['high'])
30
+ ticker.low = NumericHelper.to_d(output['ticker']['low'])
31
+ ticker.last = NumericHelper.to_d(output['ticker']['last'])
32
+ ticker.volume = NumericHelper.to_d(output['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,48 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Acx
3
+ module Services
4
+ class OrderBook < 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::Acx::Market::API_URL}/order_book.json?market=#{market_pair.base.downcase}#{market_pair.target.downcase}"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ order_book = Cryptoexchange::Models::OrderBook.new
22
+
23
+ order_book.base = market_pair.base
24
+ order_book.target = market_pair.target
25
+ order_book.market = Acx::Market::NAME
26
+ order_book.asks = adapt_orders output['asks']
27
+ order_book.bids = adapt_orders output['bids']
28
+ order_book.timestamp = Time.now.to_i
29
+ order_book.payload = output
30
+ order_book
31
+ end
32
+
33
+ def adapt_orders(orders)
34
+ orders.collect do |order_entry|
35
+ price = order_entry['price']
36
+ amount = order_entry['volume']
37
+ timestamp = DateTime.iso8601(order_entry['created_at'])
38
+ .to_time
39
+ .to_i
40
+ Cryptoexchange::Models::Order.new(price: price,
41
+ amount: amount,
42
+ timestamp: timestamp)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,24 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Acx
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Acx::Market::API_URL}/markets.json"
6
+
7
+ def fetch
8
+ output = super
9
+ adapt(output)
10
+ end
11
+
12
+ def adapt(output)
13
+ output.map do |pair|
14
+ Cryptoexchange::Models::MarketPair.new(
15
+ base: pair['base_unit'],
16
+ target: pair['quote_unit'],
17
+ market: Acx::Market::NAME
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,38 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Acx
3
+ module Services
4
+ class Trades < Cryptoexchange::Services::Market
5
+ def fetch(market_pair)
6
+ output = super(ticker_url(market_pair))
7
+ adapt(output, market_pair)
8
+ end
9
+
10
+ def ticker_url(market_pair)
11
+ base = market_pair.base.downcase
12
+ target = market_pair.target.downcase
13
+ "#{Cryptoexchange::Exchanges::Acx::Market::API_URL}/trades.json?market=#{base}#{target}"
14
+ end
15
+
16
+ def adapt(output, market_pair)
17
+ output.collect do |trade|
18
+ tr = Cryptoexchange::Models::Trade.new
19
+ tr.trade_id = trade['id']
20
+ tr.base = market_pair.base
21
+ tr.target = market_pair.target
22
+ tr.price = trade['volume']
23
+ tr.amount = trade['funds']
24
+
25
+ timestamp = DateTime.iso8601(trade['created_at'])
26
+ .to_time
27
+ .to_i
28
+
29
+ tr.timestamp = timestamp
30
+ tr.payload = trade
31
+ tr.market = Acx::Market::NAME
32
+ tr
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -38,7 +38,7 @@ module Cryptoexchange::Exchanges
38
38
  Cryptoexchange::Models::Order.new(price: NumericHelper.to_d(order_entry[0]),
39
39
  amount: NumericHelper.to_d(order_entry[1]),
40
40
  timestamp: timestamp)
41
- end
41
+ end
42
42
  end
43
43
  end
44
44
  end
@@ -0,0 +1,44 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Bitstamp
3
+ module Services
4
+ class OrderBook < 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::Bitstamp::Market::API_URL}/order_book/#{market_pair.base}#{market_pair.target}"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ order_book = Cryptoexchange::Models::OrderBook.new
22
+
23
+ order_book.base = market_pair.base
24
+ order_book.target = market_pair.target
25
+ order_book.market = Bitstamp::Market::NAME
26
+ order_book.asks = adapt_orders output['asks']
27
+ order_book.bids = adapt_orders output['bids']
28
+ order_book.timestamp = Time.now.to_i
29
+ order_book.payload = output
30
+ order_book
31
+ end
32
+
33
+ def adapt_orders(orders)
34
+ orders.collect do |order_entry|
35
+ price, amount = order_entry
36
+ Cryptoexchange::Models::Order.new(price: price,
37
+ amount: amount,
38
+ timestamp: Time.now.to_i)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,32 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Bitstamp
3
+ module Services
4
+ class Trades < Cryptoexchange::Services::Market
5
+ def fetch(market_pair)
6
+ output = super(ticker_url(market_pair))
7
+ adapt(output, market_pair)
8
+ end
9
+
10
+ def ticker_url(market_pair)
11
+ "#{Cryptoexchange::Exchanges::Bitstamp::Market::API_URL}/transactions/#{market_pair.base.downcase}#{market_pair.target.downcase}/"
12
+ end
13
+
14
+ def adapt(output, market_pair)
15
+ output.collect do |trade|
16
+ tr = Cryptoexchange::Models::Trade.new
17
+ tr.trade_id = trade['tid']
18
+ tr.base = market_pair.base
19
+ tr.target = market_pair.target
20
+ tr.type = trade['type'] == '0' ? 'buy' : 'sell'
21
+ tr.price = trade['price']
22
+ tr.amount = trade['amount']
23
+ tr.timestamp = trade['date'].to_i
24
+ tr.payload = trade
25
+ tr.market = Bitstamp::Market::NAME
26
+ tr
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -20,7 +20,7 @@ module Cryptoexchange::Exchanges
20
20
  tr.type = trade['type']
21
21
  tr.price = trade['price']
22
22
  tr.amount = trade['amount']
23
- tr.timestamp = Time.now.to_i
23
+ tr.timestamp = trade['timestamp'].to_i
24
24
  tr.payload = trade
25
25
  tr.market = Gemini::Market::NAME
26
26
  tr
@@ -40,7 +40,7 @@ module Cryptoexchange::Exchanges
40
40
  ticker.high = NumericHelper.to_d(market['high'])
41
41
  ticker.low = NumericHelper.to_d(market['low'])
42
42
  ticker.volume = NumericHelper.to_d(market['amount'])
43
- ticker.timestamp = market['ts'].to_i / 1000
43
+ ticker.timestamp = output['ts'].to_i / 1000
44
44
  ticker.payload = market
45
45
  ticker
46
46
  end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Okex
3
+ class Market
4
+ NAME = 'okex'
5
+ API_URL = 'https://www.okex.com/api/v1'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,43 @@
1
+ :pairs:
2
+ - :base: LTC
3
+ :target: BTC
4
+ - :base: ETH
5
+ :target: BTC
6
+ - :base: ETC
7
+ :target: BTC
8
+ - :base: BCH
9
+ :target: BTC
10
+ - :base: BTC
11
+ :target: USDT
12
+ - :base: ETH
13
+ :target: USDT
14
+ - :base: LTC
15
+ :target: USDT
16
+ - :base: ETC
17
+ :target: USDT
18
+ - :base: BCH
19
+ :target: USDT
20
+ - :base: ETC
21
+ :target: ETH
22
+ - :base: BT1
23
+ :target: BTC
24
+ - :base: BT2
25
+ :target: BTC
26
+ - :base: BTG
27
+ :target: BTC
28
+ - :base: QTUM
29
+ :target: BTC
30
+ - :base: HSR
31
+ :target: BTC
32
+ - :base: NEO
33
+ :target: BTC
34
+ - :base: GAS
35
+ :target: BTC
36
+ - :base: QTUM
37
+ :target: USDT
38
+ - :base: HSR
39
+ :target: USDT
40
+ - :base: NEO
41
+ :target: USDT
42
+ - :base: GAS
43
+ :target: USDT
@@ -0,0 +1,40 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Okex
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::Okex::Market::API_URL}/ticker.do?symbol=#{base}_#{target}"
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 = Okex::Market::NAME
27
+ ticker.ask = NumericHelper.to_d(output['ticker']['sell'])
28
+ ticker.bid = NumericHelper.to_d(output['ticker']['buy'])
29
+ ticker.last = NumericHelper.to_d(output['ticker']['last'])
30
+ ticker.high = NumericHelper.to_d(output['ticker']['high'])
31
+ ticker.low = NumericHelper.to_d(output['ticker']['low'])
32
+ ticker.volume = NumericHelper.to_d(output['ticker']['vol'])
33
+ ticker.timestamp = output['date'].to_i
34
+ ticker.payload = output
35
+ ticker
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,46 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Okex
3
+ module Services
4
+ class OrderBook < 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::Okex::Market::API_URL}/depth.do?symbol=#{market_pair.base.downcase}_#{market_pair.target.downcase}"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ order_book = Cryptoexchange::Models::OrderBook.new
22
+ timestamp = Time.now.to_i
23
+
24
+ order_book.base = market_pair.base
25
+ order_book.target = market_pair.target
26
+ order_book.market = Okex::Market::NAME
27
+ order_book.asks = adapt_orders(output['asks'], timestamp)
28
+ order_book.bids = adapt_orders(output['bids'], timestamp)
29
+ order_book.timestamp = Time.now.to_i
30
+ order_book.payload = output
31
+ order_book
32
+ end
33
+
34
+ def adapt_orders(orders, timestamp)
35
+ orders.collect do |order_entry|
36
+ price = order_entry[0]
37
+ amount = order_entry[1]
38
+ Cryptoexchange::Models::Order.new(price: price,
39
+ amount: amount,
40
+ timestamp: timestamp)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,24 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Okex
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
+ market_pairs = []
12
+ output.each do |pair|
13
+ market_pairs << Cryptoexchange::Models::MarketPair.new(
14
+ base: pair[:base],
15
+ target: pair[:target],
16
+ market: Okex::Market::NAME
17
+ )
18
+ end
19
+ market_pairs
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Okex
3
+ module Services
4
+ class Trades < Cryptoexchange::Services::Market
5
+ def fetch(market_pair)
6
+ output = super(ticker_url(market_pair))
7
+ adapt(output, market_pair)
8
+ end
9
+
10
+ def ticker_url(market_pair)
11
+ "#{Cryptoexchange::Exchanges::Okex::Market::API_URL}/trades.do?symbol=#{market_pair.base.downcase}_#{market_pair.target.downcase}"
12
+ end
13
+
14
+ def adapt(output, market_pair)
15
+ output.collect do |trade|
16
+ tr = Cryptoexchange::Models::Trade.new
17
+ tr.trade_id = trade['tid']
18
+ tr.base = market_pair.base
19
+ tr.target = market_pair.target
20
+ tr.type = trade['type']
21
+ tr.price = trade['price']
22
+ tr.amount = trade['amount']
23
+ tr.timestamp = trade['date'].to_i
24
+ tr.payload = trade
25
+ tr.market = Okex::Market::NAME
26
+ tr
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Wex
3
+ class Market
4
+ NAME = 'wex'
5
+ API_URL = 'https://wex.nz/api/3'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,44 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Wex
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
+ "#{Cryptoexchange::Exchanges::Wex::Market::API_URL}/ticker/#{symbol(market_pair)}"
18
+ end
19
+
20
+ def symbol(market_pair)
21
+ "#{market_pair.base.downcase}_#{market_pair.target.downcase}"
22
+ end
23
+
24
+ def adapt(market_pair, output)
25
+ data = output[symbol(market_pair)]
26
+
27
+ ticker = Cryptoexchange::Models::Ticker.new
28
+ ticker.base = market_pair.base
29
+ ticker.target = market_pair.target
30
+ ticker.market = Wex::Market::NAME
31
+ ticker.ask = NumericHelper.to_d(data['sell'])
32
+ ticker.bid = NumericHelper.to_d(data['buy'])
33
+ ticker.last = NumericHelper.to_d(data['last'])
34
+ ticker.high = NumericHelper.to_d(data['high'])
35
+ ticker.low = NumericHelper.to_d(data['low'])
36
+ ticker.volume = NumericHelper.to_d(data['vol_cur'])
37
+ ticker.timestamp = data['updated'].to_i
38
+ ticker.payload = output
39
+ ticker
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,50 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Wex
3
+ module Services
4
+ class OrderBook < 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::Wex::Market::API_URL}/depth/#{symbol(market_pair)}"
18
+ end
19
+
20
+ def symbol(market_pair)
21
+ "#{market_pair.base.downcase}_#{market_pair.target.downcase}"
22
+ end
23
+
24
+ def adapt(output, market_pair)
25
+ data = output[symbol(market_pair)]
26
+ order_book = Cryptoexchange::Models::OrderBook.new
27
+
28
+ order_book.base = market_pair.base
29
+ order_book.target = market_pair.target
30
+ order_book.market = Wex::Market::NAME
31
+ order_book.asks = adapt_orders data['asks']
32
+ order_book.bids = adapt_orders data['bids']
33
+ order_book.timestamp = Time.now.to_i
34
+ order_book.payload = output
35
+ order_book
36
+ end
37
+
38
+ def adapt_orders(orders)
39
+ orders.collect do |order_entry|
40
+ price = order_entry[0]
41
+ amount = order_entry[1]
42
+ Cryptoexchange::Models::Order.new(price: price,
43
+ amount: amount,
44
+ timestamp: Time.now.to_i)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,27 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Wex
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Wex::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_key do |pair|
15
+ base, target = pair.split('_')
16
+ market_pairs << Cryptoexchange::Models::MarketPair.new(
17
+ base: base,
18
+ target: target,
19
+ market: Wex::Market::NAME
20
+ )
21
+ end
22
+ market_pairs
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Wex
3
+ module Services
4
+ class Trades < Cryptoexchange::Services::Market
5
+ def fetch(market_pair)
6
+ output = super(ticker_url(market_pair))
7
+ adapt(output, market_pair)
8
+ end
9
+
10
+ def ticker_url(market_pair)
11
+ "#{Cryptoexchange::Exchanges::Wex::Market::API_URL}/trades/#{symbol(market_pair)}"
12
+ end
13
+
14
+ def symbol(market_pair)
15
+ "#{market_pair.base.downcase}_#{market_pair.target.downcase}"
16
+ end
17
+
18
+ def adapt(output, market_pair)
19
+ data = output[symbol(market_pair)]
20
+
21
+ data.collect do |trade|
22
+ tr = Cryptoexchange::Models::Trade.new
23
+ tr.trade_id = trade['tid']
24
+ tr.base = market_pair.base
25
+ tr.target = market_pair.target
26
+ tr.type = trade['type']
27
+ tr.price = trade['price']
28
+ tr.amount = trade['amount']
29
+ tr.timestamp = trade[:timestamp].to_i
30
+ tr.payload = trade
31
+ tr.market = Wex::Market::NAME
32
+ tr
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Zaif
3
+ class Market
4
+ NAME = 'zaif'
5
+ API_URL = 'https://api.zaif.jp/api/1'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Zaif
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
+ "#{Cryptoexchange::Exchanges::Zaif::Market::API_URL}/ticker/#{market_pair.base.downcase}_#{market_pair.target.downcase}"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ ticker = Cryptoexchange::Models::Ticker.new
22
+ ticker.base = market_pair.base
23
+ ticker.target = market_pair.target
24
+ ticker.market = Zaif::Market::NAME
25
+ ticker.last = NumericHelper.to_d(output['last'])
26
+ ticker.bid = NumericHelper.to_d(output['bid'])
27
+ ticker.ask = NumericHelper.to_d(output['ask'])
28
+ ticker.high = NumericHelper.to_d(output['high'])
29
+ ticker.low = NumericHelper.to_d(output['low'])
30
+ ticker.volume = NumericHelper.to_d(output['volume'])
31
+ ticker.timestamp = DateTime.now.to_time.to_i
32
+ ticker.payload = output
33
+ ticker
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,44 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Zaif
3
+ module Services
4
+ class OrderBook < 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::Zaif::Market::API_URL}/depth/#{market_pair.base.downcase}_#{market_pair.target.downcase}"
18
+ end
19
+
20
+ def adapt(output, market_pair)
21
+ order_book = Cryptoexchange::Models::OrderBook.new
22
+
23
+ order_book.base = market_pair.base
24
+ order_book.target = market_pair.target
25
+ order_book.market = Zaif::Market::NAME
26
+ order_book.asks = adapt_orders output['asks']
27
+ order_book.bids = adapt_orders output['bids']
28
+ order_book.timestamp = Time.now.to_i
29
+ order_book.payload = output
30
+ order_book
31
+ end
32
+
33
+ def adapt_orders(orders)
34
+ orders.collect do |order_entry|
35
+ price, amount = order_entry
36
+ Cryptoexchange::Models::Order.new(price: price,
37
+ amount: amount,
38
+ timestamp: nil)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,27 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Zaif
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Zaif::Market::API_URL}/currency_pairs/all"
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['currency_pair'].split('_')
17
+ market_pair.base = base
18
+ market_pair.target = target
19
+ market_pair.market = Zaif::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,32 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Zaif
3
+ module Services
4
+ class Trades < Cryptoexchange::Services::Market
5
+ def fetch(market_pair)
6
+ output = super(ticker_url(market_pair))
7
+ adapt(output, market_pair)
8
+ end
9
+
10
+ def ticker_url(market_pair)
11
+ "#{Cryptoexchange::Exchanges::Zaif::Market::API_URL}/trades/#{market_pair.base.downcase}_#{market_pair.target.downcase}"
12
+ end
13
+
14
+ def adapt(output, market_pair)
15
+ output.collect do |trade|
16
+ tr = Cryptoexchange::Models::Trade.new
17
+ tr.trade_id = trade['tid']
18
+ tr.base = market_pair.base
19
+ tr.target = market_pair.target
20
+ tr.type = trade['trade_type'] == 'bid' ? 'buy' : 'sell'
21
+ tr.price = trade['price']
22
+ tr.amount = trade['amount']
23
+ tr.timestamp = trade['date']
24
+ tr.payload = trade
25
+ tr.market = Zaif::Market::NAME
26
+ tr
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.16.1"
2
+ VERSION = "0.17.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.16.1
4
+ version: 0.17.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-11-27 00:00:00.000000000 Z
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,11 @@ files:
163
163
  - lib/cryptoexchange/exchanges/abucoins/services/order_book.rb
164
164
  - lib/cryptoexchange/exchanges/abucoins/services/pairs.rb
165
165
  - lib/cryptoexchange/exchanges/abucoins/services/trades.rb
166
+ - lib/cryptoexchange/exchanges/acx/market.rb
167
+ - lib/cryptoexchange/exchanges/acx/services/market.rb
168
+ - lib/cryptoexchange/exchanges/acx/services/order_book.rb
169
+ - lib/cryptoexchange/exchanges/acx/services/pairs.rb
170
+ - lib/cryptoexchange/exchanges/acx/services/trades.rb
166
171
  - lib/cryptoexchange/exchanges/allcoin/allcoin.yml
167
172
  - lib/cryptoexchange/exchanges/allcoin/market.rb
168
173
  - lib/cryptoexchange/exchanges/allcoin/services/market.rb
@@ -209,7 +214,9 @@ files:
209
214
  - lib/cryptoexchange/exchanges/bitstamp/bitstamp.yml
210
215
  - lib/cryptoexchange/exchanges/bitstamp/market.rb
211
216
  - lib/cryptoexchange/exchanges/bitstamp/services/market.rb
217
+ - lib/cryptoexchange/exchanges/bitstamp/services/order_book.rb
212
218
  - lib/cryptoexchange/exchanges/bitstamp/services/pairs.rb
219
+ - lib/cryptoexchange/exchanges/bitstamp/services/trades.rb
213
220
  - lib/cryptoexchange/exchanges/bittrex/market.rb
214
221
  - lib/cryptoexchange/exchanges/bittrex/services/market.rb
215
222
  - lib/cryptoexchange/exchanges/bittrex/services/pairs.rb
@@ -338,6 +345,12 @@ files:
338
345
  - lib/cryptoexchange/exchanges/okcoin/okcoin.yml
339
346
  - lib/cryptoexchange/exchanges/okcoin/services/market.rb
340
347
  - lib/cryptoexchange/exchanges/okcoin/services/pairs.rb
348
+ - lib/cryptoexchange/exchanges/okex/market.rb
349
+ - lib/cryptoexchange/exchanges/okex/okex.yml
350
+ - lib/cryptoexchange/exchanges/okex/services/market.rb
351
+ - lib/cryptoexchange/exchanges/okex/services/order_book.rb
352
+ - lib/cryptoexchange/exchanges/okex/services/pairs.rb
353
+ - lib/cryptoexchange/exchanges/okex/services/trades.rb
341
354
  - lib/cryptoexchange/exchanges/poloniex/market.rb
342
355
  - lib/cryptoexchange/exchanges/poloniex/services/market.rb
343
356
  - lib/cryptoexchange/exchanges/poloniex/services/pairs.rb
@@ -370,6 +383,11 @@ files:
370
383
  - lib/cryptoexchange/exchanges/viabtc/services/market.rb
371
384
  - lib/cryptoexchange/exchanges/viabtc/services/pairs.rb
372
385
  - lib/cryptoexchange/exchanges/viabtc/viabtc.yml
386
+ - lib/cryptoexchange/exchanges/wex/market.rb
387
+ - lib/cryptoexchange/exchanges/wex/services/market.rb
388
+ - lib/cryptoexchange/exchanges/wex/services/order_book.rb
389
+ - lib/cryptoexchange/exchanges/wex/services/pairs.rb
390
+ - lib/cryptoexchange/exchanges/wex/services/trades.rb
373
391
  - lib/cryptoexchange/exchanges/yobit/market.rb
374
392
  - lib/cryptoexchange/exchanges/yobit/services/market.rb
375
393
  - lib/cryptoexchange/exchanges/yobit/services/pairs.rb
@@ -380,6 +398,11 @@ files:
380
398
  - lib/cryptoexchange/exchanges/yunbi/market.rb
381
399
  - lib/cryptoexchange/exchanges/yunbi/services/market.rb
382
400
  - lib/cryptoexchange/exchanges/yunbi/services/pairs.rb
401
+ - lib/cryptoexchange/exchanges/zaif/market.rb
402
+ - lib/cryptoexchange/exchanges/zaif/services/market.rb
403
+ - lib/cryptoexchange/exchanges/zaif/services/order_book.rb
404
+ - lib/cryptoexchange/exchanges/zaif/services/pairs.rb
405
+ - lib/cryptoexchange/exchanges/zaif/services/trades.rb
383
406
  - lib/cryptoexchange/helpers/hash_helper.rb
384
407
  - lib/cryptoexchange/helpers/numeric_helper.rb
385
408
  - lib/cryptoexchange/helpers/string_helper.rb