cryptoexchange 0.2.1 → 0.3.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 +16 -5
- data/lib/cryptoexchange.rb +3 -1
- data/lib/cryptoexchange/client.rb +5 -17
- data/lib/cryptoexchange/exchanges/anx/services/market.rb +11 -11
- data/lib/cryptoexchange/exchanges/bitcoin_indonesia/services/market.rb +13 -13
- data/lib/cryptoexchange/exchanges/bitflyer/services/market.rb +10 -10
- data/lib/cryptoexchange/exchanges/bithumb/bithumb.yml +13 -0
- data/lib/cryptoexchange/exchanges/bithumb/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bithumb/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/bithumb/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/bithumb/services/market.rb +40 -0
- data/lib/cryptoexchange/exchanges/bithumb/services/pairs.rb +26 -0
- data/lib/cryptoexchange/exchanges/bitstamp/market.rb +1 -1
- data/lib/cryptoexchange/exchanges/bitstamp/services/market.rb +13 -13
- data/lib/cryptoexchange/exchanges/bittrex/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bittrex/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/bittrex/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/bittrex/services/market.rb +42 -0
- data/lib/cryptoexchange/exchanges/bittrex/services/pairs.rb +28 -0
- data/lib/cryptoexchange/exchanges/bleutrade/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bleutrade/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/bleutrade/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/bleutrade/services/market.rb +50 -0
- data/lib/cryptoexchange/exchanges/bleutrade/services/pairs.rb +27 -0
- data/lib/cryptoexchange/exchanges/btcc/services/market.rb +12 -12
- data/lib/cryptoexchange/exchanges/bter/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bter/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/bter/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/bter/services/market.rb +38 -0
- data/lib/cryptoexchange/exchanges/bter/services/pairs.rb +26 -0
- data/lib/cryptoexchange/exchanges/ccex/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/ccex/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/ccex/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/ccex/services/market.rb +48 -0
- data/lib/cryptoexchange/exchanges/ccex/services/pairs.rb +26 -0
- data/lib/cryptoexchange/exchanges/coin_exchange/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/coin_exchange/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/coin_exchange/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/coin_exchange/services/market.rb +70 -0
- data/lib/cryptoexchange/exchanges/coin_exchange/services/pairs.rb +24 -0
- data/lib/cryptoexchange/exchanges/coincheck/services/market.rb +12 -12
- data/lib/cryptoexchange/exchanges/coinone/services/market.rb +10 -10
- data/lib/cryptoexchange/exchanges/cryptopia/services/market.rb +13 -13
- data/lib/cryptoexchange/exchanges/ether_delta/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/ether_delta/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/ether_delta/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/ether_delta/services/market.rb +41 -0
- data/lib/cryptoexchange/exchanges/ether_delta/services/pairs.rb +26 -0
- data/lib/cryptoexchange/exchanges/gatecoin/services/market.rb +11 -11
- data/lib/cryptoexchange/exchanges/gemini/services/market.rb +4 -4
- data/lib/cryptoexchange/exchanges/hitbtc/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/hitbtc/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/hitbtc/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/hitbtc/services/market.rb +42 -0
- data/lib/cryptoexchange/exchanges/hitbtc/services/pairs.rb +24 -0
- data/lib/cryptoexchange/exchanges/korbit/services/market.rb +12 -12
- data/lib/cryptoexchange/exchanges/lakebtc/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/lakebtc/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/lakebtc/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/lakebtc/services/market.rb +51 -0
- data/lib/cryptoexchange/exchanges/lakebtc/services/pairs.rb +29 -0
- data/lib/cryptoexchange/exchanges/liqui/services/market.rb +6 -6
- data/lib/cryptoexchange/exchanges/livecoin/services/market.rb +12 -12
- data/lib/cryptoexchange/exchanges/novaexchange/services/market.rb +13 -13
- data/lib/cryptoexchange/exchanges/novaexchange/services/pairs.rb +6 -2
- data/lib/cryptoexchange/exchanges/okcoin/services/market.rb +12 -12
- data/lib/cryptoexchange/helpers/hash_helper.rb +20 -0
- data/lib/cryptoexchange/helpers/numeric_helper.rb +7 -0
- data/lib/cryptoexchange/version.rb +1 -1
- metadata +50 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05c26fb966defd809609e149871cccba4528c3ee
|
4
|
+
data.tar.gz: b14ce69ed0fd47f8134dcc092db30410f9e93291
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d2c33ee222ef56cc2af238a3bb32edb35375b8d4457d40d605dece38d5ff858c256a275596d84fc6ec2e6e6a6b276ec21ea439e8d24c296b77c7d58f88d98c0
|
7
|
+
data.tar.gz: a088f917c5df27a2355881de81bebddd75f74d1f16787ecc648ec36b31fddf4bd1ac9318599460b25baa8a5cf389a2b454cbeaaa9f1d0af1e64f08d220b519bf
|
data/README.md
CHANGED
@@ -28,13 +28,13 @@ Or install it yourself as:
|
|
28
28
|
| Gatecoin | Y | | | | Y |
|
29
29
|
| BTCC | Y | | | | User-Defined|
|
30
30
|
| OKCoin | Y | | | | User-Defined|
|
31
|
-
| LakeBTC |
|
31
|
+
| LakeBTC | Y | | | | Y |
|
32
32
|
| Huobi | | | | | |
|
33
33
|
| Yunbi | | | | | |
|
34
34
|
| BTC38 | | | | | |
|
35
35
|
| CHBTC | | | | | |
|
36
36
|
| Bitstamp | Y | | | | User-Defined|
|
37
|
-
| Bittrex |
|
37
|
+
| Bittrex | Y | | | | Y |
|
38
38
|
| GDAX | | | | | |
|
39
39
|
| Gemini | Y | | | | Y |
|
40
40
|
| Kraken | | | | | |
|
@@ -46,18 +46,29 @@ Or install it yourself as:
|
|
46
46
|
| Unocoin | | | | | |
|
47
47
|
| Coinone | Y | | | | Y |
|
48
48
|
| Korbit | Y | | | | User-Defined|
|
49
|
-
| Bithumb |
|
49
|
+
| Bithumb | Y | | | | Y |
|
50
50
|
| Luno | | | | | |
|
51
51
|
| BTC-e | | | | | |
|
52
|
-
| Bleutrade |
|
52
|
+
| Bleutrade | Y | | | | Y |
|
53
53
|
| Yobit | | | | | |
|
54
54
|
| Bitfinex | | | | | |
|
55
|
-
| BTER |
|
55
|
+
| BTER | Y | | | | Y |
|
56
56
|
| Cryptopia | Y | | | | Y |
|
57
57
|
| Livecoin | Y | | | | Y |
|
58
58
|
| Nova Exchange | Y | | | | Y |
|
59
59
|
| Bitcoin Indonesia | Y | | | | User-Defined|
|
60
60
|
| Liqui | Y | | | | Y |
|
61
|
+
| HitBTC | Y | | | | Y |
|
62
|
+
| CCex | Y | | | | Y |
|
63
|
+
| CoinExchange | Y | | | | Y |
|
64
|
+
| EtherDelta | Y | | | | Y |
|
65
|
+
| Bitbay | | | | | |
|
66
|
+
| Bitso | | | | | |
|
67
|
+
| BTCChina | | | | | |
|
68
|
+
| Coinmate | | | | | |
|
69
|
+
| Itbit | | | | | |
|
70
|
+
| Jubi | | | | | |
|
71
|
+
| MercadoBitcoin | | | | | |
|
61
72
|
|
62
73
|
## Usage
|
63
74
|
|
data/lib/cryptoexchange.rb
CHANGED
@@ -2,12 +2,14 @@ require "cryptoexchange/version"
|
|
2
2
|
require "cryptoexchange/client"
|
3
3
|
require "cryptoexchange/lru_ttl_cache"
|
4
4
|
require "cryptoexchange/helpers/string_helper"
|
5
|
+
require "cryptoexchange/helpers/numeric_helper"
|
6
|
+
require "cryptoexchange/helpers/hash_helper"
|
5
7
|
require "cryptoexchange/models/ticker"
|
6
8
|
require "cryptoexchange/models/market_pair"
|
7
9
|
require "cryptoexchange/services/market"
|
8
10
|
require "cryptoexchange/services/pairs"
|
9
11
|
|
10
|
-
Cryptoexchange::Client
|
12
|
+
Cryptoexchange::Client.available_exchanges.each do |market|
|
11
13
|
require "cryptoexchange/exchanges/#{market}/market"
|
12
14
|
require "cryptoexchange/exchanges/#{market}/models/ticker"
|
13
15
|
require "cryptoexchange/exchanges/#{market}/models/market_pair"
|
@@ -1,22 +1,10 @@
|
|
1
1
|
module Cryptoexchange
|
2
2
|
class Client
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
coincheck
|
9
|
-
coinone
|
10
|
-
korbit
|
11
|
-
cryptopia
|
12
|
-
gatecoin
|
13
|
-
livecoin
|
14
|
-
bitstamp
|
15
|
-
okcoin
|
16
|
-
novaexchange
|
17
|
-
liqui
|
18
|
-
gemini
|
19
|
-
)
|
3
|
+
class << self
|
4
|
+
def available_exchanges
|
5
|
+
Dir.entries("./lib/cryptoexchange/exchanges")[2..-1]
|
6
|
+
end
|
7
|
+
end
|
20
8
|
|
21
9
|
def initialize(ticker_ttl: 3)
|
22
10
|
LruTtlCache.ticker_cache(ticker_ttl)
|
@@ -22,17 +22,17 @@ module Cryptoexchange::Exchanges
|
|
22
22
|
base = output['data']['vol']['currency']
|
23
23
|
target = output['data']['high']['currency']
|
24
24
|
|
25
|
-
ticker.base
|
26
|
-
ticker.target
|
27
|
-
ticker.market
|
28
|
-
ticker.ask
|
29
|
-
ticker.bid
|
30
|
-
ticker.last
|
31
|
-
ticker.high
|
32
|
-
ticker.low
|
33
|
-
ticker.volume
|
34
|
-
ticker.timestamp = output['data']['dataUpdateTime']
|
35
|
-
ticker.payload
|
25
|
+
ticker.base = base
|
26
|
+
ticker.target = target
|
27
|
+
ticker.market = Anx::Market::NAME
|
28
|
+
ticker.ask = NumericHelper.to_d(output['data']['sell']['value'])
|
29
|
+
ticker.bid = NumericHelper.to_d(output['data']['buy']['value'])
|
30
|
+
ticker.last = NumericHelper.to_d(output['data']['last']['value'])
|
31
|
+
ticker.high = NumericHelper.to_d(output['data']['high']['value'])
|
32
|
+
ticker.low = NumericHelper.to_d(output['data']['low']['value'])
|
33
|
+
ticker.volume = NumericHelper.to_d(output['data']['vol']['value'])
|
34
|
+
ticker.timestamp = output['data']['dataUpdateTime'].to_i
|
35
|
+
ticker.payload = output
|
36
36
|
ticker
|
37
37
|
end
|
38
38
|
end
|
@@ -20,19 +20,19 @@ module Cryptoexchange::Exchanges
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def adapt(output, market_pair)
|
23
|
-
output
|
24
|
-
ticker
|
25
|
-
ticker.base
|
26
|
-
ticker.target
|
27
|
-
ticker.market
|
28
|
-
ticker.bid
|
29
|
-
ticker.ask
|
30
|
-
ticker.last
|
31
|
-
ticker.high
|
32
|
-
ticker.low
|
33
|
-
ticker.volume
|
34
|
-
ticker.timestamp = output['server_time']
|
35
|
-
ticker.payload
|
23
|
+
output = output['ticker']
|
24
|
+
ticker = BitcoinIndonesia::Models::Ticker.new
|
25
|
+
ticker.base = market_pair.base
|
26
|
+
ticker.target = market_pair.target
|
27
|
+
ticker.market = BitcoinIndonesia::Market::NAME
|
28
|
+
ticker.bid = NumericHelper.to_d(output['buy'])
|
29
|
+
ticker.ask = NumericHelper.to_d(output['sell'])
|
30
|
+
ticker.last = NumericHelper.to_d(output['last'])
|
31
|
+
ticker.high = NumericHelper.to_d(output['high'])
|
32
|
+
ticker.low = NumericHelper.to_d(output['low'])
|
33
|
+
ticker.volume = NumericHelper.to_d(output["vol_#{ticker.base.downcase}"])
|
34
|
+
ticker.timestamp = output['server_time'].to_i
|
35
|
+
ticker.payload = output
|
36
36
|
ticker
|
37
37
|
end
|
38
38
|
end
|
@@ -18,17 +18,17 @@ module Cryptoexchange::Exchanges
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def adapt(output)
|
21
|
-
ticker
|
22
|
-
base, target
|
23
|
-
ticker.base
|
24
|
-
ticker.target
|
25
|
-
ticker.market
|
26
|
-
ticker.ask
|
27
|
-
ticker.bid
|
28
|
-
ticker.last
|
29
|
-
ticker.volume
|
21
|
+
ticker = Bitflyer::Models::Ticker.new
|
22
|
+
base, target = output['product_code'].split('_')
|
23
|
+
ticker.base = base
|
24
|
+
ticker.target = target
|
25
|
+
ticker.market = Bitflyer::Market::NAME
|
26
|
+
ticker.ask = NumericHelper.to_d(output['best_ask'])
|
27
|
+
ticker.bid = NumericHelper.to_d(output['best_bid'])
|
28
|
+
ticker.last = NumericHelper.to_d(output['ltp'])
|
29
|
+
ticker.volume = NumericHelper.to_d(output['volume_by_product'])
|
30
30
|
ticker.timestamp = Time.parse(output['timestamp']).to_i
|
31
|
-
ticker.payload
|
31
|
+
ticker.payload = output
|
32
32
|
ticker
|
33
33
|
end
|
34
34
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bithumb
|
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::Bithumb::Market::API_URL}/public/ticker/#{market_pair.base}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapt(output, market_pair)
|
21
|
+
market = output['data']
|
22
|
+
ticker = Bithumb::Models::Ticker.new
|
23
|
+
ticker.base = market_pair.base
|
24
|
+
ticker.target = market_pair.target
|
25
|
+
ticker.market = Bithumb::Market::NAME
|
26
|
+
ticker.ask = NumericHelper.to_d(market['sell_price'])
|
27
|
+
ticker.bid = NumericHelper.to_d(market['buy_price'])
|
28
|
+
ticker.last = NumericHelper.to_d(market['closing_price'])
|
29
|
+
ticker.high = NumericHelper.to_d(market['max_price'])
|
30
|
+
ticker.low = NumericHelper.to_d(market['min_price'])
|
31
|
+
#use 1day volume instead of 7days
|
32
|
+
ticker.volume = NumericHelper.to_d(market['volume_1day'])
|
33
|
+
ticker.timestamp = market['date'].to_i
|
34
|
+
ticker.payload = market
|
35
|
+
ticker
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bithumb
|
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 << Bithumb::Models::MarketPair.new(
|
15
|
+
base: pair[:base],
|
16
|
+
target: pair[:target],
|
17
|
+
market: Bithumb::Market::NAME
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
market_pairs
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -16,22 +16,22 @@ module Cryptoexchange::Exchanges
|
|
16
16
|
def ticker_url(market_pair)
|
17
17
|
base = market_pair.base.downcase
|
18
18
|
target = market_pair.target.downcase
|
19
|
-
"#{Cryptoexchange::Exchanges::Bitstamp::Market::API_URL}/#{base}#{target}"
|
19
|
+
"#{Cryptoexchange::Exchanges::Bitstamp::Market::API_URL}/ticker/#{base}#{target}"
|
20
20
|
end
|
21
21
|
|
22
22
|
def adapt(output, market_pair)
|
23
|
-
ticker
|
24
|
-
ticker.base
|
25
|
-
ticker.target
|
26
|
-
ticker.market
|
27
|
-
ticker.ask
|
28
|
-
ticker.bid
|
29
|
-
ticker.last
|
30
|
-
ticker.high
|
31
|
-
ticker.low
|
32
|
-
ticker.volume
|
33
|
-
ticker.timestamp = output['timestamp']
|
34
|
-
ticker.payload
|
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 = NumericHelper.to_d(output['ask'])
|
28
|
+
ticker.bid = NumericHelper.to_d(output['bid'])
|
29
|
+
ticker.last = NumericHelper.to_d(output['last'])
|
30
|
+
ticker.high = NumericHelper.to_d(output['high'])
|
31
|
+
ticker.low = NumericHelper.to_d(output['low'])
|
32
|
+
ticker.volume = NumericHelper.to_d(output['volume'])
|
33
|
+
ticker.timestamp = output['timestamp'].to_i
|
34
|
+
ticker.payload = output
|
35
35
|
ticker
|
36
36
|
end
|
37
37
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bittrex
|
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)
|
14
|
+
end
|
15
|
+
|
16
|
+
def ticker_url(market_pair)
|
17
|
+
base = market_pair.base
|
18
|
+
target = market_pair.target
|
19
|
+
"#{Cryptoexchange::Exchanges::Bittrex::Market::API_URL}/public/getmarketsummary?market=#{base}-#{target}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def adapt(output)
|
23
|
+
ticker = Bittrex::Models::Ticker.new
|
24
|
+
market = output['result'][0]
|
25
|
+
|
26
|
+
ticker.base = market['MarketName'].split("-")[0]
|
27
|
+
ticker.target = market['MarketName'].split("-")[1]
|
28
|
+
ticker.market = Bittrex::Market::NAME
|
29
|
+
ticker.last = NumericHelper.to_d(market['Last'])
|
30
|
+
ticker.high = NumericHelper.to_d(market['High'])
|
31
|
+
ticker.low = NumericHelper.to_d(market['Low'])
|
32
|
+
ticker.ask = NumericHelper.to_d(market['Ask'])
|
33
|
+
ticker.bid = NumericHelper.to_d(market['Bid'])
|
34
|
+
ticker.volume = NumericHelper.to_d(market['BaseVolume'])
|
35
|
+
ticker.timestamp = DateTime.now.to_time.to_i
|
36
|
+
ticker.payload = market
|
37
|
+
ticker
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Bittrex
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
PAIRS_URL = "#{Cryptoexchange::Exchanges::Bittrex::Market::API_URL}/public/getmarkets"
|
6
|
+
|
7
|
+
def fetch
|
8
|
+
output = super
|
9
|
+
adapt(output)
|
10
|
+
end
|
11
|
+
|
12
|
+
def adapt(output)
|
13
|
+
pairs = output['result']
|
14
|
+
market_pairs = []
|
15
|
+
pairs.each do |pair|
|
16
|
+
market_pairs << Bittrex::Models::MarketPair.new(
|
17
|
+
base: pair['BaseCurrency'],
|
18
|
+
target: pair['MarketCurrency'],
|
19
|
+
market: Bittrex::Market::NAME
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
market_pairs
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|