cryptoexchange 0.11.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b047ac150f961ed2f5b074d5ae4c1b243f30e3f
4
- data.tar.gz: cf2e4e5bc58c295589eb814a761b6aea187cbb11
3
+ metadata.gz: f0b17ae96ebba5813aab73c5e502deb4813c9c2b
4
+ data.tar.gz: 068c4729248fccddc800d366447e74bdf5e589a4
5
5
  SHA512:
6
- metadata.gz: b89a3703b7e3d5a559bb1ac87eabab2f7f8e9b7164dfb98c12660ec9b34d4bde5b06c906d6f75a612f59fbf40c0e820095d4b76e8f9361746f5493ac3314e569
7
- data.tar.gz: 6c6bc775d4b8a2416facb85be32409c1058369946ddf370febb99c9c47aba347707388f5d5fc31156902525e019f7f2e80a6a4165ce4f88d63221a69375f9e00
6
+ metadata.gz: 6337c4523d06f01ca41ee66748fedf23449b79957224f86e167ebb2dd636e09e848f8fa4a085318f82a866cfa53c631e891dbefaf64b02285a5b614754e1c7ef
7
+ data.tar.gz: f477306326f5fa1fa7641f91733122d402071b3df397670773ef4c964e364fc5f8de06bc2da524bf2e707f1fbadd885402f1c3392f27006f494b16c75fc2b261
data/CONTRIBUTING.md CHANGED
@@ -20,6 +20,10 @@ There are many ways to contribute! Our documentation surely has room for improve
20
20
  * Be sure you have followed the code style for the project.
21
21
  * Send a pull request indicating that you have a CLA on file.
22
22
 
23
+ # Implementing a new exchange
24
+ We have a [step by step guide](https://github.com/coingecko/cryptoexchange/wiki/Implementing-a-New-Exchange).
25
+ That guide may be useful in helping you understand how we structure our classes to adapt to new exchanges.
26
+
23
27
  # How to suggest a feature or enhancement
24
28
  If you have any suggestion on how we can make this gem better, feel free to open an issue for discussion.
25
29
 
data/README.md CHANGED
@@ -51,7 +51,7 @@ Or install it yourself as:
51
51
  | EtherDelta | Y | | | | Y |
52
52
  | Gatecoin | Y | | | | Y |
53
53
  | GDAX | Y | | | | Y |
54
- | Gemini | Y | Y | | | Y |
54
+ | Gemini | Y | Y | Y | | Y |
55
55
  | HitBTC | Y | | | | Y |
56
56
  | Huobi | Y | | | | Y |
57
57
  | Itbit | | | | | |
@@ -66,10 +66,12 @@ Or install it yourself as:
66
66
  | Nova Exchange | Y | | | | Y |
67
67
  | OKCoin | Y | | | | User-Defined|
68
68
  | Poloniex | Y | | | | Y |
69
+ | Qryptos | Y | | | | Y |
69
70
  | QuadrigaCX | Y | | | | User-Defined|
70
71
  | Quoine | Y | | | | Y |
71
72
  | SZZC | Y | | | | Y |
72
73
  | Tidex | Y | | | | Y |
74
+ | TuxExchange | Y | | | | Y |
73
75
  | Unocoin | | | | | |
74
76
  | Viabtc | Y | | | | User-Defined|
75
77
  | Yobit | Y | | | | Y |
@@ -142,6 +144,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
142
144
 
143
145
  Bug reports and pull requests are welcome on GitHub at https://github.com/coingecko/cryptoexchange. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
144
146
 
147
+ When implementing a new exchange, refer to this [guide](https://github.com/coingecko/cryptoexchange/wiki/Implementing-a-New-Exchange).
148
+
145
149
  The [contributing guide](https://github.com/coingecko/cryptoexchange/blob/master/CONTRIBUTING.md) may also be useful to you.
146
150
 
147
151
  You can chat with the core team member or other participating in this repository chat on [https://gitter.im/cryptoexchange-api/Lobby/~chat#](https://gitter.im/cryptoexchange-api/Lobby/~chat#)
@@ -26,8 +26,9 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  spec.add_development_dependency "pry"
28
28
  spec.add_development_dependency "rb-readline"
29
-
29
+ spec.add_development_dependency "vcr", "~> 3.0.3"
30
+ spec.add_development_dependency "webmock"
30
31
 
31
- spec.add_dependency "http"
32
+ spec.add_dependency "http", '~> 2.1.0'
32
33
  spec.add_dependency "lru_redux"
33
34
  end
@@ -67,5 +67,13 @@ module Cryptoexchange
67
67
  end
68
68
  end
69
69
  end
70
+
71
+ def trades(market_pair)
72
+ exchange = market_pair.market
73
+ market_classname = "Cryptoexchange::Exchanges::#{StringHelper.camelize(exchange)}::Services::Trades"
74
+ market_class = Object.const_get(market_classname)
75
+ trades = market_class.new
76
+ trades.fetch(market_pair)
77
+ end
70
78
  end
71
79
  end
@@ -0,0 +1,32 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Gemini
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::Gemini::Market::API_URL}/trades/#{market_pair.base}#{market_pair.target}"
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.type = trade['type']
21
+ tr.price = trade['price']
22
+ tr.amount = trade['amount']
23
+ tr.timestamp = Time.now.to_i
24
+ tr.payload = trade
25
+ tr.market = Gemini::Market::NAME
26
+ tr
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Qryptos
3
+ class Market
4
+ NAME = 'qryptos'
5
+ API_URL = 'https://api.qryptos.com'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,50 @@
1
+ module Cryptoexchange::Exchanges
2
+ module Qryptos
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::Qryptos::Market::API_URL}/products"
18
+ end
19
+
20
+ def adapt_all(output)
21
+ output.map do |pair|
22
+ market_pair = Cryptoexchange::Models::MarketPair.new(
23
+ base: pair['base_currency'],
24
+ target: pair['quoted_currency'],
25
+ market: Qryptos::Market::NAME
26
+ )
27
+ adapt(pair, market_pair)
28
+ end
29
+ end
30
+
31
+ def adapt(output, market_pair)
32
+ ticker = Cryptoexchange::Models::Ticker.new
33
+ ticker.base = market_pair.base
34
+ ticker.target = market_pair.target
35
+ ticker.market = Qryptos::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 Qryptos
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::Qryptos::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 << Cryptoexchange::Models::MarketPair.new(
16
+ base: pair['base_currency'],
17
+ target: pair['quoted_currency'],
18
+ market: Qryptos::Market::NAME
19
+ )
20
+ end
21
+ market_pairs
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ module Cryptoexchange::Exchanges
2
+ module TuxExchange
3
+ class Market
4
+ NAME = 'tux_exchange'
5
+ API_URL = 'https://tuxexchange.com/api'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,51 @@
1
+ module Cryptoexchange::Exchanges
2
+ module TuxExchange
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::TuxExchange::Market::API_URL}?method=getticker"
18
+ end
19
+
20
+ def adapt_all(output)
21
+ output.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: TuxExchange::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 = TuxExchange::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['baseVolume'])
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,28 @@
1
+ module Cryptoexchange::Exchanges
2
+ module TuxExchange
3
+ module Services
4
+ class Pairs < Cryptoexchange::Services::Pairs
5
+ PAIRS_URL = "#{Cryptoexchange::Exchanges::TuxExchange::Market::API_URL}?method=getticker"
6
+
7
+ def fetch
8
+ output = super
9
+ adapt(output)
10
+ end
11
+
12
+ def adapt(output)
13
+ market_pairs = []
14
+ output.each_key do |pairs|
15
+ base = pairs.split("_").first
16
+ target = pairs.split("_").last
17
+ market_pairs << Cryptoexchange::Models::MarketPair.new(
18
+ base: base,
19
+ target: target,
20
+ market: TuxExchange::Market::NAME
21
+ )
22
+ end
23
+ market_pairs
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ module Cryptoexchange
2
+ module Models
3
+ class Trade
4
+ attr_accessor :trade_id, :base, :target, :type, :price, :amount, :timestamp, :payload, :market
5
+
6
+ def initialize(params = {})
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
17
+
18
+ def base
19
+ @base.upcase
20
+ end
21
+
22
+ def target
23
+ @target.upcase
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Cryptoexchange
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  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.11.0
4
+ version: 0.12.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-09-30 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,19 +81,47 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: http
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
- type: :runtime
104
+ type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: http
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 2.1.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 2.1.0
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: lru_redux
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -207,6 +235,7 @@ files:
207
235
  - lib/cryptoexchange/exchanges/gemini/services/market.rb
