cryptocompare 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +5 -0
- data/README.md +116 -1
- data/config/query_param_mapping.yml +2 -0
- data/lib/cryptocompare/price.rb +234 -3
- data/lib/cryptocompare/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb1da60424846af0f722e8ee3857276a56a54cab
|
4
|
+
data.tar.gz: 607e0325e789895690d4c2e10f12c20201b254cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef0c477aa83c3a8f325a5f74bc858f608a6175cf553f40ded4cf4093288c4138f4e1a25fe5006f71ca817bfc94a86686fc4e0fe71de5ae4e2d351d238ffd7ade
|
7
|
+
data.tar.gz: cde48298626ef54b0dcac8570219f2d60309f38e5e9f517e14646dfd42a8843b6173a3d536a9f5aed33d90b11ab0abb62c4ecbb559ecdfae577bec4c0a5ce573
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -3,3 +3,10 @@ language: ruby
|
|
3
3
|
rvm:
|
4
4
|
- 2.0.0
|
5
5
|
before_install: gem install bundler -v 1.12.5
|
6
|
+
addons:
|
7
|
+
code_climate:
|
8
|
+
repo_token:
|
9
|
+
secure: "NAjO10wrSWlyrTC+hj+4Mk3ORZqr7yoD4Or8HIj7YkpKX4l9neqiaOCmNi34wImpJttEsbH/ICIfqphjp1w7VEdS/HnVcJEv3mO9fJ3uLYXJY9uTlwlotdHQ5xCIpyQQJswRw1ef2kH55ACZOWcfC/Sp7sZ9L/xb/3Gb9o1hC6pH0Kd87gx4X8v/THfynR5tPoXUjWCN1RZDcshdTBqOLIyMBdlueZQ2bmiqPQEtCorixCSF2z0oxBXlNoklkPVGOqPXiER/KFaUmDTupSnWw9CGO/00CA1ErU2pk4LTSQwDTZbMQ6ciIl3JTaM9YtJhaKVw2qrSAEKBFjUVmSlqblwAr/A47MaNxD7B6gWe5aKjt1aPsWddNJDf43SSb4B4yh8FfA++c+ydB3XN1yEgg4eoKrqezIgffzbETGGIrlKkbEVqYzXeS3d8N2Zn/ads7Ie1QQsGaH858r+2Taser/saYqF/KIJwMOIiOAAriGJxIk70hHM5ocJVNVtyJpWOTZ1Tzoqtgayfk3lLLixzenh+HRoOLtXg4lCXOZJ+R78w9NCIG/y5ltJJqW9lXlajJHGlIvdkGKD9Q3MKAuH4UbUw6Ni12T8HigEcf1DdDGahNcL2vUdDeIF+mAGTl0blBiLnjmaj+KsfpwC0LcIVBHeLVPV48r2eld6LaNgFeT4="
|
10
|
+
# regular test configuration
|
11
|
+
after_success:
|
12
|
+
- bundle exec codeclimate-test-reporter
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
+
[![Test Coverage](https://codeclimate.com/github/alexanderdavidpan/cryptocompare/badges/coverage.svg)](https://codeclimate.com/github/alexanderdavidpan/cryptocompare/coverage)
|
5
5
|
|
6
6
|
This is a Ruby gem that utilizes the CryptoCompare API to fetch data related to cryptocurrencies.
|
7
7
|
|
@@ -84,6 +84,121 @@ Cryptocompare::Price.find('DASH', 'USD', {'e' => 'Kraken'})
|
|
84
84
|
# => {"DASH"=>{"USD"=>152.4}}
|
85
85
|
```
|
86
86
|
|
87
|
+
Get full price info (raw and display) for cryptocurrency to fiat currency.
|
88
|
+
```ruby
|
89
|
+
Cryptocompare::Price.full('BTC', 'USD')
|
90
|
+
# => {
|
91
|
+
# "RAW" => {
|
92
|
+
# "BTC" => {
|
93
|
+
# "USD" => {
|
94
|
+
# "TYPE"=>"5",
|
95
|
+
# "MARKET"=>"CCCAGG",
|
96
|
+
# "FROMSYMBOL"=>"BTC",
|
97
|
+
# "TOSYMBOL"=>"USD",
|
98
|
+
# "FLAGS"=>"4",
|
99
|
+
# "PRICE"=>4551.84,
|
100
|
+
# "LASTUPDATE"=>1504753702,
|
101
|
+
# "LASTVOLUME"=>2.19e-06,
|
102
|
+
# "LASTVOLUMETO"=>0.00995355,
|
103
|
+
# "LASTTRADEID"=>20466080,
|
104
|
+
# "VOLUME24HOUR"=>110449.85666195827,
|
105
|
+
# "VOLUME24HOURTO"=>503369392.8440719,
|
106
|
+
# "OPEN24HOUR"=>4497.45,
|
107
|
+
# "HIGH24HOUR"=>4667.51,
|
108
|
+
# "LOW24HOUR"=>4386.51,
|
109
|
+
# "LASTMARKET"=>"Coinbase",
|
110
|
+
# "CHANGE24HOUR"=>54.39000000000033,
|
111
|
+
# "CHANGEPCT24HOUR"=>1.2093519661141388,
|
112
|
+
# "SUPPLY"=>16549137,
|
113
|
+
# "MKTCAP"=>75329023762.08
|
114
|
+
# }
|
115
|
+
# }
|
116
|
+
# },
|
117
|
+
# "DISPLAY" => {
|
118
|
+
# "BTC" => {
|
119
|
+
# "USD" => {
|
120
|
+
# "FROMSYMBOL"=>"Ƀ",
|
121
|
+
# "TOSYMBOL"=>"$",
|
122
|
+
# "MARKET"=>"CryptoCompare Index",
|
123
|
+
# "PRICE"=>"$ 4,551.84",
|
124
|
+
# "LASTUPDATE"=>"Just now",
|
125
|
+
# "LASTVOLUME"=>"Ƀ 0.00000219",
|
126
|
+
# "LASTVOLUMETO"=>"$ 0.009954",
|
127
|
+
# "LASTTRADEID"=>20466080,
|
128
|
+
# "VOLUME24HOUR"=>"Ƀ 110,449.9",
|
129
|
+
# "VOLUME24HOURTO"=>"$ 503,369,392.8",
|
130
|
+
# "OPEN24HOUR"=>"$ 4,497.45",
|
131
|
+
# "HIGH24HOUR"=>"$ 4,667.51",
|
132
|
+
# "LOW24HOUR"=>"$ 4,386.51",
|
133
|
+
# "LASTMARKET"=>"Coinbase",
|
134
|
+
# "CHANGE24HOUR"=>"$ 54.39",
|
135
|
+
# "CHANGEPCT24HOUR"=>"1.21",
|
136
|
+
# "SUPPLY"=>"Ƀ 16,549,137",
|
137
|
+
# "MKTCAP"=>"$ 75.33 B"
|
138
|
+
# }
|
139
|
+
# }
|
140
|
+
# }
|
141
|
+
# }
|
142
|
+
```
|
143
|
+
|
144
|
+
Generate average price for cryptocurrency to fiat currency.
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
Cryptocompare::Price.generate_avg('BTC', 'USD', ['Coinbase', 'Bitfinex'])
|
148
|
+
# => {
|
149
|
+
# RAW: {
|
150
|
+
# MARKET: "CUSTOMAGG",
|
151
|
+
# FROMSYMBOL: "BTC",
|
152
|
+
# TOSYMBOL: "USD",
|
153
|
+
# FLAGS: 0,
|
154
|
+
# PRICE: 4137.43,
|
155
|
+
# LASTUPDATE: 1503454563,
|
156
|
+
# LASTVOLUME: 2,
|
157
|
+
# LASTVOLUMETO: 8271.98,
|
158
|
+
# LASTTRADEID: 19656029,
|
159
|
+
# VOLUME24HOUR: 71728.71957884016,
|
160
|
+
# VOLUME24HOURTO: 279374718.3442189,
|
161
|
+
# OPEN24HOUR: 3885.85,
|
162
|
+
# HIGH24HOUR: 4145,
|
163
|
+
# LOW24HOUR: 3583.46,
|
164
|
+
# LASTMARKET: "Coinbase",
|
165
|
+
# CHANGE24HOUR: 251.58000000000038,
|
166
|
+
# CHANGEPCT24HOUR: 6.474259171095137
|
167
|
+
# },
|
168
|
+
# DISPLAY: {
|
169
|
+
# FROMSYMBOL: "Ƀ",
|
170
|
+
# TOSYMBOL: "$",
|
171
|
+
# MARKET: "CUSTOMAGG",
|
172
|
+
# PRICE: "$ 4,137.43",
|
173
|
+
# LASTUPDATE: "Just now",
|
174
|
+
# LASTVOLUME: "Ƀ 2",
|
175
|
+
# LASTVOLUMETO: "$ 8,271.98",
|
176
|
+
# LASTTRADEID: 19656029,
|
177
|
+
# VOLUME24HOUR: "Ƀ 71,728.7",
|
178
|
+
# VOLUME24HOURTO: "$ 279,374,718.3",
|
179
|
+
# OPEN24HOUR: "$ 3,885.85",
|
180
|
+
# HIGH24HOUR: "$ 4,145",
|
181
|
+
# LOW24HOUR: "$ 3,583.46",
|
182
|
+
# LASTMARKET: "Coinbase",
|
183
|
+
# CHANGE24HOUR: "$ 251.58",
|
184
|
+
# CHANGEPCT24HOUR: "6.47"
|
185
|
+
# }
|
186
|
+
# }
|
187
|
+
```
|
188
|
+
|
189
|
+
Get day average price.
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
Cryptocompare::Price.day_avg('BTC', 'USD')
|
193
|
+
# => {
|
194
|
+
# "USD" => 4109.92,
|
195
|
+
# "ConversionType" => {
|
196
|
+
# "type" => "direct",
|
197
|
+
# "conversionSymbol" => ""
|
198
|
+
# }
|
199
|
+
# }
|
200
|
+
```
|
201
|
+
|
87
202
|
### PriceHistorical
|
88
203
|
|
89
204
|
Finds the price of any cryptocurrency in any other currency that you need at a given timestamp. The price comes from the daily info - so it would be the price at the end of the day GMT based on the requested timestamp. If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion. Tries to get direct trading pair data, if there is none or it is more than 30 days before the ts requested, it uses BTC conversion. If the opposite pair trades we invert it (eg.: BTC-XMR)
|
data/lib/cryptocompare/price.rb
CHANGED
@@ -3,7 +3,10 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Cryptocompare
|
5
5
|
module Price
|
6
|
-
|
6
|
+
PRICE_API_URL = 'https://min-api.cryptocompare.com/data/pricemulti'
|
7
|
+
PRICE_FULL_API_URL = 'https://min-api.cryptocompare.com/data/pricemultifull'
|
8
|
+
GENERATE_AVG_API_URL = 'https://min-api.cryptocompare.com/data/generateAvg'
|
9
|
+
DAY_AVG_API_URL = 'https://min-api.cryptocompare.com/data/dayAvg'
|
7
10
|
|
8
11
|
# Finds the currency price(s) of a given currency symbol. Really fast,
|
9
12
|
# 20-60 ms. Cached each 10 seconds.
|
@@ -61,10 +64,238 @@ module Cryptocompare
|
|
61
64
|
def self.find(from_syms, to_syms, opts = {})
|
62
65
|
params = {
|
63
66
|
'from_syms' => Array(from_syms).join(','),
|
64
|
-
'to_syms'
|
67
|
+
'to_syms' => Array(to_syms).join(',')
|
65
68
|
}.merge!(opts)
|
66
69
|
|
67
|
-
full_path = QueryParamHelper.set_query_params(
|
70
|
+
full_path = QueryParamHelper.set_query_params(PRICE_API_URL, params)
|
71
|
+
api_resp = Faraday.get(full_path)
|
72
|
+
JSON.parse(api_resp.body)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Get all the current trading info (price, vol, open, high, low etc) of any
|
76
|
+
# list of cryptocurrencies in any other currency that you need. If the
|
77
|
+
# crypto does not trade directly into the toSymbol requested, BTC will be
|
78
|
+
# used for conversion. This API also returns display values for all the
|
79
|
+
# fields. If the opposite pair trades we invert it (eg.: BTC-XMR).
|
80
|
+
#
|
81
|
+
# ==== Parameters
|
82
|
+
#
|
83
|
+
# * +from_sym+ [String, Array] - (required) currency symbols (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
|
84
|
+
# * +to_sym+ [String, Array] - (required) currency symbols (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
|
85
|
+
# * +opts+ [Hash] - (optional) options hash
|
86
|
+
#
|
87
|
+
# ==== Options
|
88
|
+
#
|
89
|
+
# * +e+ [String] - (optional) name of exchange (ex: 'Coinbase','Poloniex') Default: CCCAGG.
|
90
|
+
# * +tc+ [Boolean] - (optional) try conversion. Default true. If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion.
|
91
|
+
#
|
92
|
+
# ==== Returns
|
93
|
+
#
|
94
|
+
# [Hash] Hash that returns two hashes: RAW and DISPLAY. Both contain similar
|
95
|
+
# data, one is just raw data and the other is meant for displaying.
|
96
|
+
# See sample response below for data that is returned.
|
97
|
+
#
|
98
|
+
# ==== Examples
|
99
|
+
#
|
100
|
+
# Get full price info (raw and display) for cryptocurrency to fiat currency.
|
101
|
+
#
|
102
|
+
# Cryptocompare::Price.full('BTC', 'USD')
|
103
|
+
#
|
104
|
+
# Sample response
|
105
|
+
#
|
106
|
+
# {
|
107
|
+
# "RAW" => {
|
108
|
+
# "BTC" => {
|
109
|
+
# "USD" => {
|
110
|
+
# "TYPE"=>"5",
|
111
|
+
# "MARKET"=>"CCCAGG",
|
112
|
+
# "FROMSYMBOL"=>"BTC",
|
113
|
+
# "TOSYMBOL"=>"USD",
|
114
|
+
# "FLAGS"=>"4",
|
115
|
+
# "PRICE"=>4551.84,
|
116
|
+
# "LASTUPDATE"=>1504753702,
|
117
|
+
# "LASTVOLUME"=>2.19e-06,
|
118
|
+
# "LASTVOLUMETO"=>0.00995355,
|
119
|
+
# "LASTTRADEID"=>20466080,
|
120
|
+
# "VOLUME24HOUR"=>110449.85666195827,
|
121
|
+
# "VOLUME24HOURTO"=>503369392.8440719,
|
122
|
+
# "OPEN24HOUR"=>4497.45,
|
123
|
+
# "HIGH24HOUR"=>4667.51,
|
124
|
+
# "LOW24HOUR"=>4386.51,
|
125
|
+
# "LASTMARKET"=>"Coinbase",
|
126
|
+
# "CHANGE24HOUR"=>54.39000000000033,
|
127
|
+
# "CHANGEPCT24HOUR"=>1.2093519661141388,
|
128
|
+
# "SUPPLY"=>16549137,
|
129
|
+
# "MKTCAP"=>75329023762.08
|
130
|
+
# }
|
131
|
+
# }
|
132
|
+
# },
|
133
|
+
# "DISPLAY" => {
|
134
|
+
# "BTC" => {
|
135
|
+
# "USD" => {
|
136
|
+
# "FROMSYMBOL"=>"Ƀ",
|
137
|
+
# "TOSYMBOL"=>"$",
|
138
|
+
# "MARKET"=>"CryptoCompare Index",
|
139
|
+
# "PRICE"=>"$ 4,551.84",
|
140
|
+
# "LASTUPDATE"=>"Just now",
|
141
|
+
# "LASTVOLUME"=>"Ƀ 0.00000219",
|
142
|
+
# "LASTVOLUMETO"=>"$ 0.009954",
|
143
|
+
# "LASTTRADEID"=>20466080,
|
144
|
+
# "VOLUME24HOUR"=>"Ƀ 110,449.9",
|
145
|
+
# "VOLUME24HOURTO"=>"$ 503,369,392.8",
|
146
|
+
# "OPEN24HOUR"=>"$ 4,497.45",
|
147
|
+
# "HIGH24HOUR"=>"$ 4,667.51",
|
148
|
+
# "LOW24HOUR"=>"$ 4,386.51",
|
149
|
+
# "LASTMARKET"=>"Coinbase",
|
150
|
+
# "CHANGE24HOUR"=>"$ 54.39",
|
151
|
+
# "CHANGEPCT24HOUR"=>"1.21",
|
152
|
+
# "SUPPLY"=>"Ƀ 16,549,137",
|
153
|
+
# "MKTCAP"=>"$ 75.33 B"
|
154
|
+
# }
|
155
|
+
# }
|
156
|
+
# }
|
157
|
+
# }
|
158
|
+
def self.full(from_syms, to_syms, opts = {})
|
159
|
+
params = {
|
160
|
+
'from_syms' => Array(from_syms).join(','),
|
161
|
+
'to_syms' => Array(to_syms).join(','),
|
162
|
+
}.merge!(opts)
|
163
|
+
|
164
|
+
full_path = QueryParamHelper.set_query_params(PRICE_FULL_API_URL, params)
|
165
|
+
api_resp = Faraday.get(full_path)
|
166
|
+
JSON.parse(api_resp.body)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Compute the current trading info (price, vol, open, high, low, etc) of the
|
170
|
+
# requested pair as a volume weighted average based on the markets that are
|
171
|
+
# requested.
|
172
|
+
#
|
173
|
+
# ==== Parameters
|
174
|
+
#
|
175
|
+
# * +from_sym+ [String] - (required) currency symbols (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
|
176
|
+
# * +to_sym+ [String] - (required) currency symbols (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
|
177
|
+
# * +markets+ [String, Array] - (required) Name of exchanges. Supports multiple. (ex: 'Coinbase','Poloniex')
|
178
|
+
# * +opts+ [Hash] - (optional) options hash
|
179
|
+
#
|
180
|
+
# ==== Options
|
181
|
+
#
|
182
|
+
# * +tc+ [Boolean] - (optional) try conversion. Default true. If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion.
|
183
|
+
#
|
184
|
+
# ==== Returns
|
185
|
+
#
|
186
|
+
# [Hash] Hash that returns two hashes: raw and display. Both contain similar
|
187
|
+
# data, one is just raw data and the other is meant for displaying.
|
188
|
+
# See sample response below for data that is returned.
|
189
|
+
#
|
190
|
+
# ==== Examples
|
191
|
+
#
|
192
|
+
# Generate average price for cryptocurrency to fiat currency.
|
193
|
+
#
|
194
|
+
# Cryptocompare::Price.generate_avg('BTC', 'USD', ['Coinbase', 'Bitfinex'])
|
195
|
+
#
|
196
|
+
# Sample response
|
197
|
+
#
|
198
|
+
# {
|
199
|
+
# RAW: {
|
200
|
+
# MARKET: "CUSTOMAGG",
|
201
|
+
# FROMSYMBOL: "BTC",
|
202
|
+
# TOSYMBOL: "USD",
|
203
|
+
# FLAGS: 0,
|
204
|
+
# PRICE: 4137.43,
|
205
|
+
# LASTUPDATE: 1503454563,
|
206
|
+
# LASTVOLUME: 2,
|
207
|
+
# LASTVOLUMETO: 8271.98,
|
208
|
+
# LASTTRADEID: 19656029,
|
209
|
+
# VOLUME24HOUR: 71728.71957884016,
|
210
|
+
# VOLUME24HOURTO: 279374718.3442189,
|
211
|
+
# OPEN24HOUR: 3885.85,
|
212
|
+
# HIGH24HOUR: 4145,
|
213
|
+
# LOW24HOUR: 3583.46,
|
214
|
+
# LASTMARKET: "Coinbase",
|
215
|
+
# CHANGE24HOUR: 251.58000000000038,
|
216
|
+
# CHANGEPCT24HOUR: 6.474259171095137
|
217
|
+
# },
|
218
|
+
# DISPLAY: {
|
219
|
+
# FROMSYMBOL: "Ƀ",
|
220
|
+
# TOSYMBOL: "$",
|
221
|
+
# MARKET: "CUSTOMAGG",
|
222
|
+
# PRICE: "$ 4,137.43",
|
223
|
+
# LASTUPDATE: "Just now",
|
224
|
+
# LASTVOLUME: "Ƀ 2",
|
225
|
+
# LASTVOLUMETO: "$ 8,271.98",
|
226
|
+
# LASTTRADEID: 19656029,
|
227
|
+
# VOLUME24HOUR: "Ƀ 71,728.7",
|
228
|
+
# VOLUME24HOURTO: "$ 279,374,718.3",
|
229
|
+
# OPEN24HOUR: "$ 3,885.85",
|
230
|
+
# HIGH24HOUR: "$ 4,145",
|
231
|
+
# LOW24HOUR: "$ 3,583.46",
|
232
|
+
# LASTMARKET: "Coinbase",
|
233
|
+
# CHANGE24HOUR: "$ 251.58",
|
234
|
+
# CHANGEPCT24HOUR: "6.47"
|
235
|
+
# }
|
236
|
+
# }
|
237
|
+
def self.generate_avg(from_sym, to_sym, markets, opts = {})
|
238
|
+
params = {
|
239
|
+
'from_sym' => from_sym,
|
240
|
+
'to_sym' => to_sym,
|
241
|
+
'markets' => Array(markets).join(',')
|
242
|
+
}.merge!(opts)
|
243
|
+
|
244
|
+
full_path = QueryParamHelper.set_query_params(GENERATE_AVG_API_URL, params)
|
245
|
+
api_resp = Faraday.get(full_path)
|
246
|
+
JSON.parse(api_resp.body)
|
247
|
+
end
|
248
|
+
|
249
|
+
# Get day average price. The values are based on hourly vwap data and the
|
250
|
+
# average can be calculated in different ways. It uses BTC conversion if
|
251
|
+
# data is not available because the coin is not trading in the specified
|
252
|
+
# currency. If 'tc' param is set to false, it will give you the direct
|
253
|
+
# data. If no toTS is given it will automatically do the current day. Also,
|
254
|
+
# for different timezones use the utc_offset param. The calculation types
|
255
|
+
# are: HourVWAP - a VWAP of the hourly close price,MidHighLow - the average
|
256
|
+
# between the 24 H high and low.VolFVolT - the total volume from / the total
|
257
|
+
# volume to (only avilable with tryConversion set to false so only for
|
258
|
+
# direct trades but the value should be the most accurate price)
|
259
|
+
#
|
260
|
+
# ==== Parameters
|
261
|
+
#
|
262
|
+
# * +from_sym+ [String] - (required) currency symbols (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
|
263
|
+
# * +to_sym+ [String] - (required) currency symbols (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
|
264
|
+
# * +opts+ [Hash] - (optional) options hash
|
265
|
+
#
|
266
|
+
# ==== Options
|
267
|
+
#
|
268
|
+
# * +e+ [String] - (optional) name of exchange (ex: 'Coinbase','Poloniex') Default: CCCAGG.
|
269
|
+
# * +tc+ [Boolean] - (optional) try conversion. Default true. If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion.
|
270
|
+
# * +to_ts+ [Integer] - (optional) timestamp. Must be an hour unit.
|
271
|
+
# * +utc_offset+ [Integer] - (optional) Default is UTC, but if you want a different time zone just pass the hour difference. For example, for PST you would pass -8.
|
272
|
+
#
|
273
|
+
# ==== Returns
|
274
|
+
#
|
275
|
+
# [Hash] Hash with currency prices and information about conversion type.
|
276
|
+
#
|
277
|
+
# ==== Examples
|
278
|
+
#
|
279
|
+
# Generate average day price for cryptocurrency to fiat currency.
|
280
|
+
#
|
281
|
+
# Cryptocompare::Price.day_avg('BTC', 'USD')
|
282
|
+
#
|
283
|
+
# Sample response
|
284
|
+
#
|
285
|
+
# {
|
286
|
+
# "USD" => 4109.92,
|
287
|
+
# "ConversionType" => {
|
288
|
+
# "type" => "direct",
|
289
|
+
# "conversionSymbol" => ""
|
290
|
+
# }
|
291
|
+
# }
|
292
|
+
def self.day_avg(from_sym, to_sym, opts = {})
|
293
|
+
params = {
|
294
|
+
'from_sym' => from_sym,
|
295
|
+
'to_sym' => to_sym,
|
296
|
+
}.merge!(opts)
|
297
|
+
|
298
|
+
full_path = QueryParamHelper.set_query_params(DAY_AVG_API_URL, params)
|
68
299
|
api_resp = Faraday.get(full_path)
|
69
300
|
JSON.parse(api_resp.body)
|
70
301
|
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.
|
4
|
+
version: 0.10.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-
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.0.14.1
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: A Ruby gem for communicating with the CryptoCompare API
|