cryptoexchange 0.3.3 → 0.3.4
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/lib/cryptoexchange.rb +4 -6
- data/lib/cryptoexchange/client.rb +0 -6
- data/lib/cryptoexchange/exchanges/liqui/services/market.rb +1 -1
- data/lib/cryptoexchange/exchanges/quoine/market.rb +8 -0
- data/lib/cryptoexchange/exchanges/quoine/models/market_pair.rb +8 -0
- data/lib/cryptoexchange/exchanges/quoine/models/ticker.rb +8 -0
- data/lib/cryptoexchange/exchanges/quoine/services/market.rb +50 -0
- data/lib/cryptoexchange/exchanges/quoine/services/pairs.rb +26 -0
- data/lib/cryptoexchange/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22bdccda478343a7dd66ddaf26059f5801a20066
|
4
|
+
data.tar.gz: 6cff0eefe5f32dd033b66a31cb0d88f67a487920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29013a559084db947eeca02aa0e7bee42c9451fc00a0d47f5135f70f72f52de51a103f88f8793cc083f0318c4e6710e85e5c07a07b4b9d7365d97cd2ed67fc6e
|
7
|
+
data.tar.gz: f412cbe653f408ba08b50c2be728ef4dbcd1a745c6be779c3170d300280ec3121bb6d42f85ddae75af0e30770997bb2ff07cadb894c49b8db2a27722a2978c04
|
data/lib/cryptoexchange.rb
CHANGED
@@ -9,12 +9,10 @@ require "cryptoexchange/models/market_pair"
|
|
9
9
|
require "cryptoexchange/services/market"
|
10
10
|
require "cryptoexchange/services/pairs"
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
require "cryptoexchange/exchanges/#{market}/services/market"
|
17
|
-
require "cryptoexchange/exchanges/#{market}/services/pairs"
|
12
|
+
path_files = Dir[File.join(File.dirname(__dir__), 'lib', 'cryptoexchange', '**', '*.rb')]
|
13
|
+
|
14
|
+
path_files.sort_by!{ |file_name| file_name.downcase }.each do |path|
|
15
|
+
require_relative path
|
18
16
|
end
|
19
17
|
|
20
18
|
require "http"
|
@@ -1,11 +1,5 @@
|
|
1
1
|
module Cryptoexchange
|
2
2
|
class Client
|
3
|
-
class << self
|
4
|
-
def available_exchanges
|
5
|
-
exchanges_dir = File.join(File.dirname(__dir__), "cryptoexchange", "exchanges")
|
6
|
-
Dir.entries(exchanges_dir).reject{|entry| entry == "." || entry == ".."}
|
7
|
-
end
|
8
|
-
end
|
9
3
|
|
10
4
|
def initialize(ticker_ttl: 3)
|
11
5
|
LruTtlCache.ticker_cache(ticker_ttl)
|
@@ -32,7 +32,7 @@ module Cryptoexchange::Exchanges
|
|
32
32
|
ticker.ask = NumericHelper.to_d(market['sell'])
|
33
33
|
ticker.high = NumericHelper.to_d(market['high'])
|
34
34
|
ticker.low = NumericHelper.to_d(market['low'])
|
35
|
-
ticker.volume = NumericHelper.to_d(market['
|
35
|
+
ticker.volume = NumericHelper.to_d(market['vol_cur'])
|
36
36
|
ticker.timestamp = DateTime.now.to_time.to_i
|
37
37
|
ticker.payload = market
|
38
38
|
ticker
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Quoine
|
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::Quoine::Market::API_URL}/products"
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapt_all(output)
|
21
|
+
output.map do |pair|
|
22
|
+
market_pair = Cryptoexchange::Exchanges::Quoine::Models::MarketPair.new(
|
23
|
+
base: pair['base_currency'],
|
24
|
+
target: pair['quoted_currency'],
|
25
|
+
market: Quoine::Market::NAME
|
26
|
+
)
|
27
|
+
adapt(pair, market_pair)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def adapt(output, market_pair)
|
32
|
+
ticker = Quoine::Models::Ticker.new
|
33
|
+
ticker.base = market_pair.base
|
34
|
+
ticker.target = market_pair.target
|
35
|
+
ticker.market = Quoine::Market::NAME
|
36
|
+
#use last price 24h
|
37
|
+
ticker.last = NumericHelper.to_d(output['last_price_24h'])
|
38
|
+
ticker.bid = NumericHelper.to_d(output['market_bid'])
|
39
|
+
ticker.ask = NumericHelper.to_d(output['market_ask'])
|
40
|
+
ticker.high = NumericHelper.to_d(output['high_market_ask'])
|
41
|
+
ticker.low = NumericHelper.to_d(output['low_market_bid'])
|
42
|
+
ticker.volume = NumericHelper.to_d(output['volume_24h'])
|
43
|
+
ticker.timestamp = DateTime.now.to_time.to_i
|
44
|
+
ticker.payload = output
|
45
|
+
ticker
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cryptoexchange::Exchanges
|
2
|
+
module Quoine
|
3
|
+
module Services
|
4
|
+
class Pairs < Cryptoexchange::Services::Pairs
|
5
|
+
PAIRS_URL = "#{Cryptoexchange::Exchanges::Quoine::Market::API_URL}/products"
|
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_pairs << Quoine::Models::MarketPair.new(
|
16
|
+
base: pair['base_currency'],
|
17
|
+
target: pair['quoted_currency'],
|
18
|
+
market: Quoine::Market::NAME
|
19
|
+
)
|
20
|
+
end
|
21
|
+
market_pairs
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
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.3.
|
4
|
+
version: 0.3.4
|
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-07-
|
11
|
+
date: 2017-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -256,6 +256,11 @@ files:
|
|
256
256
|
- lib/cryptoexchange/exchanges/okcoin/okcoin.yml
|
257
257
|
- lib/cryptoexchange/exchanges/okcoin/services/market.rb
|
258
258
|
- lib/cryptoexchange/exchanges/okcoin/services/pairs.rb
|
259
|
+
- lib/cryptoexchange/exchanges/quoine/market.rb
|
260
|
+
- lib/cryptoexchange/exchanges/quoine/models/market_pair.rb
|
261
|
+
- lib/cryptoexchange/exchanges/quoine/models/ticker.rb
|
262
|
+
- lib/cryptoexchange/exchanges/quoine/services/market.rb
|
263
|
+
- lib/cryptoexchange/exchanges/quoine/services/pairs.rb
|
259
264
|
- lib/cryptoexchange/helpers/hash_helper.rb
|
260
265
|
- lib/cryptoexchange/helpers/numeric_helper.rb
|
261
266
|
- lib/cryptoexchange/helpers/string_helper.rb
|