cryptocompare 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +119 -5
- data/Rakefile +1 -1
- data/config/exchanges.yml +55 -0
- data/lib/cryptocompare.rb +0 -1
- data/lib/cryptocompare/price.rb +27 -1
- data/lib/cryptocompare/version.rb +1 -1
- metadata +22 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58a7edd2c27081e3d18bd5a9c5f55bd4d6188ed1
|
4
|
+
data.tar.gz: 4d975e8065f816ebd0a4fd29a8fabcf01d62cb52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 407a2341f2489649265710af467979b09646cf1c3180c24e6fe69a535b7cc078571b8d40f74cd561d00a41f3e6d32c2a4d1d0de4406d2d9aeef3d071b23b5594
|
7
|
+
data.tar.gz: 2355645467ebc2f6f5f09ea8bbc484f553a3c72f2fc5dbac5c30583308164c8d2a9082bf6c078841016f3ca6fd9732c87f65a40f482e9f60e91f075258302ca7
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Cryptocompare
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/cryptocompare.svg)](http://badge.fury.io/rb/cryptocompare) [![Build Status](https://travis-ci.org/alexanderdavidpan/cryptocompare.svg)](https://travis-ci.org/alexanderdavidpan/cryptocompare)
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
This is a Ruby gem that utilizes the CryptoCompare API to fetch data related to cryptocurrencies.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -22,7 +23,121 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
To use Cryptocompare, just require it like so:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'cryptocompare'
|
30
|
+
```
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
|
34
|
+
1. Cryptocurrency to Fiat
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Cryptocompare::Price.find('BTC', 'USD')
|
38
|
+
# => {"BTC"=>{"USD"=>2594.07}}
|
39
|
+
```
|
40
|
+
|
41
|
+
2. Fiat to Cryptocurrency
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Cryptocompare::Price.find('USD', 'BTC')
|
45
|
+
# => {"USD"=>{"BTC"=>0.0004176}}
|
46
|
+
```
|
47
|
+
3. Cryptocurrency to Cryptocurrency
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Cryptocompare::Price.find('BTC', 'ETH')
|
51
|
+
# =>{"BTC"=>{"ETH"=>9.29}}
|
52
|
+
```
|
53
|
+
|
54
|
+
4. Fiat to Fiat
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
Cryptocompare::Price.find('USD', 'EUR')
|
58
|
+
# => {"USD"=>{"EUR"=>0.8772}}
|
59
|
+
```
|
60
|
+
|
61
|
+
5. Multiple cryptocurrencies to multiple fiat
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Cryptocompare::Price.find(['BTC','ETH', 'LTC'], ['USD', 'EUR', 'CNY'])
|
65
|
+
# => {"BTC"=>{"USD"=>2501.61, "EUR"=>2197.04, "CNY"=>17329.48}, "ETH"=>{"USD"=>236.59, "EUR"=>209.39, "CNY"=>1655.15}, "LTC"=>{"USD"=>45.74, "EUR"=>40.33, "CNY"=>310.5}}
|
66
|
+
```
|
67
|
+
|
68
|
+
6. Multiple fiat to multiple cryptocurrencies
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
Cryptocompare::Price.find(['USD', 'EUR'], ['BTC','ETH', 'LTC'])
|
72
|
+
# => {"USD"=>{"BTC"=>0.0003996, "ETH"=>0.004238, "LTC"=>0.02184}, "EUR"=>{"BTC"=>0.0004548, "ETH"=>0.00477, "LTC"=>0.0248}}
|
73
|
+
```
|
74
|
+
|
75
|
+
7. Find prices based on exchange
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
Cryptocompare::Price.find('DASH', 'USD', {'e' => 'Kraken'})
|
79
|
+
# => {"DASH"=>{"USD"=>152.4}}
|
80
|
+
```
|
81
|
+
|
82
|
+
## Supported Exchanges
|
83
|
+
|
84
|
+
* BTC38
|
85
|
+
* BTCC
|
86
|
+
* BTCE
|
87
|
+
* BTCMarkets
|
88
|
+
* BTCXIndia
|
89
|
+
* BTER
|
90
|
+
* Bit2C
|
91
|
+
* BitBay
|
92
|
+
* bitFlyer
|
93
|
+
* bitFlyerFX
|
94
|
+
* BitMarket
|
95
|
+
* BitSquare
|
96
|
+
* Bitfinex
|
97
|
+
* Bitso
|
98
|
+
* Bitstamp
|
99
|
+
* Bittrex
|
100
|
+
* Bleutrade
|
101
|
+
* CCEDK
|
102
|
+
* Cexio
|
103
|
+
* CoinCheck
|
104
|
+
* Coinbase
|
105
|
+
* Coinfloor
|
106
|
+
* Coinone
|
107
|
+
* Coinse
|
108
|
+
* Coinsetter
|
109
|
+
* Cryptopia
|
110
|
+
* Cryptsy
|
111
|
+
* EtherDelta
|
112
|
+
* EthexIndia
|
113
|
+
* Gatecoin
|
114
|
+
* Gemini
|
115
|
+
* HitBTC
|
116
|
+
* Huobi
|
117
|
+
* itBit
|
118
|
+
* Korbit
|
119
|
+
* Kraken
|
120
|
+
* LakeBTC
|
121
|
+
* Liqui
|
122
|
+
* LiveCoin
|
123
|
+
* LocalBitcoins
|
124
|
+
* Luno
|
125
|
+
* MercadoBitcoin
|
126
|
+
* MonetaGo
|
127
|
+
* OKCoin
|
128
|
+
* Paymium
|
129
|
+
* Poloniex
|
130
|
+
* QuadrigaCX
|
131
|
+
* Quoine
|
132
|
+
* TheRockTrading
|
133
|
+
* Tidex
|
134
|
+
* Unocoin
|
135
|
+
* Vaultoro
|
136
|
+
* Yacuna
|
137
|
+
* Yobit
|
138
|
+
* Yunbi
|
139
|
+
|
140
|
+
If no exchange option is specified, then the default 'CCCAGG' is used. This is cryptocompare's aggregated data.
|
26
141
|
|
27
142
|
## Development
|
28
143
|
|
@@ -32,10 +147,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
147
|
|
33
148
|
## Contributing
|
34
149
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
150
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/alexanderdavidpan/cryptocompare. 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.
|
36
151
|
|
37
152
|
|
38
153
|
## License
|
39
154
|
|
40
155
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/Rakefile
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
BTC38: BTC38
|
2
|
+
BTCC: BTCC
|
3
|
+
BTCE: BTCE
|
4
|
+
BTCMARKETS: BTCMarkets
|
5
|
+
BTCXINDIA: BTCXIndia
|
6
|
+
BTER: BTER
|
7
|
+
BIT2C: Bit2C
|
8
|
+
BITBAY: BitBay
|
9
|
+
BITFLYER: bitFlyer
|
10
|
+
BITFLYERFX: bitFlyerFX
|
11
|
+
BITMARKET: BitMarket
|
12
|
+
BITSQUARE: BitSquare
|
13
|
+
BITFINEX: Bitfinex
|
14
|
+
BITSO: Bitso
|
15
|
+
BITSTAMP: Bitstamp
|
16
|
+
BITTREX: Bittrex
|
17
|
+
BLEUTRADE: Bleutrade
|
18
|
+
CCEDK: CCEDK
|
19
|
+
CEXIO: Cexio
|
20
|
+
COINCHECK: CoinCheck
|
21
|
+
COINBASE: Coinbase
|
22
|
+
COINFLOOR: Coinfloor
|
23
|
+
COINONE: Coinone
|
24
|
+
COINSE: Coinse
|
25
|
+
COINSETTER: Coinsetter
|
26
|
+
CRYPTOPIA: Cryptopia
|
27
|
+
CRYPTSY: Cryptsy
|
28
|
+
ETHERDELTA: EtherDelta
|
29
|
+
ETHEXINDIA: EthexIndia
|
30
|
+
GATECOIN: Gatecoin
|
31
|
+
GEMINI: Gemini
|
32
|
+
HITBTC: HitBTC
|
33
|
+
HUOBI: Huobi
|
34
|
+
ITBIT: itBit
|
35
|
+
KORBIT: Korbit
|
36
|
+
KRAKEN: Kraken
|
37
|
+
LAKEBTC: LakeBTC
|
38
|
+
LIQUI: Liqui
|
39
|
+
LIVECOIN: LiveCoin
|
40
|
+
LOCALBITCOINS: LocalBitcoins
|
41
|
+
LUNO: Luno
|
42
|
+
MERCADOBITCOIN: MercadoBitcoin
|
43
|
+
MONETAGO: MonetaGo
|
44
|
+
OKCOIN: OKCoin
|
45
|
+
PAYMIUM: Paymium
|
46
|
+
POLONIEX: Poloniex
|
47
|
+
QUADRIGACX: QuadrigaCX
|
48
|
+
QUOINE: Quoine
|
49
|
+
THEROCKTRADING: TheRockTrading
|
50
|
+
TIDEX: Tidex
|
51
|
+
UNOCOIN: Unocoin
|
52
|
+
VAULTORO: Vaultoro
|
53
|
+
YACUNA: Yacuna
|
54
|
+
YOBIT: Yobit
|
55
|
+
YUNBI: Yunbi
|
data/lib/cryptocompare.rb
CHANGED
data/lib/cryptocompare/price.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'json'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
module Cryptocompare
|
5
6
|
API_URL = 'https://min-api.cryptocompare.com/data/pricemulti'
|
7
|
+
EXCHANGES = YAML::load_file(File.join(__dir__, '../../config/exchanges.yml'))
|
6
8
|
|
7
9
|
module Price
|
8
10
|
# Finds the currency price(s) of a given currency symbol
|
@@ -10,6 +12,8 @@ module Cryptocompare
|
|
10
12
|
# Params:
|
11
13
|
# from_syms [String, Array] - currency symbols (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
|
12
14
|
# to_syms [String, Array] - currency symbols (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
|
15
|
+
# opts [Hash] - Options hash
|
16
|
+
# opts[e] [String] - name of exchange (ex: 'Coinbase','Poloniex') Default: CCCAGG.
|
13
17
|
#
|
14
18
|
# Returns:
|
15
19
|
# [Hash] Hash with currency prices
|
@@ -33,12 +37,34 @@ module Cryptocompare
|
|
33
37
|
# 4. Fiat to Fiat
|
34
38
|
# Cryptocompare::Price.find('USD', 'EUR')
|
35
39
|
# => {"USD"=>{"EUR"=>0.8772}}
|
36
|
-
|
40
|
+
#
|
41
|
+
# 5. Multiple cryptocurrencies to multiple fiat
|
42
|
+
# Cryptocompare::Price.find(['BTC','ETH', 'LTC'], ['USD', 'EUR', 'CNY'])
|
43
|
+
# => {"BTC"=>{"USD"=>2501.61, "EUR"=>2197.04, "CNY"=>17329.48}, "ETH"=>{"USD"=>236.59, "EUR"=>209.39, "CNY"=>1655.15}, "LTC"=>{"USD"=>45.74, "EUR"=>40.33, "CNY"=>310.5}}
|
44
|
+
#
|
45
|
+
# 6. Multiple fiat to multiple cryptocurrencies
|
46
|
+
# Cryptocompare::Price.find(['USD', 'EUR'], ['BTC','ETH', 'LTC'])
|
47
|
+
# => {"USD"=>{"BTC"=>0.0003996, "ETH"=>0.004238, "LTC"=>0.02184}, "EUR"=>{"BTC"=>0.0004548, "ETH"=>0.00477, "LTC"=>0.0248}}
|
48
|
+
#
|
49
|
+
# 7. Find prices based on exchange
|
50
|
+
#
|
51
|
+
# Cryptocompare::Price.find('DASH', 'USD', {'e' => 'Kraken'})
|
52
|
+
# # => {"DASH"=>{"USD"=>152.4}}
|
53
|
+
def self.find(from_syms, to_syms, opts = {})
|
37
54
|
fsyms = Array(from_syms).join(',')
|
38
55
|
tsyms = Array(to_syms).join(',')
|
39
56
|
full_path = API_URL + "?fsyms=#{fsyms}&tsyms=#{tsyms}"
|
57
|
+
full_path += "&e=#{set_exchange(opts['e'])}" if opts['e']
|
40
58
|
api_resp = Faraday.get(full_path)
|
41
59
|
JSON.parse(api_resp.body)
|
42
60
|
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
# Helper method to overcome case-sensitive exchange name enforced by the API.
|
65
|
+
# If no supported exchange mapping is found, it will try user's input.
|
66
|
+
def self.set_exchange(exchange)
|
67
|
+
EXCHANGES[exchange.upcase] || exchange
|
68
|
+
end
|
43
69
|
end
|
44
70
|
end
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptocompare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander David Pan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.12'
|
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
26
|
version: '1.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: vcr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: faraday
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: json
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: A Ruby gem for communicating with the CryptoCompare API
|
@@ -115,8 +115,8 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
-
|
119
|
-
-
|
118
|
+
- .gitignore
|
119
|
+
- .travis.yml
|
120
120
|
- CODE_OF_CONDUCT.md
|
121
121
|
- Gemfile
|
122
122
|
- LICENSE.txt
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- Rakefile
|
125
125
|
- bin/console
|
126
126
|
- bin/setup
|
127
|
+
- config/exchanges.yml
|
127
128
|
- cryptocompare.gemspec
|
128
129
|
- lib/cryptocompare.rb
|
129
130
|
- lib/cryptocompare/price.rb
|
@@ -139,17 +140,17 @@ require_paths:
|
|
139
140
|
- lib
|
140
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
142
|
requirements:
|
142
|
-
- -
|
143
|
+
- - '>='
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
147
|
requirements:
|
147
|
-
- -
|
148
|
+
- - '>='
|
148
149
|
- !ruby/object:Gem::Version
|
149
150
|
version: '0'
|
150
151
|
requirements: []
|
151
152
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.4.8
|
153
154
|
signing_key:
|
154
155
|
specification_version: 4
|
155
156
|
summary: A Ruby gem for communicating with the CryptoCompare API
|