208
236
  - lib/cryptoexchange/exchanges/gemini/services/order_book.rb
209
237
  - lib/cryptoexchange/exchanges/gemini/services/pairs.rb
238
+ - lib/cryptoexchange/exchanges/gemini/services/trades.rb
210
239
  - lib/cryptoexchange/exchanges/hitbtc/market.rb
211
240
  - lib/cryptoexchange/exchanges/hitbtc/services/market.rb
212
241
  - lib/cryptoexchange/exchanges/hitbtc/services/pairs.rb
@@ -249,6 +278,9 @@ files:
249
278
  - lib/cryptoexchange/exchanges/poloniex/market.rb
250
279
  - lib/cryptoexchange/exchanges/poloniex/services/market.rb
251
280
  - lib/cryptoexchange/exchanges/poloniex/services/pairs.rb
281
+ - lib/cryptoexchange/exchanges/qryptos/market.rb
282
+ - lib/cryptoexchange/exchanges/qryptos/services/market.rb
283
+ - lib/cryptoexchange/exchanges/qryptos/services/pairs.rb
252
284
  - lib/cryptoexchange/exchanges/quadrigacx/market.rb
253
285
  - lib/cryptoexchange/exchanges/quadrigacx/quadrigacx.yml
254
286
  - lib/cryptoexchange/exchanges/quadrigacx/services/market.rb
@@ -262,6 +294,9 @@ files:
262
294
  - lib/cryptoexchange/exchanges/tidex/market.rb
263
295
  - lib/cryptoexchange/exchanges/tidex/services/market.rb
264
296
  - lib/cryptoexchange/exchanges/tidex/services/pairs.rb
297
+ - lib/cryptoexchange/exchanges/tux_exchange/market.rb
298
+ - lib/cryptoexchange/exchanges/tux_exchange/services/market.rb
299
+ - lib/cryptoexchange/exchanges/tux_exchange/services/pairs.rb
265
300
  - lib/cryptoexchange/exchanges/viabtc/market.rb
266
301
  - lib/cryptoexchange/exchanges/viabtc/services/market.rb
267
302
  - lib/cryptoexchange/exchanges/viabtc/services/pairs.rb
@@ -283,6 +318,7 @@ files:
283
318
  - lib/cryptoexchange/models/market_pair.rb
284
319
  - lib/cryptoexchange/models/order_book.rb
285
320
  - lib/cryptoexchange/models/ticker.rb
321
+ - lib/cryptoexchange/models/trade.rb
286
322
  - lib/cryptoexchange/services/market.rb
287
323
  - lib/cryptoexchange/services/pairs.rb
288
324
  - lib/cryptoexchange/version.rb