cryptoexchange 0.1.1 → 0.2.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 +4 -4
- data/README.md +13 -12
- data/cryptoexchange.gemspec +2 -0
- data/lib/cryptoexchange.rb +5 -12
- data/lib/cryptoexchange/client.rb +46 -0
- data/lib/cryptoexchange/exchanges/anx/anx.yml +27 -0
- data/lib/cryptoexchange/exchanges/anx/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/anx/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/anx/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/anx/services/market.rb +41 -0
- data/lib/cryptoexchange/exchanges/anx/services/pairs.rb +25 -0
- data/lib/cryptoexchange/exchanges/bitcoin_indonesia/bitcoin_indonesia.yml +19 -0
- data/lib/cryptoexchange/exchanges/bitcoin_indonesia/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bitcoin_indonesia/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/bitcoin_indonesia/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/bitcoin_indonesia/services/market.rb +41 -0
- data/lib/cryptoexchange/exchanges/bitcoin_indonesia/services/pairs.rb +25 -0
- data/lib/cryptoexchange/exchanges/bitflyer/services/market.rb +8 -2
- data/lib/cryptoexchange/exchanges/bitflyer/services/pairs.rb +1 -2
- data/lib/cryptoexchange/exchanges/bitstamp/bitstamp.yml +19 -0
- data/lib/cryptoexchange/exchanges/bitstamp/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bitstamp/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/bitstamp/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/bitstamp/services/market.rb +40 -0
- data/lib/cryptoexchange/exchanges/bitstamp/services/pairs.rb +26 -0
- data/lib/cryptoexchange/exchanges/btcc/btcc.yml +5 -0
- data/lib/cryptoexchange/exchanges/btcc/market.rb +9 -0
- data/lib/cryptoexchange/exchanges/btcc/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/btcc/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/btcc/services/market.rb +42 -0
- data/lib/cryptoexchange/exchanges/btcc/services/pairs.rb +25 -0
- data/lib/cryptoexchange/exchanges/coincheck/services/market.rb +8 -2
- data/lib/cryptoexchange/exchanges/coincheck/services/pairs.rb +1 -2
- data/lib/cryptoexchange/exchanges/coinone/services/market.rb +8 -2
- data/lib/cryptoexchange/exchanges/coinone/services/pairs.rb +1 -2
- data/lib/cryptoexchange/exchanges/cryptopia/services/market.rb +7 -2
- data/lib/cryptoexchange/exchanges/cryptopia/services/pairs.rb +1 -2
- data/lib/cryptoexchange/exchanges/gatecoin/services/market.rb +28 -27
- data/lib/cryptoexchange/exchanges/gatecoin/services/pairs.rb +1 -2
- data/lib/cryptoexchange/exchanges/gemini/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/gemini/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/gemini/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/gemini/services/market.rb +49 -0
- data/lib/cryptoexchange/exchanges/gemini/services/pairs.rb +28 -0
- data/lib/cryptoexchange/exchanges/korbit/services/market.rb +8 -2
- data/lib/cryptoexchange/exchanges/korbit/services/pairs.rb +1 -2
- data/lib/cryptoexchange/exchanges/liqui/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/liqui/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/liqui/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/liqui/services/market.rb +43 -0
- data/lib/cryptoexchange/exchanges/liqui/services/pairs.rb +27 -0
- data/lib/cryptoexchange/exchanges/livecoin/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/livecoin/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/livecoin/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/livecoin/services/market.rb +51 -0
- data/lib/cryptoexchange/exchanges/livecoin/services/pairs.rb +27 -0
- data/lib/cryptoexchange/exchanges/novaexchange/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/novaexchange/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/novaexchange/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/novaexchange/services/market.rb +44 -0
- data/lib/cryptoexchange/exchanges/novaexchange/services/pairs.rb +26 -0
- data/lib/cryptoexchange/exchanges/okcoin/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/okcoin/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/okcoin/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/okcoin/okcoin.yml +7 -0
- data/lib/cryptoexchange/exchanges/okcoin/services/market.rb +40 -0
- data/lib/cryptoexchange/exchanges/okcoin/services/pairs.rb +25 -0
- data/lib/cryptoexchange/helpers/string_helper.rb +7 -0
- data/lib/cryptoexchange/lru_ttl_cache.rb +7 -0
- data/lib/cryptoexchange/services/market.rb +15 -1
- data/lib/cryptoexchange/services/pairs.rb +7 -2
- data/lib/cryptoexchange/version.rb +1 -1
- metadata +69 -2
@@ -0,0 +1,19 @@
|
|
1
|
+
:pairs:
|
2
|
+
- :base: BTC
|
3
|
+
:target: USD
|
4
|
+
- :base: BTC
|
5
|
+
:target: EUR
|
6
|
+
- :base: EUR
|
7
|
+
:target: USD
|
8
|
+
- :base: XRP
|
9
|
+
:target: USD
|
10
|
+
- :base: XRP
|
11
|
+
:target: EUR
|
12
|
+
- :base: XRP
|
13
|
+
:target: BTC
|
14
|
+
- :base: LTC
|
15
|
+
:target: USD
|
16
|
+
- :base: LTC
|
17
|
+
:target: EUR
|
18
|
+
- :base: LTC
|
19
|
+
:target: BTC
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bitstamp
|
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::Bitstamp::Market::API_URL}/#{base}#{target}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def adapt(output, market_pair)
|
23
|
+
ticker = Bitstamp::Models::Ticker.new
|
24
|
+
ticker.base = market_pair.base
|
25
|
+
ticker.target = market_pair.target
|
26
|
+
ticker.market = Bitstamp::Market::NAME
|
27
|
+
ticker.ask = output['ask']
|
28
|
+
ticker.bid = output['bid']
|
29
|
+
ticker.last = output['last']
|
30
|
+
ticker.high = output['high']
|
31
|
+
ticker.low = output['low']
|
32
|
+
ticker.volume = output['volume'].to_f
|
33
|
+
ticker.timestamp = output['timestamp']
|
34
|
+
ticker.payload = output
|
35
|
+
ticker
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bitstamp
|
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 << Bitstamp::Models::MarketPair.new(
|
15
|
+
base: pair[:base],
|
16
|
+
target: pair[:target],
|
17
|
+
market: Bitstamp::Market::NAME
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
market_pairs
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Btcc
|
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
|
+
if market_pair.target == 'USD'
|
18
|
+
"#{Cryptoexchange::Exchanges::Btcc::Market::API_URL_USD}/ticker?symbol=#{market_pair.base}#{market_pair.target}"
|
19
|
+
else
|
20
|
+
"#{Cryptoexchange::Exchanges::Btcc::Market::API_URL_CNY}/ticker?symbol=#{market_pair.base}#{market_pair.target}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def adapt(output, market_pair)
|
25
|
+
ticker = Btcc::Models::Ticker.new
|
26
|
+
ticker.base = market_pair.base
|
27
|
+
ticker.target = market_pair.target
|
28
|
+
ticker.market = Btcc::Market::NAME
|
29
|
+
ticker.ask = output['ticker']['AskPrice']
|
30
|
+
ticker.bid = output['ticker']['BidPrice']
|
31
|
+
ticker.last = output['ticker']['Last']
|
32
|
+
ticker.high = output['ticker']['High']
|
33
|
+
ticker.low = output['ticker']['Low']
|
34
|
+
ticker.volume = output['ticker']['Volume']
|
35
|
+
ticker.timestamp = output['ticker']['Timestamp']
|
36
|
+
ticker.payload = output
|
37
|
+
ticker
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Btcc
|
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 << Btcc::Models::MarketPair.new(
|
15
|
+
base: pair[:base],
|
16
|
+
target: pair[:target],
|
17
|
+
market: Btcc::Market::NAME
|
18
|
+
)
|
19
|
+
end
|
20
|
+
market_pairs
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,12 +2,18 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Coincheck
|
3
3
|
module Services
|
4
4
|
class Market < Cryptoexchange::Services::Market
|
5
|
+
class << self
|
6
|
+
def supports_individual_ticker_query?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
def fetch(_)
|
6
|
-
output = super(
|
12
|
+
output = super(ticker_url(_))
|
7
13
|
adapt(output)
|
8
14
|
end
|
9
15
|
|
10
|
-
def
|
16
|
+
def ticker_url(_)
|
11
17
|
"#{Cryptoexchange::Exchanges::Coincheck::Market::API_URL}/ticker"
|
12
18
|
end
|
13
19
|
|
@@ -2,7 +2,6 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Coincheck
|
3
3
|
module Services
|
4
4
|
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
-
MARKET = Coincheck::Market
|
6
5
|
|
7
6
|
def fetch
|
8
7
|
output = super
|
@@ -15,7 +14,7 @@ module Cryptoexchange::Exchanges
|
|
15
14
|
market_pairs << Coincheck::Models::MarketPair.new(
|
16
15
|
base: pair[:base],
|
17
16
|
target: pair[:target],
|
18
|
-
market:
|
17
|
+
market: Coincheck::Market::NAME
|
19
18
|
)
|
20
19
|
end
|
21
20
|
market_pairs
|
@@ -2,12 +2,18 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Coinone
|
3
3
|
module Services
|
4
4
|
class Market < Cryptoexchange::Services::Market
|
5
|
+
class << self
|
6
|
+
def supports_individual_ticker_query?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
def fetch(market_pair)
|
6
|
-
output = super(
|
12
|
+
output = super(ticker_url(market_pair))
|
7
13
|
adapt(output)
|
8
14
|
end
|
9
15
|
|
10
|
-
def
|
16
|
+
def ticker_url(market_pair)
|
11
17
|
base = market_pair.base.downcase
|
12
18
|
"#{Cryptoexchange::Exchanges::Coinone::Market::API_URL}/ticker?currency=#{base}"
|
13
19
|
end
|
@@ -2,7 +2,6 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Coinone
|
3
3
|
module Services
|
4
4
|
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
-
MARKET = Coinone::Market
|
6
5
|
PAIRS_URL = "#{Cryptoexchange::Exchanges::Coinone::Market::API_URL}/ticker?currency=all"
|
7
6
|
|
8
7
|
def fetch
|
@@ -17,7 +16,7 @@ module Cryptoexchange::Exchanges
|
|
17
16
|
market_pair = Coinone::Models::MarketPair.new
|
18
17
|
market_pair.base = value['currency']
|
19
18
|
market_pair.target = 'krw'
|
20
|
-
market_pair.market =
|
19
|
+
market_pair.market = Coinone::Market::NAME
|
21
20
|
market_pairs << market_pair
|
22
21
|
end
|
23
22
|
market_pairs
|
@@ -2,13 +2,18 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Cryptopia
|
3
3
|
module Services
|
4
4
|
class Market < Cryptoexchange::Services::Market
|
5
|
+
class << self
|
6
|
+
def supports_individual_ticker_query?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
end
|
5
10
|
|
6
11
|
def fetch(market_pair)
|
7
|
-
output = super(
|
12
|
+
output = super(ticker_url(market_pair))
|
8
13
|
adapt(output)
|
9
14
|
end
|
10
15
|
|
11
|
-
def
|
16
|
+
def ticker_url(market_pair)
|
12
17
|
base = market_pair.base
|
13
18
|
target = market_pair.target
|
14
19
|
"#{Cryptoexchange::Exchanges::Cryptopia::Market::API_URL}/GetMarket/#{base}_#{target}"
|
@@ -2,7 +2,6 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Cryptopia
|
3
3
|
module Services
|
4
4
|
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
-
MARKET = Cryptopia::Market
|
6
5
|
PAIRS_URL = "#{Cryptoexchange::Exchanges::Cryptopia::Market::API_URL}/GetTradePairs"
|
7
6
|
|
8
7
|
def fetch
|
@@ -18,7 +17,7 @@ module Cryptoexchange::Exchanges
|
|
18
17
|
market_pair = Cryptopia::Models::MarketPair.new
|
19
18
|
market_pair.base = base
|
20
19
|
market_pair.target = target
|
21
|
-
market_pair.market =
|
20
|
+
market_pair.market = Cryptopia::Market::NAME
|
22
21
|
market_pairs << market_pair
|
23
22
|
end
|
24
23
|
market_pairs
|
@@ -2,45 +2,46 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Gatecoin
|
3
3
|
module Services
|
4
4
|
class Market < Cryptoexchange::Services::Market
|
5
|
+
class << self
|
6
|
+
def supports_individual_ticker_query?
|
7
|
+
false
|
8
|
+
end
|
9
|
+
end
|
5
10
|
|
6
|
-
def fetch
|
7
|
-
output = super(
|
8
|
-
|
11
|
+
def fetch
|
12
|
+
output = super(self.ticker_url)
|
13
|
+
adapt_all(output)
|
9
14
|
end
|
10
15
|
|
11
|
-
def
|
16
|
+
def ticker_url
|
12
17
|
"#{Cryptoexchange::Exchanges::Gatecoin::Market::API_URL}/Public/LiveTickers"
|
13
18
|
end
|
14
19
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# volume
|
25
|
-
# timestamp
|
26
|
-
|
27
|
-
data = output['tickers']
|
28
|
-
ticker_match = data.find do |datum|
|
29
|
-
datum['currencyPair'] == market_pair.base + market_pair.target
|
20
|
+
def adapt_all(output)
|
21
|
+
output['tickers'].map do |ticker|
|
22
|
+
currency_pair = ticker['currencyPair']
|
23
|
+
market_pair = Cryptoexchange::Exchanges::Gatecoin::Models::MarketPair.new(
|
24
|
+
base: currency_pair[0..2],
|
25
|
+
target: currency_pair[3..-1],
|
26
|
+
market: Gatecoin::Market::NAME
|
27
|
+
)
|
28
|
+
adapt(ticker, market_pair)
|
30
29
|
end
|
30
|
+
end
|
31
31
|
|
32
|
+
def adapt(output, market_pair)
|
32
33
|
ticker = Gatecoin::Models::Ticker.new
|
33
34
|
ticker.base = market_pair.base
|
34
35
|
ticker.target = market_pair.target
|
35
36
|
ticker.market = 'gatecoin'
|
36
|
-
ticker.last =
|
37
|
-
ticker.bid =
|
38
|
-
ticker.ask =
|
39
|
-
ticker.high =
|
40
|
-
ticker.low =
|
41
|
-
ticker.volume =
|
42
|
-
ticker.timestamp =
|
43
|
-
ticker.payload =
|
37
|
+
ticker.last = output['last']
|
38
|
+
ticker.bid = output['bid']
|
39
|
+
ticker.ask = output['ask']
|
40
|
+
ticker.high = output['high']
|
41
|
+
ticker.low = output['low']
|
42
|
+
ticker.volume = output['volume'] # TODO: Check if it is base denominated?
|
43
|
+
ticker.timestamp = output['createDateTime'].to_i
|
44
|
+
ticker.payload = output
|
44
45
|
ticker
|
45
46
|
end
|
46
47
|
end
|
@@ -2,7 +2,6 @@ module Cryptoexchange::Exchanges
|
|
2
2
|
module Gatecoin
|
3
3
|
module Services
|
4
4
|
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
-
MARKET = Gatecoin::Market
|
6
5
|
PAIRS_URL = "#{Cryptoexchange::Exchanges::Gatecoin::Market::API_URL}/Public/LiveTickers"
|
7
6
|
|
8
7
|
def fetch
|
@@ -21,7 +20,7 @@ module Cryptoexchange::Exchanges
|
|
21
20
|
market_pair = Gatecoin::Models::MarketPair.new
|
22
21
|
market_pair.base = base
|
23
22
|
market_pair.target = target
|
24
|
-
market_pair.market =
|
23
|
+
market_pair.market = Gatecoin::Market::NAME
|
25
24
|
market_pairs << market_pair
|
26
25
|
end
|
27
26
|
market_pairs
|