cryptoexchange 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/lib/cryptoexchange/client.rb +15 -35
- data/lib/cryptoexchange/error.rb +3 -0
- data/lib/cryptoexchange/exchanges/acx/services/market.rb +2 -2
- data/lib/cryptoexchange/exchanges/bibox/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bibox/services/market.rb +42 -0
- data/lib/cryptoexchange/exchanges/bibox/services/order_book.rb +47 -0
- data/lib/cryptoexchange/exchanges/bibox/services/pairs.rb +24 -0
- data/lib/cryptoexchange/exchanges/bibox/services/trades.rb +34 -0
- data/lib/cryptoexchange/exchanges/cobinhood/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/cobinhood/services/market.rb +41 -0
- data/lib/cryptoexchange/exchanges/cobinhood/services/order_book.rb +44 -0
- data/lib/cryptoexchange/exchanges/cobinhood/services/pairs.rb +24 -0
- data/lib/cryptoexchange/exchanges/coinnest/coinnest.yml +47 -0
- data/lib/cryptoexchange/exchanges/coinnest/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/coinnest/services/market.rb +39 -0
- data/lib/cryptoexchange/exchanges/coinnest/services/order_book.rb +45 -0
- data/lib/cryptoexchange/exchanges/coinnest/services/pairs.rb +23 -0
- data/lib/cryptoexchange/exchanges/coinnest/services/trades.rb +32 -0
- data/lib/cryptoexchange/exchanges/cryptopia/services/order_book.rb +47 -0
- data/lib/cryptoexchange/exchanges/cryptopia/services/trades.rb +34 -0
- data/lib/cryptoexchange/exchanges/hksy/hksy.yml +69 -0
- data/lib/cryptoexchange/exchanges/hksy/market.rb +9 -0
- data/lib/cryptoexchange/exchanges/hksy/services/market.rb +42 -0
- data/lib/cryptoexchange/exchanges/hksy/services/pairs.rb +21 -0
- data/lib/cryptoexchange/exchanges/hksy/services/trades.rb +34 -0
- data/lib/cryptoexchange/exchanges/k_kex/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/k_kex/services/market.rb +41 -0
- data/lib/cryptoexchange/exchanges/k_kex/services/order_book.rb +45 -0
- data/lib/cryptoexchange/exchanges/k_kex/services/pairs.rb +24 -0
- data/lib/cryptoexchange/exchanges/k_kex/services/trades.rb +32 -0
- data/lib/cryptoexchange/exchanges/trade_satoshi/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/trade_satoshi/services/market.rb +65 -0
- data/lib/cryptoexchange/exchanges/trade_satoshi/services/pairs.rb +27 -0
- data/lib/cryptoexchange/services/market.rb +16 -2
- data/lib/cryptoexchange/services/pairs.rb +16 -2
- data/lib/cryptoexchange/version.rb +1 -1
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54e0fe4ad10dc783fbb17f51b123e1340a26df7
|
4
|
+
data.tar.gz: db28b4cf0d169f52cede566a47a8ed4546acf62e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bac8dcf7d4e3c69532e02325fd9a1b568cdf73ffd85a031662d2b24bff334acb6be07a36be65684913728c06f0b3ac919ff75e913e7bd018d07d647ffbfd8cb
|
7
|
+
data.tar.gz: acc44a0b78bd3aa84456602fb35bc0a29de002f3fc04a437522c0d75ef491f67337681df9c7072c46555a5b8ac3b07234ec83878fcb2441a15e7ce93146d4e56
|
data/README.md
CHANGED
@@ -28,8 +28,9 @@ Or install it yourself as:
|
|
28
28
|
| ACX | Y | Y | Y | | Y |
|
29
29
|
| Allcoin | Y | Y | | | User-Defined|
|
30
30
|
| ANX | Y | | | | User-Defined|
|
31
|
+
| Bibox | Y | Y | Y | | Y |
|
31
32
|
| Bit-Z | Y | | | | Y |
|
32
|
-
| Binance | Y | Y | | |
|
33
|
+
| Binance | Y | Y | | | Y |
|
33
34
|
| Bitbay | Y | | | | User-Defined|
|
34
35
|
| Bitcoin Indonesia | Y | | | | User-Defined|
|
35
36
|
| Bitconnect | Y | | | | Y |
|
@@ -50,14 +51,16 @@ Or install it yourself as:
|
|
50
51
|
| Cex | Y | Y | Y | | Y |
|
51
52
|
| CCex | Y | | | | Y |
|
52
53
|
| CHBTC | Y | | | | User-Defined|
|
54
|
+
| Cobinhood | Y | Y | | | Y |
|
53
55
|
| Coincheck | Y | | | | User-Defined|
|
54
56
|
| CoinExchange | Y | | | | Y |
|
55
57
|
| Coinmate | Y | Y | | | User-Defined|
|
58
|
+
| Coinnest | Y | Y | Y | | User-Defined|
|
56
59
|
| Coinone | Y | | | | Y |
|
57
60
|
| CoinsMarkets | Y | | | | Y |
|
58
61
|
| COSS | Y | | | | Y |
|
59
62
|
| CryptoBridge | Y | | | | Y |
|
60
|
-
| Cryptopia | Y |
|
63
|
+
| Cryptopia | Y | Y | Y | | Y |
|
61
64
|
| EtherDelta | Y | | | | Y |
|
62
65
|
| Exmo | Y | Y | Y | | Y |
|
63
66
|
| Gate | Y | Y | Y | | Y |
|
@@ -65,8 +68,10 @@ Or install it yourself as:
|
|
65
68
|
| GDAX | Y | | | | Y |
|
66
69
|
| Gemini | Y | Y | Y | | Y |
|
67
70
|
| HitBTC | Y | | | | Y |
|
71
|
+
| Hksy | Y | | Y | | User-Defined|
|
68
72
|
| Huobi | Y | | | | Y |
|
69
73
|
| Itbit | Y | | | | User-Defined|
|
74
|
+
| KKex | Y | Y | Y | | Y |
|
70
75
|
| Jubi | Y | | | | Y |
|
71
76
|
| Korbit | Y | | | | User-Defined|
|
72
77
|
| Kraken | Y | | | | Y |
|
@@ -92,6 +97,7 @@ Or install it yourself as:
|
|
92
97
|
| SZZC | Y | | | | Y |
|
93
98
|
| The Rock Trading | Y | | | | Y |
|
94
99
|
| Tidex | Y | | | | Y |
|
100
|
+
| Trade Satoshi | Y | | | | Y |
|
95
101
|
| TuxExchange | Y | | | | Y |
|
96
102
|
| Unocoin | | | | | |
|
97
103
|
| Viabtc | Y | | | | User-Defined|
|
@@ -5,46 +5,26 @@ module Cryptoexchange
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def pairs(exchange)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
pairs_object.fetch
|
13
|
-
rescue HTTP::ConnectionError => e
|
14
|
-
raise Cryptoexchange::HttpConnectionError, e
|
15
|
-
rescue HTTP::TimeoutError => e
|
16
|
-
raise Cryptoexchange::HttpTimeoutError, e
|
17
|
-
rescue JSON::ParserError => e
|
18
|
-
raise Cryptoexchange::JsonParseError, e
|
19
|
-
rescue TypeError => e
|
20
|
-
raise Cryptoexchange::TypeFormatError, e
|
21
|
-
end
|
8
|
+
pairs_classname = "Cryptoexchange::Exchanges::#{StringHelper.camelize(exchange)}::Services::Pairs"
|
9
|
+
pairs_class = Object.const_get(pairs_classname)
|
10
|
+
pairs_object = pairs_class.new
|
11
|
+
pairs_object.fetch
|
22
12
|
end
|
23
13
|
|
24
14
|
def ticker(market_pair)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
market = market_class.new
|
15
|
+
exchange = market_pair.market
|
16
|
+
market_classname = "Cryptoexchange::Exchanges::#{StringHelper.camelize(exchange)}::Services::Market"
|
17
|
+
market_class = Object.const_get(market_classname)
|
18
|
+
market = market_class.new
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
20
|
+
if market_class.supports_individual_ticker_query?
|
21
|
+
market.fetch(market_pair)
|
22
|
+
else
|
23
|
+
tickers = market.fetch
|
24
|
+
tickers.find do |t|
|
25
|
+
t.base.casecmp(market_pair.base) == 0 &&
|
26
|
+
t.target.casecmp(market_pair.target) == 0
|
39
27
|
end
|
40
|
-
rescue HTTP::ConnectionError => e
|
41
|
-
raise Cryptoexchange::HttpConnectionError, e
|
42
|
-
rescue HTTP::TimeoutError => e
|
43
|
-
raise Cryptoexchange::HttpTimeoutError, e
|
44
|
-
rescue JSON::ParserError => e
|
45
|
-
raise Cryptoexchange::JsonParseError, e
|
46
|
-
rescue TypeError => e
|
47
|
-
raise Cryptoexchange::TypeFormatError, e
|
48
28
|
end
|
49
29
|
end
|
50
30
|
|
data/lib/cryptoexchange/error.rb
CHANGED
@@ -24,8 +24,8 @@ module Cryptoexchange::Exchanges
|
|
24
24
|
ticker.base = market_pair.base
|
25
25
|
ticker.target = market_pair.target
|
26
26
|
ticker.market = Acx::Market::NAME
|
27
|
-
ticker.ask = NumericHelper.to_d(output['ticker']['
|
28
|
-
ticker.bid = NumericHelper.to_d(output['ticker']['
|
27
|
+
ticker.ask = NumericHelper.to_d(output['ticker']['sell'])
|
28
|
+
ticker.bid = NumericHelper.to_d(output['ticker']['buy'])
|
29
29
|
ticker.high = NumericHelper.to_d(output['ticker']['high'])
|
30
30
|
ticker.low = NumericHelper.to_d(output['ticker']['low'])
|
31
31
|
ticker.last = NumericHelper.to_d(output['ticker']['last'])
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bibox
|
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
|
18
|
+
target = market_pair.target
|
19
|
+
"#{Cryptoexchange::Exchanges::Bibox::Market::API_URL}/mdata?cmd=ticker&pair=#{base}_#{target}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def adapt(output, market_pair)
|
23
|
+
market = output['result']
|
24
|
+
ticker = Cryptoexchange::Models::Ticker.new
|
25
|
+
|
26
|
+
ticker.base = market_pair.base
|
27
|
+
ticker.target = market_pair.target
|
28
|
+
ticker.market = Bibox::Market::NAME
|
29
|
+
ticker.ask = NumericHelper.to_d(market['sell'])
|
30
|
+
ticker.bid = NumericHelper.to_d(market['buy'])
|
31
|
+
ticker.last = NumericHelper.to_d(market['last'])
|
32
|
+
ticker.high = NumericHelper.to_d(market['high'])
|
33
|
+
ticker.low = NumericHelper.to_d(market['low'])
|
34
|
+
ticker.volume = NumericHelper.to_d(market['vol'])
|
35
|
+
ticker.timestamp = market['timestamp'].to_i / 1000
|
36
|
+
ticker.payload = output
|
37
|
+
ticker
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bibox
|
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
|
+
base = market_pair.base
|
18
|
+
target = market_pair.target
|
19
|
+
"#{Cryptoexchange::Exchanges::Bibox::Market::API_URL}/mdata?cmd=depth&pair=#{base}_#{target}&size=15"
|
20
|
+
end
|
21
|
+
|
22
|
+
def adapt(output, market_pair)
|
23
|
+
order_book = Cryptoexchange::Models::OrderBook.new
|
24
|
+
timestamp = Time.now.to_i
|
25
|
+
depth = output['result']
|
26
|
+
|
27
|
+
order_book.base = market_pair.base
|
28
|
+
order_book.target = market_pair.target
|
29
|
+
order_book.market = Bibox::Market::NAME
|
30
|
+
order_book.asks = adapt_orders depth['asks']
|
31
|
+
order_book.bids = adapt_orders depth['bids']
|
32
|
+
order_book.timestamp = timestamp
|
33
|
+
order_book.payload = depth
|
34
|
+
order_book
|
35
|
+
end
|
36
|
+
|
37
|
+
def adapt_orders(orders)
|
38
|
+
orders.collect do |order_entry|
|
39
|
+
Cryptoexchange::Models::Order.new(price: order_entry['price'],
|
40
|
+
amount: order_entry['volume'],
|
41
|
+
timestamp: nil)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bibox
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
PAIRS_URL = "#{Cryptoexchange::Exchanges::Bibox::Market::API_URL}/mdata?cmd=marketAll"
|
6
|
+
|
7
|
+
def fetch
|
8
|
+
output = super
|
9
|
+
adapt(output)
|
10
|
+
end
|
11
|
+
|
12
|
+
def adapt(output)
|
13
|
+
output['result'].map do |pair|
|
14
|
+
Cryptoexchange::Models::MarketPair.new(
|
15
|
+
base: pair['coin_symbol'],
|
16
|
+
target: pair['currency_symbol'],
|
17
|
+
market: Bibox::Market::NAME
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bibox
|
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
|
12
|
+
target = market_pair.target
|
13
|
+
"#{Cryptoexchange::Exchanges::Bibox::Market::API_URL}/mdata?cmd=deals&pair=#{base}_#{target}&size=15"
|
14
|
+
end
|
15
|
+
|
16
|
+
def adapt(output, market_pair)
|
17
|
+
trades = output['result']
|
18
|
+
trades.collect do |trade|
|
19
|
+
tr = Cryptoexchange::Models::Trade.new
|
20
|
+
tr.base = market_pair.base
|
21
|
+
tr.target = market_pair.target
|
22
|
+
tr.type = trade['side'] == 2 ? "sell" : "buy"
|
23
|
+
tr.price = trade['price']
|
24
|
+
tr.amount = trade['amount']
|
25
|
+
tr.timestamp = trade['time'].to_i / 1000
|
26
|
+
tr.payload = trade
|
27
|
+
tr.market = Bibox::Market::NAME
|
28
|
+
tr
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Cobinhood
|
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
|
+
trading_pair_id = "#{market_pair.base}-#{market_pair.target}"
|
18
|
+
"#{Cryptoexchange::Exchanges::Cobinhood::Market::API_URL}/market/tickers/#{trading_pair_id}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapt(output, market_pair)
|
22
|
+
ticker = Cryptoexchange::Models::Ticker.new
|
23
|
+
market = output['result']["ticker"]
|
24
|
+
|
25
|
+
ticker.base = market_pair.base
|
26
|
+
ticker.target = market_pair.target
|
27
|
+
ticker.market = Cobinhood::Market::NAME
|
28
|
+
ticker.last = NumericHelper.to_d(market['last_trade_price'])
|
29
|
+
ticker.high = NumericHelper.to_d(market['24h_high'])
|
30
|
+
ticker.low = NumericHelper.to_d(market['24h_low'])
|
31
|
+
ticker.ask = NumericHelper.to_d(market['lowest_ask'])
|
32
|
+
ticker.bid = NumericHelper.to_d(market['highest_bid'])
|
33
|
+
ticker.volume = NumericHelper.to_d(market['24h_volume'])
|
34
|
+
ticker.timestamp = DateTime.now.to_time.to_i
|
35
|
+
ticker.payload = market
|
36
|
+
ticker
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Cobinhood
|
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
|
+
trading_pair_id = "#{market_pair.base}-#{market_pair.target}"
|
18
|
+
"#{Cryptoexchange::Exchanges::Cobinhood::Market::API_URL}/market/orderbooks/#{trading_pair_id}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapt(output, market_pair)
|
22
|
+
order_book = Cryptoexchange::Models::OrderBook.new
|
23
|
+
order_book.base = market_pair.base
|
24
|
+
order_book.target = market_pair.target
|
25
|
+
order_book.market = Cobinhood::Market::NAME
|
26
|
+
order_book.asks = adapt_orders output["result"]["orderbook"]['asks']
|
27
|
+
order_book.bids = adapt_orders output["result"]["orderbook"]['bids']
|
28
|
+
order_book.timestamp = DateTime.now.to_time.to_i
|
29
|
+
order_book.payload = output
|
30
|
+
order_book
|
31
|
+
end
|
32
|
+
|
33
|
+
def adapt_orders(orders)
|
34
|
+
orders.collect do |price, amount, count|
|
35
|
+
Cryptoexchange::Models::Order.new \
|
36
|
+
price: price,
|
37
|
+
amount: amount,
|
38
|
+
timestamp: DateTime.now.to_time.to_i
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Cobinhood
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
PAIRS_URL = "#{Cryptoexchange::Exchanges::Cobinhood::Market::API_URL}/market/trading_pairs"
|
6
|
+
|
7
|
+
def fetch
|
8
|
+
output = super
|
9
|
+
adapt(output)
|
10
|
+
end
|
11
|
+
|
12
|
+
def adapt(output)
|
13
|
+
pairs = output['result']["trading_pairs"]
|
14
|
+
pairs.map do |pair|
|
15
|
+
Cryptoexchange::Models::MarketPair.new \
|
16
|
+
base: pair['base_currency_id'],
|
17
|
+
target: pair['quote_currency_id'],
|
18
|
+
market: Cobinhood::Market::NAME
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
:pairs:
|
2
|
+
- :base: BTC
|
3
|
+
:target: KRW
|
4
|
+
- :base: BT1
|
5
|
+
:target: KRW
|
6
|
+
- :base: BT2
|
7
|
+
:target: KRW
|
8
|
+
- :base: BCH
|
9
|
+
:target: KRW
|
10
|
+
- :base: BTG
|
11
|
+
:target: KRW
|
12
|
+
- :base: BCD
|
13
|
+
:target: KRW
|
14
|
+
- :base: ETH
|
15
|
+
:target: KRW
|
16
|
+
- :base: ETC
|
17
|
+
:target: KRW
|
18
|
+
- :base: ADA
|
19
|
+
:target: KRW
|
20
|
+
- :base: QTUM
|
21
|
+
:target: KRW
|
22
|
+
- :base: XLM
|
23
|
+
:target: KRW
|
24
|
+
- :base: NEO
|
25
|
+
:target: KRW
|
26
|
+
- :base: GAS
|
27
|
+
:target: KRW
|
28
|
+
- :base: RPX
|
29
|
+
:target: KRW
|
30
|
+
- :base: HSR
|
31
|
+
:target: KRW
|
32
|
+
- :base: KNC
|
33
|
+
:target: KRW
|
34
|
+
- :base: TSL
|
35
|
+
:target: KRW
|
36
|
+
- :base: TRON
|
37
|
+
:target: KRW
|
38
|
+
- :base: OMG
|
39
|
+
:target: KRW
|
40
|
+
- :base: WTC
|
41
|
+
:target: KRW
|
42
|
+
- :base: MCO
|
43
|
+
:target: KRW
|
44
|
+
- :base: INK
|
45
|
+
:target: KRW
|
46
|
+
- :base: ENT
|
47
|
+
:target: KRW
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Coinnest
|
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::Coinnest::Market::API_URL}/api/pub/ticker?coin=#{market_pair.base.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 = Coinnest::Market::NAME
|
25
|
+
ticker.ask = NumericHelper.to_d(output['sell'])
|
26
|
+
ticker.bid = NumericHelper.to_d(output['buy'])
|
27
|
+
ticker.last = NumericHelper.to_d(output['last'])
|
28
|
+
ticker.high = NumericHelper.to_d(output['high'])
|
29
|
+
ticker.low = NumericHelper.to_d(output['low'])
|
30
|
+
ticker.volume = NumericHelper.to_d(output['vol'])
|
31
|
+
ticker.timestamp = output['time'].to_i
|
32
|
+
ticker.payload = output
|
33
|
+
ticker
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Coinnest
|
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::Coinnest::Market::API_URL}/api/pub/depth?coin=#{market_pair.base.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 = Coinnest::Market::NAME
|
27
|
+
order_book.asks = adapt_orders(output['asks'])
|
28
|
+
order_book.bids = adapt_orders(output['bids'])
|
29
|
+
order_book.timestamp = timestamp
|
30
|
+
order_book.payload = output
|
31
|
+
order_book
|
32
|
+
end
|
33
|
+
|
34
|
+
def adapt_orders(orders)
|
35
|
+
orders.collect do |order_entry|
|
36
|
+
price, amount = order_entry
|
37
|
+
Cryptoexchange::Models::Order.new(price: price,
|
38
|
+
amount: amount,
|
39
|
+
timestamp: nil)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Coinnest
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
|
6
|
+
def fetch
|
7
|
+
output = super
|
8
|
+
market_pairs = []
|
9
|
+
output.each do |pair|
|
10
|
+
market_pairs << Cryptoexchange::Models::MarketPair.new(
|
11
|
+
base: pair[:base],
|
12
|
+
target: pair[:target],
|
13
|
+
market: Coinnest::Market::NAME
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
market_pairs
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Coinnest
|
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::Coinnest::Market::API_URL}/api/pub/trades?coin=#{market_pair.base.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.market = Coinnest::Market::NAME
|
21
|
+
tr.type = trade['type']
|
22
|
+
tr.price = trade['price']
|
23
|
+
tr.amount = trade['amount']
|
24
|
+
tr.timestamp = trade['date'].to_i
|
25
|
+
tr.payload = trade
|
26
|
+
tr
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|