cryptoexchange 0.14.2 → 0.15.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.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/cryptoexchange.gemspec +1 -1
- data/lib/cryptoexchange/client.rb +3 -2
- data/lib/cryptoexchange/exchanges/allcoin/allcoin.yml +69 -0
- data/lib/cryptoexchange/exchanges/allcoin/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/allcoin/services/market.rb +41 -0
- data/lib/cryptoexchange/exchanges/allcoin/services/order_book.rb +45 -0
- data/lib/cryptoexchange/exchanges/allcoin/services/pairs.rb +25 -0
- data/lib/cryptoexchange/exchanges/binance/binance.yml +147 -0
- data/lib/cryptoexchange/exchanges/binance/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/binance/services/market.rb +40 -0
- data/lib/cryptoexchange/exchanges/binance/services/order_book.rb +46 -0
- data/lib/cryptoexchange/exchanges/binance/services/pairs.rb +25 -0
- data/lib/cryptoexchange/exchanges/bit_z/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/bit_z/services/market.rb +51 -0
- data/lib/cryptoexchange/exchanges/bit_z/services/pairs.rb +29 -0
- data/lib/cryptoexchange/exchanges/coinmate/services/order_book.rb +5 -2
- data/lib/cryptoexchange/exchanges/gemini/services/order_book.rb +6 -2
- data/lib/cryptoexchange/exchanges/litebiteu/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/litebiteu/services/market.rb +50 -0
- data/lib/cryptoexchange/exchanges/litebiteu/services/pairs.rb +31 -0
- data/lib/cryptoexchange/exchanges/mercatox/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/mercatox/services/market.rb +51 -0
- data/lib/cryptoexchange/exchanges/mercatox/services/pairs.rb +27 -0
- data/lib/cryptoexchange/models/order.rb +13 -0
- data/lib/cryptoexchange/models/order_book.rb +8 -8
- data/lib/cryptoexchange/models/trade.rb +3 -13
- data/lib/cryptoexchange/version.rb +1 -1
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c66d393c34a0b990fe0c9c56055786428fdd94a
|
4
|
+
data.tar.gz: 7c86456e853a4c0cc33143a5150c62fb9423eb01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04e8ee3a27e92d15400ce22d26ed31ae6c232b1b84cc1da6af535dc53394b9492194ca7373dad4e014878a02153cf7b5ebb22bcef1f0b6cadb9eaf1bf4e41575
|
7
|
+
data.tar.gz: c818b4c651d3675812759ad44b2f8acac6e59e2fa0b43f526f87ed32ade5783f14ef551ff5a46f344045aad677c68c5d6ff0778e14a2a9f682dfeea3a459a01f
|
data/README.md
CHANGED
@@ -24,8 +24,10 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
| Exchange | Ticker | Order Book | Trade | Account | Market List |
|
26
26
|
| ----------------- | ------- | ---------- | ------- | ------- | ----------- |
|
27
|
+
| Allcoin | Y | Y | | | User-Defined|
|
27
28
|
| ANX | Y | | | | User-Defined|
|
28
|
-
|
|
29
|
+
| Bit-Z | Y | | | | Y |
|
30
|
+
| Binance | Y | Y | | | User-Defined|
|
29
31
|
| Bitbay | Y | | | | User-Defined|
|
30
32
|
| Bitcoin Indonesia | Y | | | | User-Defined|
|
31
33
|
| Bitfinex | Y | | | | Y |
|
@@ -61,9 +63,11 @@ Or install it yourself as:
|
|
61
63
|
| Kraken | Y | | | | Y |
|
62
64
|
| LakeBTC | Y | | | | Y |
|
63
65
|
| Liqui | Y | | | | Y |
|
66
|
+
| LiteBit.eu | Y | | | | Y |
|
64
67
|
| Livecoin | Y | | | | Y |
|
65
68
|
| Luno | Y | | | | Y |
|
66
69
|
| MercadoBitcoin | Y | | | | User-Defined|
|
70
|
+
| Mercatox | Y | N | N | N | Y |
|
67
71
|
| Nova Exchange | Y | | | | Y |
|
68
72
|
| OKCoin | Y | | | | User-Defined|
|
69
73
|
| Poloniex | Y | | | | Y |
|
data/cryptoexchange.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
27
|
spec.add_development_dependency "pry"
|
@@ -35,7 +35,7 @@ module Cryptoexchange
|
|
35
35
|
folder_names = Dir[File.join(File.dirname(__dir__), 'cryptoexchange', 'exchanges', '**')]
|
36
36
|
folder_names.map do |folder_name|
|
37
37
|
folder_name.split('/').last
|
38
|
-
end
|
38
|
+
end.sort
|
39
39
|
end
|
40
40
|
|
41
41
|
def exchange_for(currency)
|
@@ -64,7 +64,8 @@ module Cryptoexchange
|
|
64
64
|
else
|
65
65
|
order_books = order_book.fetch
|
66
66
|
order_books.find do |o|
|
67
|
-
o.base
|
67
|
+
o.base.casecmp(market_pair.base) == 0 &&
|
68
|
+
o.target.casecmp(market_pair.target) == 0
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
:pairs:
|
2
|
+
- :base: BTC
|
3
|
+
:target: USD
|
4
|
+
- :base: QTUM
|
5
|
+
:target: USD
|
6
|
+
- :base: GP
|
7
|
+
:target: USD
|
8
|
+
- :base: ETH
|
9
|
+
:target: BTC
|
10
|
+
- :base: LTC
|
11
|
+
:target: BTC
|
12
|
+
- :base: NEO
|
13
|
+
:target: BTC
|
14
|
+
- :base: HSR
|
15
|
+
:target: BTC
|
16
|
+
- :base: QTUM
|
17
|
+
:target: BTC
|
18
|
+
- :base: GXS
|
19
|
+
:target: BTC
|
20
|
+
- :base: MGO
|
21
|
+
:target: BTC
|
22
|
+
- :base: NAS
|
23
|
+
:target: BTC
|
24
|
+
- :base: ZEC
|
25
|
+
:target: BTC
|
26
|
+
- :base: TSL
|
27
|
+
:target: BTC
|
28
|
+
- :base: ACC
|
29
|
+
:target: BTC
|
30
|
+
- :base: GAME
|
31
|
+
:target: BTC
|
32
|
+
- :base: BASH
|
33
|
+
:target: BTC
|
34
|
+
- :base: FID
|
35
|
+
:target: BTC
|
36
|
+
- :base: ABC
|
37
|
+
:target: BTC
|
38
|
+
- :base: YBCT
|
39
|
+
:target: BTC
|
40
|
+
- :base: SIGMA
|
41
|
+
:target: ETH
|
42
|
+
- :base: UGT
|
43
|
+
:target: ETH
|
44
|
+
- :base: TSL
|
45
|
+
:target: QTUM
|
46
|
+
- :base: CFS
|
47
|
+
:target: BTC
|
48
|
+
- :base: IQT
|
49
|
+
:target: BTC
|
50
|
+
- :base: AICC
|
51
|
+
:target: BTC
|
52
|
+
- :base: DWC
|
53
|
+
:target: BTC
|
54
|
+
- :base: AO101
|
55
|
+
:target: BTC
|
56
|
+
- :base: LMC
|
57
|
+
:target: BTC
|
58
|
+
- :base: AIC
|
59
|
+
:target: BTC
|
60
|
+
- :base: XKC
|
61
|
+
:target: BTC
|
62
|
+
- :base: SHC
|
63
|
+
:target: BTC
|
64
|
+
- :base: YUAN
|
65
|
+
:target: BTC
|
66
|
+
- :base: ACT
|
67
|
+
:target: BTC
|
68
|
+
- :base: MCC
|
69
|
+
:target: BTC
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Allcoin
|
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::Allcoin::Market::API_URL}/ticker?symbol=#{market_pair.base.downcase}_#{market_pair.target.downcase}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapt(output, market_pair)
|
21
|
+
ticker = Cryptoexchange::Models::Ticker.new
|
22
|
+
base = market_pair.base
|
23
|
+
target = market_pair.target
|
24
|
+
|
25
|
+
ticker.base = base
|
26
|
+
ticker.target = target
|
27
|
+
ticker.market = Allcoin::Market::NAME
|
28
|
+
ticker.ask = NumericHelper.to_d(output['ticker']['sell'])
|
29
|
+
ticker.bid = NumericHelper.to_d(output['ticker']['buy'])
|
30
|
+
ticker.last = NumericHelper.to_d(output['ticker']['last'])
|
31
|
+
ticker.high = NumericHelper.to_d(output['ticker']['high'])
|
32
|
+
ticker.low = NumericHelper.to_d(output['ticker']['low'])
|
33
|
+
ticker.volume = NumericHelper.to_d(output['ticker']['vol'])
|
34
|
+
ticker.timestamp = output['date'].to_i
|
35
|
+
ticker.payload = output
|
36
|
+
ticker
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Allcoin
|
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::Allcoin::Market::API_URL}/depth?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 = Allcoin::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,25 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Allcoin
|
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 << Cryptoexchange::Models::MarketPair.new(
|
15
|
+
base: pair[:base],
|
16
|
+
target: pair[:target],
|
17
|
+
market: Allcoin::Market::NAME
|
18
|
+
)
|
19
|
+
end
|
20
|
+
market_pairs
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
:pairs:
|
2
|
+
- :base: ETH
|
3
|
+
:target: BTC
|
4
|
+
- :base: LTC
|
5
|
+
:target: BTC
|
6
|
+
- :base: BNB
|
7
|
+
:target: BTC
|
8
|
+
- :base: NEO
|
9
|
+
:target: BTC
|
10
|
+
- :base: QTUM
|
11
|
+
:target: ETH
|
12
|
+
- :base: EOS
|
13
|
+
:target: ETH
|
14
|
+
- :base: SNT
|
15
|
+
:target: ETH
|
16
|
+
- :base: BNT
|
17
|
+
:target: ETH
|
18
|
+
- :base: BCC
|
19
|
+
:target: BTC
|
20
|
+
- :base: GAS
|
21
|
+
:target: BTC
|
22
|
+
- :base: BNB
|
23
|
+
:target: ETH
|
24
|
+
- :base: BTM
|
25
|
+
:target: ETH
|
26
|
+
- :base: HCC
|
27
|
+
:target: BTC
|
28
|
+
- :base: BTC
|
29
|
+
:target: USDT
|
30
|
+
- :base: ETH
|
31
|
+
:target: USDT
|
32
|
+
- :base: HSR
|
33
|
+
:target: BTC
|
34
|
+
- :base: OAX
|
35
|
+
:target: ETH
|
36
|
+
- :base: DNT
|
37
|
+
:target: ETH
|
38
|
+
- :base: MCO
|
39
|
+
:target: ETH
|
40
|
+
- :base: ICN
|
41
|
+
:target: ETH
|
42
|
+
- :base: ELC
|
43
|
+
:target: BTC
|
44
|
+
- :base: MCO
|
45
|
+
:target: BTC
|
46
|
+
- :base: WTC
|
47
|
+
:target: BTC
|
48
|
+
- :base: WTC
|
49
|
+
:target: ETH
|
50
|
+
- :base: LLT
|
51
|
+
:target: BTC
|
52
|
+
- :base: LRC
|
53
|
+
:target: BTC
|
54
|
+
- :base: LRC
|
55
|
+
:target: ETH
|
56
|
+
- :base: QTUM
|
57
|
+
:target: BTC
|
58
|
+
- :base: YOYO
|
59
|
+
:target: BTC
|
60
|
+
- :base: OMG
|
61
|
+
:target: BTC
|
62
|
+
- :base: OMG
|
63
|
+
:target: ETH
|
64
|
+
- :base: ZRX
|
65
|
+
:target: BTC
|
66
|
+
- :base: ZRX
|
67
|
+
:target: ETH
|
68
|
+
- :base: STRAT
|
69
|
+
:target: BTC
|
70
|
+
- :base: STRAT
|
71
|
+
:target: ETH
|
72
|
+
- :base: SNGLS
|
73
|
+
:target: BTC
|
74
|
+
- :base: SNGLS
|
75
|
+
:target: ETH
|
76
|
+
- :base: BQX
|
77
|
+
:target: BTC
|
78
|
+
- :base: BQX
|
79
|
+
:target: ETH
|
80
|
+
- :base: KNC
|
81
|
+
:target: BTC
|
82
|
+
- :base: KNC
|
83
|
+
:target: ETH
|
84
|
+
- :base: FUN
|
85
|
+
:target: BTC
|
86
|
+
- :base: FUN
|
87
|
+
:target: ETH
|
88
|
+
- :base: SNM
|
89
|
+
:target: BTC
|
90
|
+
- :base: SNM
|
91
|
+
:target: ETH
|
92
|
+
- :base: NEO
|
93
|
+
:target: ETH
|
94
|
+
- :base: IOTA
|
95
|
+
:target: BTC
|
96
|
+
- :base: IOTA
|
97
|
+
:target: ETH
|
98
|
+
- :base: LINK
|
99
|
+
:target: BTC
|
100
|
+
- :base: LINK
|
101
|
+
:target: ETH
|
102
|
+
- :base: XVG
|
103
|
+
:target: BTC
|
104
|
+
- :base: XVG
|
105
|
+
:target: ETH
|
106
|
+
- :base: CTR
|
107
|
+
:target: BTC
|
108
|
+
- :base: CTR
|
109
|
+
:target: ETH
|
110
|
+
- :base: SALT
|
111
|
+
:target: BTC
|
112
|
+
- :base: SALT
|
113
|
+
:target: ETH
|
114
|
+
- :base: MDA
|
115
|
+
:target: BTC
|
116
|
+
- :base: MDA
|
117
|
+
:target: ETH
|
118
|
+
- :base: MTL
|
119
|
+
:target: BTC
|
120
|
+
- :base: MTL
|
121
|
+
:target: ETH
|
122
|
+
- :base: SUB
|
123
|
+
:target: BTC
|
124
|
+
- :base: SUB
|
125
|
+
:target: ETH
|
126
|
+
- :base: EOS
|
127
|
+
:target: BTC
|
128
|
+
- :base: SNT
|
129
|
+
:target: BTC
|
130
|
+
- :base: ETC
|
131
|
+
:target: ETH
|
132
|
+
- :base: ETC
|
133
|
+
:target: BTC
|
134
|
+
- :base: MTH
|
135
|
+
:target: BTC
|
136
|
+
- :base: MTH
|
137
|
+
:target: ETH
|
138
|
+
- :base: ENG
|
139
|
+
:target: BTC
|
140
|
+
- :base: ENG
|
141
|
+
:target: ETH
|
142
|
+
- :base: DNT
|
143
|
+
:target: BTC
|
144
|
+
- :base: ZEC
|
145
|
+
:target: BTC
|
146
|
+
- :base: ZEC
|
147
|
+
:target: ETH
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Binance
|
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::Binance::Market::API_URL}/ticker/24hr?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 = Binance::Market::NAME
|
27
|
+
ticker.bid = NumericHelper.to_d(output['bidPrice'])
|
28
|
+
ticker.ask = NumericHelper.to_d(output['askPrice'])
|
29
|
+
ticker.last = NumericHelper.to_d(output['lastPrice'])
|
30
|
+
ticker.high = NumericHelper.to_d(output['highPrice'])
|
31
|
+
ticker.low = NumericHelper.to_d(output['lowPrice'])
|
32
|
+
ticker.volume = NumericHelper.to_d(output['volume'])
|
33
|
+
ticker.timestamp = output['closeTime'].to_i / 1000
|
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 Binance
|
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(order_book_url(market_pair))
|
13
|
+
adapt(output, market_pair)
|
14
|
+
end
|
15
|
+
|
16
|
+
def order_book_url(market_pair)
|
17
|
+
base = market_pair.base
|
18
|
+
target = market_pair.target
|
19
|
+
"#{Cryptoexchange::Exchanges::Binance::Market::API_URL}/depth?symbol=#{base}#{target}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def adapt(output, market_pair)
|
23
|
+
order_book = Cryptoexchange::Models::OrderBook.new
|
24
|
+
timestamp = Time.now.to_i
|
25
|
+
|
26
|
+
order_book.base = market_pair.base
|
27
|
+
order_book.target = market_pair.target
|
28
|
+
order_book.market = Binance::Market::NAME
|
29
|
+
order_book.asks = adapt_orders(output['asks'], timestamp)
|
30
|
+
order_book.bids = adapt_orders(output['bids'], timestamp)
|
31
|
+
order_book.timestamp = timestamp
|
32
|
+
order_book.payload = output
|
33
|
+
order_book
|
34
|
+
end
|
35
|
+
|
36
|
+
def adapt_orders(orders, timestamp)
|
37
|
+
orders.collect do |order_entry|
|
38
|
+
Cryptoexchange::Models::Order.new(price: NumericHelper.to_d(order_entry[0]),
|
39
|
+
amount: NumericHelper.to_d(order_entry[1]),
|
40
|
+
timestamp: timestamp)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Binance
|
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 << Cryptoexchange::Models::MarketPair.new(
|
15
|
+
base: pair[:base],
|
16
|
+
target: pair[:target],
|
17
|
+
market: Binance::Market::NAME
|
18
|
+
)
|
19
|
+
end
|
20
|
+
market_pairs
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module BitZ
|
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(ticker_url)
|
13
|
+
adapt_all(output)
|
14
|
+
end
|
15
|
+
|
16
|
+
def ticker_url
|
17
|
+
"#{Cryptoexchange::Exchanges::BitZ::Market::API_URL}/tickerall"
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapt_all(output)
|
21
|
+
output["data"].map do |key, value|
|
22
|
+
base = key.split("_").first
|
23
|
+
target = key.split("_").last
|
24
|
+
market_pair = Cryptoexchange::Models::MarketPair.new(
|
25
|
+
base: base,
|
26
|
+
target: target,
|
27
|
+
market: BitZ::Market::NAME
|
28
|
+
)
|
29
|
+
adapt(value,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 = BitZ::Market::NAME
|
38
|
+
ticker.ask = NumericHelper.to_d(output['sell'])
|
39
|
+
ticker.bid = NumericHelper.to_d(output['buy'])
|
40
|
+
ticker.last = NumericHelper.to_d(output['last'])
|
41
|
+
ticker.high = NumericHelper.to_d(output['high'])
|
42
|
+
ticker.low = NumericHelper.to_d(output['low'])
|
43
|
+
ticker.volume = NumericHelper.to_d(output['vol'])
|
44
|
+
ticker.timestamp = DateTime.now.to_time.to_i
|
45
|
+
ticker.payload = output
|
46
|
+
ticker
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module BitZ
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
PAIRS_URL = "#{Cryptoexchange::Exchanges::BitZ::Market::API_URL}/tickerall"
|
6
|
+
|
7
|
+
def fetch
|
8
|
+
output = super
|
9
|
+
adapt(output)
|
10
|
+
end
|
11
|
+
|
12
|
+
def adapt(output)
|
13
|
+
market_pairs = []
|
14
|
+
pairs = output["data"]
|
15
|
+
pairs.each_key do |pair|
|
16
|
+
base = pair.split("_").first
|
17
|
+
target = pair.split("_").last
|
18
|
+
market_pairs << Cryptoexchange::Models::MarketPair.new(
|
19
|
+
base: base,
|
20
|
+
target: target,
|
21
|
+
market: BitZ::Market::NAME
|
22
|
+
)
|
23
|
+
end
|
24
|
+
market_pairs
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -32,8 +32,11 @@ module Cryptoexchange::Exchanges
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def adapt_orders(orders, timestamp)
|
35
|
-
|
36
|
-
|
35
|
+
orders.collect do |order_entry|
|
36
|
+
Cryptoexchange::Models::Order.new(price: order_entry['price'],
|
37
|
+
amount: order_entry['amount'],
|
38
|
+
timestamp: timestamp)
|
39
|
+
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -31,8 +31,12 @@ module Cryptoexchange::Exchanges
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def adapt_orders(orders)
|
34
|
-
|
35
|
-
|
34
|
+
orders.collect do |order_entry|
|
35
|
+
price, amount, timestamp = order_entry.values
|
36
|
+
Cryptoexchange::Models::Order.new(price: price,
|
37
|
+
amount: amount,
|
38
|
+
timestamp: timestamp)
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Litebiteu
|
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 ticker_url
|
13
|
+
adapt_all(output)
|
14
|
+
end
|
15
|
+
|
16
|
+
def ticker_url
|
17
|
+
"#{Cryptoexchange::Exchanges::Litebiteu::Market::API_URL}/markets"
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapt_all(output)
|
21
|
+
fetch_timestamp = DateTime.now.to_time.to_i
|
22
|
+
|
23
|
+
output['result'].map do |base, market|
|
24
|
+
market_pair = Cryptoexchange::Models::MarketPair.new(
|
25
|
+
base: base.upcase,
|
26
|
+
target: 'EUR',
|
27
|
+
market: Bithumb::Market::NAME
|
28
|
+
)
|
29
|
+
adapt(market, market_pair, fetch_timestamp)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def adapt(market, market_pair, fetch_timestamp)
|
34
|
+
ticker = Cryptoexchange::Models::Ticker.new
|
35
|
+
|
36
|
+
ticker.base = market_pair.base
|
37
|
+
ticker.target = market_pair.target
|
38
|
+
ticker.market = Litebiteu::Market::NAME
|
39
|
+
ticker.ask = NumericHelper.to_d(market['buy'])
|
40
|
+
ticker.bid = NumericHelper.to_d(market['sell'])
|
41
|
+
ticker.volume = NumericHelper.to_d(market['volume'])
|
42
|
+
ticker.last = (ticker.ask + ticker.bid) / 2
|
43
|
+
ticker.timestamp = fetch_timestamp
|
44
|
+
ticker.payload = market
|
45
|
+
ticker
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Litebiteu
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
PAIRS_URL = "#{Cryptoexchange::Exchanges::Litebiteu::Market::API_URL}/markets"
|
6
|
+
|
7
|
+
def fetch
|
8
|
+
output = super
|
9
|
+
adapt(output)
|
10
|
+
end
|
11
|
+
|
12
|
+
def adapt(output)
|
13
|
+
market_pairs = []
|
14
|
+
|
15
|
+
output['result'].each do |currency, _|
|
16
|
+
|
17
|
+
if currency
|
18
|
+
market_pairs << Cryptoexchange::Models::MarketPair.new(
|
19
|
+
base: currency.upcase,
|
20
|
+
target: 'EUR',
|
21
|
+
market: Litebiteu::Market::NAME
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
market_pairs
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Mercatox
|
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::Mercatox::Market::API_URL}/json24"
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapt_all(output)
|
21
|
+
output['pairs'].map do |pair, ticker|
|
22
|
+
base, target = pair.split('_')
|
23
|
+
market_pair = Cryptoexchange::Models::MarketPair.new(
|
24
|
+
base: base,
|
25
|
+
target: target,
|
26
|
+
market: Mercatox::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 = Mercatox::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['quoteVolume'])
|
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 Mercatox
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
PAIRS_URL = "#{Cryptoexchange::Exchanges::Mercatox::Market::API_URL}/json24"
|
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, 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 = Mercatox::Market::NAME
|
20
|
+
market_pairs << market_pair
|
21
|
+
end
|
22
|
+
market_pairs
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -4,14 +4,14 @@ module Cryptoexchange
|
|
4
4
|
attr_accessor :base, :target, :market, :bids,
|
5
5
|
:asks, :timestamp, :payload
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@base =
|
9
|
-
@target =
|
10
|
-
@market =
|
11
|
-
@bids =
|
12
|
-
@asks =
|
13
|
-
@timestamp =
|
14
|
-
@payload =
|
7
|
+
def initialize(args = {})
|
8
|
+
@base = args[:base]
|
9
|
+
@target = args[:target]
|
10
|
+
@market = args[:market]
|
11
|
+
@bids = args[:bids] || []
|
12
|
+
@asks = args[:asks] || []
|
13
|
+
@timestamp = args[:timestamp]
|
14
|
+
@payload = args[:payload]
|
15
15
|
end
|
16
16
|
|
17
17
|
def base
|
@@ -1,19 +1,9 @@
|
|
1
1
|
module Cryptoexchange
|
2
2
|
module Models
|
3
3
|
class Trade
|
4
|
-
attr_accessor :trade_id, :base, :target, :type,
|
5
|
-
|
6
|
-
|
7
|
-
@trade_id = params[:id]
|
8
|
-
@base = params[:base]
|
9
|
-
@target = params[:target]
|
10
|
-
@type = params[:type]
|
11
|
-
@price = params[:price]
|
12
|
-
@amount = params[:amount]
|
13
|
-
@timestamp = params[:timestamp]
|
14
|
-
@payload = params[:payload]
|
15
|
-
@market = params[:market]
|
16
|
-
end
|
4
|
+
attr_accessor :trade_id, :base, :target, :type,
|
5
|
+
:price, :amount, :timestamp, :payload,
|
6
|
+
:market
|
17
7
|
|
18
8
|
def base
|
19
9
|
@base.upcase
|
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.
|
4
|
+
version: 0.15.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-10-
|
11
|
+
date: 2017-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.15'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,10 +158,23 @@ files:
|
|
158
158
|
- cryptoexchange.gemspec
|
159
159
|
- lib/cryptoexchange.rb
|
160
160
|
- lib/cryptoexchange/client.rb
|
161
|
+
- lib/cryptoexchange/exchanges/allcoin/allcoin.yml
|
162
|
+
- lib/cryptoexchange/exchanges/allcoin/market.rb
|
163
|
+
- lib/cryptoexchange/exchanges/allcoin/services/market.rb
|
164
|
+
- lib/cryptoexchange/exchanges/allcoin/services/order_book.rb
|
165
|
+
- lib/cryptoexchange/exchanges/allcoin/services/pairs.rb
|
161
166
|
- lib/cryptoexchange/exchanges/anx/anx.yml
|
162
167
|
- lib/cryptoexchange/exchanges/anx/market.rb
|
163
168
|
- lib/cryptoexchange/exchanges/anx/services/market.rb
|
164
169
|
- lib/cryptoexchange/exchanges/anx/services/pairs.rb
|
170
|
+
- lib/cryptoexchange/exchanges/binance/binance.yml
|
171
|
+
- lib/cryptoexchange/exchanges/binance/market.rb
|
172
|
+
- lib/cryptoexchange/exchanges/binance/services/market.rb
|
173
|
+
- lib/cryptoexchange/exchanges/binance/services/order_book.rb
|
174
|
+
- lib/cryptoexchange/exchanges/binance/services/pairs.rb
|
175
|
+
- lib/cryptoexchange/exchanges/bit_z/market.rb
|
176
|
+
- lib/cryptoexchange/exchanges/bit_z/services/market.rb
|
177
|
+
- lib/cryptoexchange/exchanges/bit_z/services/pairs.rb
|
165
178
|
- lib/cryptoexchange/exchanges/bitbay/bitbay.yml
|
166
179
|
- lib/cryptoexchange/exchanges/bitbay/market.rb
|
167
180
|
- lib/cryptoexchange/exchanges/bitbay/services/market.rb
|
@@ -271,6 +284,9 @@ files:
|
|
271
284
|
- lib/cryptoexchange/exchanges/liqui/market.rb
|
272
285
|
- lib/cryptoexchange/exchanges/liqui/services/market.rb
|
273
286
|
- lib/cryptoexchange/exchanges/liqui/services/pairs.rb
|
287
|
+
- lib/cryptoexchange/exchanges/litebiteu/market.rb
|
288
|
+
- lib/cryptoexchange/exchanges/litebiteu/services/market.rb
|
289
|
+
- lib/cryptoexchange/exchanges/litebiteu/services/pairs.rb
|
274
290
|
- lib/cryptoexchange/exchanges/livecoin/market.rb
|
275
291
|
- lib/cryptoexchange/exchanges/livecoin/services/market.rb
|
276
292
|
- lib/cryptoexchange/exchanges/livecoin/services/pairs.rb
|
@@ -281,6 +297,9 @@ files:
|
|
281
297
|
- lib/cryptoexchange/exchanges/mercado_bitcoin/mercado_bitcoin.yml
|
282
298
|
- lib/cryptoexchange/exchanges/mercado_bitcoin/services/market.rb
|
283
299
|
- lib/cryptoexchange/exchanges/mercado_bitcoin/services/pairs.rb
|
300
|
+
- lib/cryptoexchange/exchanges/mercatox/market.rb
|
301
|
+
- lib/cryptoexchange/exchanges/mercatox/services/market.rb
|
302
|
+
- lib/cryptoexchange/exchanges/mercatox/services/pairs.rb
|
284
303
|
- lib/cryptoexchange/exchanges/novaexchange/market.rb
|
285
304
|
- lib/cryptoexchange/exchanges/novaexchange/services/market.rb
|
286
305
|
- lib/cryptoexchange/exchanges/novaexchange/services/pairs.rb
|
@@ -332,6 +351,7 @@ files:
|
|
332
351
|
- lib/cryptoexchange/helpers/string_helper.rb
|
333
352
|
- lib/cryptoexchange/lru_ttl_cache.rb
|
334
353
|
- lib/cryptoexchange/models/market_pair.rb
|
354
|
+
- lib/cryptoexchange/models/order.rb
|
335
355
|
- lib/cryptoexchange/models/order_book.rb
|
336
356
|
- lib/cryptoexchange/models/ticker.rb
|
337
357
|
- lib/cryptoexchange/models/trade.rb
|