cryptocompare 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d4a7c86c44eb915bc9b55686b677cd0345deeb9
4
- data.tar.gz: 6e83e131f26c3dc32811ef29760df2275418dc93
3
+ metadata.gz: d20e62b88d867db1cbca707672c55176fc66517a
4
+ data.tar.gz: ba8adf2091a559f4df530a0fac701335aa50bae6
5
5
  SHA512:
6
- metadata.gz: 39f93ad0cb72542b9c456b0088dce7338415608dd8551a05eeb6075ade76b02fd41cf8e6ab3444dcf5be3867fb0dca6516f16407d5c915ab80f209d56dab2cef
7
- data.tar.gz: c86d6af2d8e1e8847a3bfd90326e36c9aa32e18f7ab1e445f4e5fadc3c9bd0c109ac7ece61ee12ee3d84ccba01d56a25d5525ad6ecdf6addfb5d19a6b56bd9a5
6
+ metadata.gz: 6341cad1ddd37cf355fac24ce4c61b37d7d75017b8b242f1fecf133e5f7ff2164c7178e21cbb4160cbab0acf12cbb124d1e4a77cb417cea5bf06b3f35593ef37
7
+ data.tar.gz: 47a2e9f163e8bb860911e00403c345147c5f07676b92dbfcfd79cba61d88e97ce6eeac6aae81d3387229c8500ce69224eca66787504378ed8cb24bc1e4cc65d9
@@ -35,7 +35,7 @@ This code of conduct applies both within project spaces and in public spaces
35
35
  when an individual is representing the project or its community.
36
36
 
37
37
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at ap3809@yp.com. All
38
+ reported by contacting a project maintainer at alexanderdavidpan@gmail.com. All
39
39
  complaints will be reviewed and investigated and will result in a response that
40
40
  is deemed necessary and appropriate to the circumstances. Maintainers are
41
41
  obligated to maintain confidentiality with regard to the reporter of an
