cryptocompare 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -0
- data/lib/cryptocompare.rb +3 -0
- data/lib/cryptocompare/coin_snapshot.rb +2 -0
- data/lib/cryptocompare/histo_minute.rb +102 -0
- data/lib/cryptocompare/price.rb +3 -0
- data/lib/cryptocompare/price_historical.rb +2 -0
- data/lib/cryptocompare/top_pairs.rb +2 -0
- data/lib/cryptocompare/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d00d76f9c9a92203e67633a4d76831db01273259
|
4
|
+
data.tar.gz: c9bd0a4255153b1f2760021c9e7f654cb4dfaa3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 906225c0c70ffec0e8ccfdafad3be6808c39720dc06277a38f14097ea94c53ccd8779e06f2fc53a668a903dff228bfdbbfb1168a9b6249bc90d48c7082fc3266
|
7
|
+
data.tar.gz: ac27297ecb113ee31a83eb1767a47e6be39fc9f3b348c58bc8ce9c399a8a7c06f625831d1aa2515e6c995226b927a13ac11ac9454d550483435557eb2315e8b6
|
data/README.md
CHANGED
@@ -204,6 +204,51 @@ Cryptocompare::TopPairs.find('ETH')
|
|
204
204
|
# }
|
205
205
|
```
|
206
206
|
|
207
|
+
### HistoMinute
|
208
|
+
|
209
|
+
Get open, high, low, close, volumefrom and volumeto for each minute of historical data. This data is only stored for 7 days, if you need more, use the hourly or daily path. It uses BTC conversion if data is not available because the coin is not trading in the specified currency.
|
210
|
+
|
211
|
+
**Examples:**
|
212
|
+
|
213
|
+
Find historical data by minute for BTC to USD.
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
Cryptocompare::HistoMinute.find('BTC', 'USD')
|
217
|
+
# => {
|
218
|
+
# Response: "Success",
|
219
|
+
# Type: 100,
|
220
|
+
# Aggregated: true,
|
221
|
+
# Data: [
|
222
|
+
# {
|
223
|
+
# time: 1502259120,
|
224
|
+
# close: 3396.44,
|
225
|
+
# high: 3397.63,
|
226
|
+
# low: 3396.34,
|
227
|
+
# open: 3397.39,
|
228
|
+
# volumefrom: 98.2,
|
229
|
+
# volumeto: 335485
|
230
|
+
# },
|
231
|
+
# {
|
232
|
+
# time: 1502259300,
|
233
|
+
# close: 3396.86,
|
234
|
+
# high: 3396.94,
|
235
|
+
# low: 3396.44,
|
236
|
+
# open: 3396.44,
|
237
|
+
# volumefrom: 16.581031,
|
238
|
+
# volumeto: 56637.869999999995
|
239
|
+
# },
|
240
|
+
# ...
|
241
|
+
# ],
|
242
|
+
# TimeTo: 1502259360,
|
243
|
+
# TimeFrom: 1502259120,
|
244
|
+
# FirstValueInArray: true,
|
245
|
+
# ConversionType: {
|
246
|
+
# type: "direct",
|
247
|
+
# conversionSymbol: ""
|
248
|
+
# }
|
249
|
+
# }
|
250
|
+
```
|
251
|
+
|
207
252
|
## Supported Exchanges
|
208
253
|
|
209
254
|
* BTC38
|
data/lib/cryptocompare.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require_relative "cryptocompare/version"
|
2
2
|
require_relative "cryptocompare/coin_snapshot"
|
3
|
+
require_relative "cryptocompare/histo_day"
|
4
|
+
require_relative "cryptocompare/histo_hour"
|
5
|
+
require_relative "cryptocompare/histo_minute"
|
3
6
|
require_relative "cryptocompare/price"
|
4
7
|
require_relative "cryptocompare/price_historical"
|
5
8
|
require_relative "cryptocompare/top_pairs"
|
@@ -10,10 +10,12 @@ module Cryptocompare
|
|
10
10
|
# available.
|
11
11
|
#
|
12
12
|
# ==== Parameters
|
13
|
+
#
|
13
14
|
# * +from_sym+ [String] - (required) currency symbol (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
|
14
15
|
# * +to_sym+ [String] - (required) currency symbol (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
|
15
16
|
#
|
16
17
|
# ==== Returns
|
18
|
+
#
|
17
19
|
# [Hash] Hash with data about given currency pair.
|
18
20
|
#
|
19
21
|
# ==== Example
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require_relative 'helpers/exchange_name_helper'
|
4
|
+
|
5
|
+
module Cryptocompare
|
6
|
+
module HistoMinute
|
7
|
+
extend ExchangeNameHelper
|
8
|
+
|
9
|
+
API_URL = 'https://min-api.cryptocompare.com/data/histominute'
|
10
|
+
|
11
|
+
# Get open, high, low, close, volumefrom and volumeto for each minute of
|
12
|
+
# historical data. This data is only stored for 7 days, if you need more,
|
13
|
+
# use the hourly or daily path. It uses BTC conversion if data is not
|
14
|
+
# available because the coin is not trading in the specified currency.
|
15
|
+
#
|
16
|
+
# ==== Parameters
|
17
|
+
#
|
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
|
+
#
|
22
|
+
# ==== Options
|
23
|
+
#
|
24
|
+
# * +e+ [String] - (optional) name of exchange (ex: 'Coinbase','Poloniex') Default: CCCAGG.
|
25
|
+
# * +limit+ [Integer] - (optional) limit. Default 1440. Max 2000. Must be positive integer. Returns limit + 1 data points.
|
26
|
+
# * +agg+ [Integer] - (optional) number of data points to aggregate. Default 1.
|
27
|
+
# * +to_ts+ [Integer] - (optional) timestamp. Use the timestamp option to set a historical start point. By default, it gets historical data for the past several minutes.
|
28
|
+
# * +tc+ [Boolean] - (optional) try conversion. Default true. If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion.
|
29
|
+
#
|
30
|
+
# ==== Returns
|
31
|
+
#
|
32
|
+
# [Hash] Returns a hash containing data as an array of hashes containing
|
33
|
+
# info such as open, high, low, close, volumefrom and volumeto for
|
34
|
+
# each minute.
|
35
|
+
#
|
36
|
+
# ==== Examples
|
37
|
+
#
|
38
|
+
# Find historical data by minute for BTC to USD.
|
39
|
+
#
|
40
|
+
# Cryptocompare::HistoMinute.find('BTC', 'USD')
|
41
|
+
#
|
42
|
+
# {
|
43
|
+
# Response: "Success",
|
44
|
+
# Type: 100,
|
45
|
+
# Aggregated: true,
|
46
|
+
# Data: [
|
47
|
+
# {
|
48
|
+
# time: 1502259120,
|
49
|
+
# close: 3396.44,
|
50
|
+
# high: 3397.63,
|
51
|
+
# low: 3396.34,
|
52
|
+
# open: 3397.39,
|
53
|
+
# volumefrom: 98.2,
|
54
|
+
# volumeto: 335485
|
55
|
+
# },
|
56
|
+
# {
|
57
|
+
# time: 1502259300,
|
58
|
+
# close: 3396.86,
|
59
|
+
# high: 3396.94,
|
60
|
+
# low: 3396.44,
|
61
|
+
# open: 3396.44,
|
62
|
+
# volumefrom: 16.581031,
|
63
|
+
# volumeto: 56637.869999999995
|
64
|
+
# },
|
65
|
+
# ...
|
66
|
+
# ],
|
67
|
+
# TimeTo: 1502259360,
|
68
|
+
# TimeFrom: 1502259120,
|
69
|
+
# FirstValueInArray: true,
|
70
|
+
# ConversionType: {
|
71
|
+
# type: "direct",
|
72
|
+
# conversionSymbol: ""
|
73
|
+
# }
|
74
|
+
# }
|
75
|
+
def self.find(from_sym, to_sym, opts = {})
|
76
|
+
full_path = API_URL + "?fsym=#{from_sym}&tsym=#{to_sym}"
|
77
|
+
|
78
|
+
if (exchange = opts['e'])
|
79
|
+
full_path += "&e=#{ExchangeNameHelper.set_exchange(exchange)}"
|
80
|
+
end
|
81
|
+
|
82
|
+
if (limit = opts['limit'])
|
83
|
+
full_path += "&limit=#{limit}"
|
84
|
+
end
|
85
|
+
|
86
|
+
if (agg = opts['agg'])
|
87
|
+
full_path += "&aggregate=#{agg}"
|
88
|
+
end
|
89
|
+
|
90
|
+
if (to_ts = opts['to_ts'])
|
91
|
+
full_path += "&toTs=#{to_ts}"
|
92
|
+
end
|
93
|
+
|
94
|
+
if (opts['tc'] == false)
|
95
|
+
full_path += "&tryConversion=false"
|
96
|
+
end
|
97
|
+
|
98
|
+
api_resp = Faraday.get(full_path)
|
99
|
+
JSON.parse(api_resp.body)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/cryptocompare/price.rb
CHANGED
@@ -12,14 +12,17 @@ module Cryptocompare
|
|
12
12
|
# 20-60 ms. Cached each 10 seconds.
|
13
13
|
#
|
14
14
|
# ==== Parameters
|
15
|
+
#
|
15
16
|
# * +from_syms+ [String, Array] - (required) currency symbols (ex: 'BTC', 'ETH', 'LTC', 'USD', 'EUR', 'CNY')
|
16
17
|
# * +to_syms+ [String, Array] - (required) currency symbols (ex: 'USD', 'EUR', 'CNY', 'USD', 'EUR', 'CNY')
|
17
18
|
# * +opts+ [Hash] - (optional) options hash
|
18
19
|
#
|
19
20
|
# ==== Options
|
21
|
+
#
|
20
22
|
# * +e+ [String] - (optional) name of exchange (ex: 'Coinbase','Poloniex') Default: CCCAGG.
|
21
23
|
#
|
22
24
|
# ==== Returns
|
25
|
+
#
|
23
26
|
# [Hash] Hash with currency prices
|
24
27
|
#
|
25
28
|
# ==== Examples
|
@@ -15,9 +15,11 @@ module Cryptocompare
|
|
15
15
|
# * +opts+ [Hash] - (optional) options hash
|
16
16
|
#
|
17
17
|
# ==== Options
|
18
|
+
#
|
18
19
|
# * +limit+ [Integer] - (optional) limit. Default 5. Max 2000.
|
19
20
|
#
|
20
21
|
# ==== Returns
|
22
|
+
#
|
21
23
|
# [Hash] Returns a hash containing data as an array of hashes containing
|
22
24
|
# info about top-traded pairs.
|
23
25
|
#
|
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.6.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-08-
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/cryptocompare.rb
|
130
130
|
- lib/cryptocompare/coin_snapshot.rb
|
131
131
|
- lib/cryptocompare/helpers/exchange_name_helper.rb
|
132
|
+
- lib/cryptocompare/histo_minute.rb
|
132
133
|
- lib/cryptocompare/price.rb
|
133
134
|
- lib/cryptocompare/price_historical.rb
|
134
135
|
- lib/cryptocompare/top_pairs.rb
|
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
requirements: []
|
156
157
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.0.14.1
|
158
159
|
signing_key:
|
159
160
|
specification_version: 4
|
160
161
|
summary: A Ruby gem for communicating with the CryptoCompare API
|