@@ -46,4 +46,4 @@ version 1.3.0, available at
46
46
  [http://contributor-covenant.org/version/1/3/0/][version]
47
47
 
48
48
  [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Cryptocompare
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
 
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- To use Cryptocompare, just require it like so:
26
+ To use cryptocompare, just require it like so:
27
27
 
28
28
  ```ruby
29
29
  require 'cryptocompare'
@@ -53,7 +53,7 @@ Convert cryptocurrency to cryptocurrency.
53
53
 
54
54
  ```ruby
55
55
  Cryptocompare::Price.find('BTC', 'ETH')
56
- # =>{"BTC"=>{"ETH"=>9.29}}
56
+ # => {"BTC"=>{"ETH"=>9.29}}
57
57
  ```
58
58
 
59
59
  Convert fiat to fiat.
@@ -107,10 +107,71 @@ Cryptocompare::PriceHistorical.find('ETH', 'USD', {'ts' => 1452680400})
107
107
  Find historical price of cryptocurrency in many currencies at a given timestamp.
108
108
 
109
109
  ```ruby
110
- Cryptocompare::PriceHistorical.find('ETH', ['BTC', 'USD', 'EUR'], {'ts' => '1452680400')
110
+ Cryptocompare::PriceHistorical.find('ETH', ['BTC', 'USD', 'EUR'], {'ts' => '1452680400'})
111
111
  # => {"ETH"=>{"BTC"=>0.08006, "USD"=>225.93, "EUR"=>194.24}}
112
112
  ```
113
113
 
114
+ ### CoinSnapshot
115
+
116
+ Get data for a currency pair. It returns general block explorer information, aggregated data and individual data for each exchange available.
117
+
118
+ **Example:**
119
+
120
+ ```ruby
121
+ Cryptocompare::CoinSnapshot.find('BTC', 'USD')
122
+ # => {
123
+ # "Response":"Success",
124
+ # "Message":"Coin snapshot succesfully returned",
125
+ # "Type":100,
126
+ # "Data":{
127
+ # "Algorithm":"SHA256",
128
+ # "ProofType":"PoW",
129
+ # "BlockNumber":378345,
130
+ # "NetHashesPerSecond":465548431.66333866,
131
+ # "TotalCoinsMined":14707625.0,
132
+ # "BlockReward":25.0,
133
+ # "AggregatedData":{
134
+ # "TYPE":"5",
135
+ # "MARKET":"CCCAGG",
136
+ # "FROMSYMBOL":"BTC",
137
+ # "TOSYMBOL":"USD",
138
+ # "FLAGS":"4",
139
+ # "PRICE":"245.41",
140
+ # "LASTUPDATE":"1444520460",
141
+ # "LASTVOLUME":"0.0086",
142
+ # "LASTVOLUMETO":"2.110268",
143
+ # "LASTTRADEID":"1444520460357",
144
+ # "VOLUME24HOUR":"49591.48108707269",
145
+ # "VOLUME24HOURTO":"12139110.189163648",
146
+ # "OPEN24HOUR":"244.41",
147
+ # "HIGH24HOUR":"258.37",
148
+ # "LOW24HOUR":"239.01000004",
149
+ # "LASTMARKET":"Huobi"
150
+ # },
151
+ # "Exchanges":[
152
+ # {
153
+ # "TYPE":"2",
154
+ # "MARKET":"LakeBTC",
155
+ # "FROMSYMBOL":"BTC",
156
+ # "TOSYMBOL":"USD",
157
+ # "FLAGS":"2",
158
+ # "PRICE":"244.37",
159
+ # "LASTUPDATE":"1444513131",
160
+ # "LASTVOLUME":"0.03",
161
+ # "LASTVOLUMETO":"7.3311",
162
+ # "LASTTRADEID":"1444513131",
163
+ # "VOLUME24HOUR":"3599.0560000000005",
164
+ # "VOLUME24HOURTO":"879237.6299349999",
165
+ # "OPEN24HOUR":"243.83",
166
+ # "HIGH24HOUR":"245.23",
167
+ # "LOW24HOUR":"242.68"
168
+ # },
169
+ # ....
170
+ # ]
171
+ # }
172
+ # }
173
+ ```
174
+
114
175
  ## Supported Exchanges
115
176
 
116
177
  * BTC38
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{A Ruby gem for communicating with the CryptoCompare API}
14
14
  spec.homepage = "https://github.com/alexanderdavidpan/cryptocompare"
15
15
  spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = '>= 2.0.0'
16
18
 
17
19
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
20
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -1,4 +1,5 @@
1
1
  require_relative "cryptocompare/version"
2
+ require_relative "cryptocompare/coin_snapshot"
2
3
  require_relative "cryptocompare/price"
3
4
  require_relative "cryptocompare/price_historical"
4
5
 
@@ -0,0 +1,85 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'yaml'
4
+
5
+ module Cryptocompare
6
+ module CoinSnapshot
7
+ API_URL = 'https://www.cryptocompare.com/api/data/coinsnapshot/'
8
+
9
+ # Get data for a currency pair. It returns general block explorer
10
+ # information, aggregated data and individual data for each exchange
11
+ # available.
12
+ #
13
+ # ==== Parameters
14
+ # * +from_sym+ [String] - (required) currency symbol (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
15
+ # * +to_sym+ [String] - (required) currency symbol (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
16
+ #
17
+ # ==== Returns
18
+ # [Hash] Hash with data about given currency pair.
19
+ #
20
+ # ==== Example
21
+ #
22
+ # Find data for a currency pair.
23
+ #
24
+ # Cryptocompare::CoinSnapshot.find('BTC', 'USD')
25
+ #
26
+ # Sample response
27
+ #
28
+ # {
29
+ # "Response":"Success",
30
+ # "Message":"Coin snapshot succesfully returned",
31
+ # "Type":100,
32
+ # "Data":{
33
+ # "Algorithm":"SHA256",
34
+ # "ProofType":"PoW",
35
+ # "BlockNumber":378345,
36
+ # "NetHashesPerSecond":465548431.66333866,
37
+ # "TotalCoinsMined":14707625.0,
38
+ # "BlockReward":25.0,
39
+ # "AggregatedData":{
40
+ # "TYPE":"5",
41
+ # "MARKET":"CCCAGG",
42
+ # "FROMSYMBOL":"BTC",
43
+ # "TOSYMBOL":"USD",
44
+ # "FLAGS":"4",
45
+ # "PRICE":"245.41",
46
+ # "LASTUPDATE":"1444520460",
47
+ # "LASTVOLUME":"0.0086",
48
+ # "LASTVOLUMETO":"2.110268",
49
+ # "LASTTRADEID":"1444520460357",
50
+ # "VOLUME24HOUR":"49591.48108707269",
51
+ # "VOLUME24HOURTO":"12139110.189163648",
52
+ # "OPEN24HOUR":"244.41",
53
+ # "HIGH24HOUR":"258.37",
54
+ # "LOW24HOUR":"239.01000004",
55
+ # "LASTMARKET":"Huobi"
56
+ # },
57
+ # "Exchanges":[
58
+ # {
59
+ # "TYPE":"2",
60
+ # "MARKET":"LakeBTC",
61
+ # "FROMSYMBOL":"BTC",
62
+ # "TOSYMBOL":"USD",
63
+ # "FLAGS":"2",
64
+ # "PRICE":"244.37",
65
+ # "LASTUPDATE":"1444513131",
66
+ # "LASTVOLUME":"0.03",
67
+ # "LASTVOLUMETO":"7.3311",
68
+ # "LASTTRADEID":"1444513131",
69
+ # "VOLUME24HOUR":"3599.0560000000005",
70
+ # "VOLUME24HOURTO":"879237.6299349999",
71
+ # "OPEN24HOUR":"243.83",
72
+ # "HIGH24HOUR":"245.23",
73
+ # "LOW24HOUR":"242.68"
74
+ # },
75
+ # ....
76
+ # ]
77
+ # }
78
+ # }
79
+ def self.find(from_sym, to_sym)
80
+ full_path = API_URL + "?fsym=#{from_sym}&tsym=#{to_sym}"
81
+ api_resp = Faraday.get(full_path)
82
+ JSON.parse(api_resp.body)
83
+ end
84
+ end
85
+ end
@@ -11,44 +11,53 @@ module Cryptocompare
11
11
  # Finds the currency price(s) of a given currency symbol. Really fast,
12
12
  # 20-60 ms. Cached each 10 seconds.
13
13
  #
14
- # Params:
15
- # from_syms [String, Array] - currency symbols (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
16
- # to_syms [String, Array] - currency symbols (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
17
- # opts [Hash] - options hash
18
- # opts[e] [String] - name of exchange (ex: 'Coinbase','Poloniex') Default: CCCAGG.
14
+ # ==== Parameters
15
+ # * +from_syms+ [String, Array] - (required) currency symbols (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
16
+ # * +to_syms+ [String, Array] - (required) currency symbols (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
17
+ # * +opts+ [Hash] - (optional) options hash
19
18
  #
20
- # Returns:
19
+ # ==== Options
20
+ # * +e+ [String] - (optional) name of exchange (ex: 'Coinbase','Poloniex') Default: CCCAGG.
21
+ #
22
+ # ==== Returns
21
23
  # [Hash] Hash with currency prices
22
24
  #
23
- # Examples:
25
+ # ==== Examples
24
26
  #
25
27
  # Convert cryptocurrency to fiat.
26
28
  #
27
- # Cryptocompare::Price.find('BTC', 'USD') #=> {"BTC"=>{"USD"=>2594.07}}
29
+ # Cryptocompare::Price.find('BTC', 'USD')
30
+ # #=> {"BTC"=>{"USD"=>2594.07}}
28
31
  #
29
32
  # Convert fiat to cryptocurrency.
30
33
  #
31
- # Cryptocompare::Price.find('USD', 'BTC') #=> {"USD"=>{"BTC"=>0.0004176}}
34
+ # Cryptocompare::Price.find('USD', 'BTC')
35
+ # #=> {"USD"=>{"BTC"=>0.0004176}}
32
36
  #
33
37
  # Convert cryptocurrency to cryptocurrency.
34
38
  #
35
- # Cryptocompare::Price.find('BTC', 'ETH') #=>{"BTC"=>{"ETH"=>9.29}}
39
+ # Cryptocompare::Price.find('BTC', 'ETH')
40
+ # #=> {"BTC"=>{"ETH"=>9.29}}
36
41
  #
37
42
  # Convert fiat to fiat.
38
43
  #
39
- # Cryptocompare::Price.find('USD', 'EUR') #=> {"USD"=>{"EUR"=>0.8772}}
44
+ # Cryptocompare::Price.find('USD', 'EUR')
45
+ # #=> {"USD"=>{"EUR"=>0.8772}}
40
46
  #
41
47
  # Convert multiple cryptocurrencies to multiple fiat.
42
48
  #
43
- # Cryptocompare::Price.find(['BTC','ETH', 'LTC'], ['USD', 'EUR', 'CNY']) #=> {"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}}
49
+ # Cryptocompare::Price.find(['BTC','ETH', 'LTC'], ['USD', 'EUR', 'CNY'])
50
+ # #=> {"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
51
  #
45
52
  # Convert multiple fiat to multiple cryptocurrencies.
46
53
  #
47
- # Cryptocompare::Price.find(['USD', 'EUR'], ['BTC','ETH', 'LTC']) #=> {"USD"=>{"BTC"=>0.0003996, "ETH"=>0.004238, "LTC"=>0.02184}, "EUR"=>{"BTC"=>0.0004548, "ETH"=>0.00477, "LTC"=>0.0248}}
54
+ # Cryptocompare::Price.find(['USD', 'EUR'], ['BTC','ETH', 'LTC'])
55
+ # #=> {"USD"=>{"BTC"=>0.0003996, "ETH"=>0.004238, "LTC"=>0.02184}, "EUR"=>{"BTC"=>0.0004548, "ETH"=>0.00477, "LTC"=>0.0248}}
48
56
  #
49
57
  # Find prices based on exchange.
50
58
  #
51
- # Cryptocompare::Price.find('DASH', 'USD', {'e' => 'Kraken'}) #=> {"DASH"=>{"USD"=>152.4}}
59
+ # Cryptocompare::Price.find('DASH', 'USD', {'e' => 'Kraken'})
60
+ # #=> {"DASH"=>{"USD"=>152.4}}
52
61
  def self.find(from_syms, to_syms, opts = {})
53
62
  fsyms = Array(from_syms).join(',')
54
63
  tsyms = Array(to_syms).join(',')
@@ -12,30 +12,36 @@ module Cryptocompare
12
12
  # the crypto does not trade directly into the toSymbol requested, BTC will
13
13
  # be used for conversion. Tries to get direct trading pair data, if there is
14
14
  # none or it is more than 30 days before the ts requested, it uses BTC
15
- # conversion. If the opposite pair trades we invert it (eg.: BTC-XMR)
15
+ # conversion. If the opposite pair trades we invert it (eg.: BTC-XMR).
16
16
  #
17
- # Params:
18
- # from_sym [String] - (required) currency symbol (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
19
- # to_syms [String, Array] - (required) currency symbol(s) (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
20
- # opts [Hash] - (optional) options hash
21
- # opts[ts] [String, Integer] - (optional) timestamp
17
+ # ==== Parameters
22
18
  #
23
- # Returns:
19
+ # * +from_sym+ [String] - (required) currency symbol (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
20
+ # * +to_syms+ [String, Array] - (required) currency symbol(s) (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
21
+ # * +opts+ [Hash] - (optional) options hash
22
+ #
23
+ # ==== Options
24
+ # * +ts+ [String, Integer] - (optional) timestamp
25
+ #
26
+ # ==== Returns
24
27
  # [Hash] Hash with currency prices
25
28
  #
26
- # Examples:
29
+ # ==== Examples
27
30
  #
28
31
  # Find historical price of cryptocurrency.
29
32
  #
30
- # Cryptocompare::PriceHistorical.find('ETH', 'USD') #=> {"ETH"=>{"USD"=>225.93}}
33
+ # Cryptocompare::PriceHistorical.find('ETH', 'USD')
34
+ # #=> {"ETH"=>{"USD"=>225.93}}
31
35
  #
32
36
  # Find historical price of cryptocurrency at a given timestamp.
33
37
  #
34
- # Cryptocompare::PriceHistorical.find('ETH', 'USD', {'ts' => 1452680400}) #=> {"ETH"=>{"USD"=>223.2}}
38
+ # Cryptocompare::PriceHistorical.find('ETH', 'USD', {'ts' => 1452680400})
39
+ # #=> {"ETH"=>{"USD"=>223.2}}
35
40
  #
36
41
  # Find historical price of cryptocurrency in many currencies at a given timestamp.
37
42
  #
38
- # Cryptocompare::PriceHistorical.find('ETH', ['BTC', 'USD', 'EUR'], {'ts' => '1452680400') #=> {"ETH"=>{"BTC"=>0.08006, "USD"=>225.93, "EUR"=>194.24}}
43
+ # Cryptocompare::PriceHistorical.find('ETH', ['BTC', 'USD', 'EUR'], {'ts' => '1452680400'})
44
+ # #=> {"ETH"=>{"BTC"=>0.08006, "USD"=>225.93, "EUR"=>194.24}}
39
45
  def self.find(from_sym, to_syms, opts = {})
40
46
  tsyms = Array(to_syms).join(',')
41
47
  full_path = API_URL + "?fsym=#{from_sym}&tsyms=#{tsyms}"
@@ -1,3 +1,3 @@
1
1
  module Cryptocompare
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptocompare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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-25 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,6 +127,7 @@ files:
127
127
  - config/exchanges.yml
128
128
  - cryptocompare.gemspec
129
129
  - lib/cryptocompare.rb
130
+ - lib/cryptocompare/coin_snapshot.rb
130
131
  - lib/cryptocompare/price.rb
131
132
  - lib/cryptocompare/price_historical.rb
132
133
  - lib/cryptocompare/version.rb
@@ -143,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
144
  requirements:
144
145
  - - '>='
145
146
  - !ruby/object:Gem::Version
146
- version: '0'
147
+ version: 2.0.0
147
148
  required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  requirements:
149
150
  - - '>='