coingecko_ruby 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +31 -0
  3. data/.gitignore +11 -0
  4. data/.travis.yml +6 -0
  5. data/CHANGELOG.md +66 -0
  6. data/Gemfile +16 -0
  7. data/Gemfile.lock +37 -0
  8. data/README.md +7 -5
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/coingecko_ruby.gemspec +5 -5
  12. data/fixtures/vcr_cassettes/test_that_it_gets_a_coins_complete_current_data.yml +74 -0
  13. data/fixtures/vcr_cassettes/test_that_it_gets_a_coins_tickers.yml +99 -0
  14. data/fixtures/vcr_cassettes/test_that_it_gets_a_derivative_exchange.yml +71 -0
  15. data/fixtures/vcr_cassettes/test_that_it_gets_a_specific_exchange_ticker_from_an_exchange.yml +145 -0
  16. data/fixtures/vcr_cassettes/test_that_it_gets_btc_to_eth_exchange_rate.yml +120 -0
  17. data/fixtures/vcr_cassettes/test_that_it_gets_btc_to_usd_exchange_rate.yml +122 -0
  18. data/fixtures/vcr_cassettes/test_that_it_gets_complete_data_for_an_exchange.yml +72 -0
  19. data/fixtures/vcr_cassettes/test_that_it_gets_daily_historical_prices_for_one_coin.yml +120 -0
  20. data/fixtures/vcr_cassettes/test_that_it_gets_derivative_exchanges.yml +79 -0
  21. data/fixtures/vcr_cassettes/test_that_it_gets_derivatives.yml +1732 -0
  22. data/fixtures/vcr_cassettes/test_that_it_gets_derivatives_exchanges_ids_and_names.yml +95 -0
  23. data/fixtures/vcr_cassettes/test_that_it_gets_event_countries.yml +76 -0
  24. data/fixtures/vcr_cassettes/test_that_it_gets_event_types.yml +71 -0
  25. data/fixtures/vcr_cassettes/test_that_it_gets_exchange_ids_supported_by_coingecko.yml +159 -0
  26. data/fixtures/vcr_cassettes/test_that_it_gets_exchange_tickers_from_an_exchange.yml +78 -0
  27. data/fixtures/vcr_cassettes/test_that_it_gets_finance_platforms.yml +95 -0
  28. data/fixtures/vcr_cassettes/test_that_it_gets_finance_products.yml +100 -0
  29. data/fixtures/vcr_cassettes/test_that_it_gets_global_crypto_data.yml +71 -0
  30. data/fixtures/vcr_cassettes/test_that_it_gets_global_defi_data.yml +71 -0
  31. data/fixtures/vcr_cassettes/test_that_it_gets_historical_price_for_one_coin_at_a_previous_date.yml +173 -0
  32. data/fixtures/vcr_cassettes/test_that_it_gets_hourly_historical_prices_for_one_coin.yml +120 -0
  33. data/fixtures/vcr_cassettes/test_that_it_gets_indexes.yml +127 -0
  34. data/fixtures/vcr_cassettes/test_that_it_gets_indexes_by_market_id_and_coin_id.yml +66 -0
  35. data/fixtures/vcr_cassettes/test_that_it_gets_indexes_by_market_id_and_index_id.yml +71 -0
  36. data/fixtures/vcr_cassettes/test_that_it_gets_indexes_ids.yml +630 -0
  37. data/fixtures/vcr_cassettes/test_that_it_gets_last_7_days_exchange_volume_from_an_exchange.yml +120 -0
  38. data/fixtures/vcr_cassettes/test_that_it_gets_market_data_for_a_coin.yml +169 -0
  39. data/fixtures/vcr_cassettes/test_that_it_gets_market_data_for_a_coin_in_myr.yml +120 -0
  40. data/fixtures/vcr_cassettes/test_that_it_gets_market_data_for_multiple_coins_in_eth.yml +120 -0
  41. data/fixtures/vcr_cassettes/test_that_it_gets_minutely_historical_prices_for_one_coin.yml +188 -0
  42. data/fixtures/vcr_cassettes/test_that_it_gets_ohlc_data_for_one_coin_in_the_last_30_days_in_myr.yml +120 -0
  43. data/fixtures/vcr_cassettes/test_that_it_gets_ohlc_data_for_one_coin_in_the_last_7_days.yml +120 -0
  44. data/fixtures/vcr_cassettes/test_that_it_gets_price_for_multiple_coins.yml +71 -0
  45. data/fixtures/vcr_cassettes/test_that_it_gets_price_for_multiple_coins_in_different_currencies.yml +71 -0
  46. data/fixtures/vcr_cassettes/test_that_it_gets_price_for_one_coin.yml +122 -0
  47. data/fixtures/vcr_cassettes/test_that_it_gets_price_for_one_coin_in_a_different_currency.yml +120 -0
  48. data/fixtures/vcr_cassettes/test_that_it_gets_simple_price_for_one_coin.yml +73 -0
  49. data/fixtures/vcr_cassettes/test_that_it_gets_status_updates.yml +79 -0
  50. data/fixtures/vcr_cassettes/test_that_it_gets_status_updates_for_an_exchange.yml +76 -0
  51. data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_asset_platforms.yml +80 -0
  52. data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_categories.yml +114 -0
  53. data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_categories_with_market_data.yml +100 -0
  54. data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_supported_coins.yml +143 -0
  55. data/fixtures/vcr_cassettes/test_that_it_gets_the_list_of_supported_exchanges.yml +79 -0
  56. data/fixtures/vcr_cassettes/test_that_it_gets_the_list_supported_coins.yml +74 -0
  57. data/fixtures/vcr_cassettes/test_that_it_gets_trending_searches.yml +77 -0
  58. data/lib/coingecko_ruby.rb +1 -1
  59. data/lib/coingecko_ruby/client.rb +20 -0
  60. data/lib/coingecko_ruby/client/categories.rb +85 -0
  61. data/lib/coingecko_ruby/client/coins.rb +213 -10
  62. data/lib/coingecko_ruby/client/derivatives.rb +154 -0
  63. data/lib/coingecko_ruby/client/events.rb +84 -0
  64. data/lib/coingecko_ruby/client/exchanges.rb +193 -0
  65. data/lib/coingecko_ruby/client/finance.rb +100 -0
  66. data/lib/coingecko_ruby/client/indexes.rb +88 -0
  67. data/lib/coingecko_ruby/client/infos.rb +174 -0
  68. data/lib/coingecko_ruby/client/prices.rb +302 -10
  69. data/lib/coingecko_ruby/client/status.rb +7 -1
  70. data/lib/coingecko_ruby/connection.rb +4 -6
  71. data/lib/coingecko_ruby/version.rb +1 -1
  72. metadata +63 -2
@@ -0,0 +1,154 @@
1
+ module CoingeckoRuby
2
+ class Client
3
+ module Derivatives
4
+ # Fetches the list of derivative products listed in CoinGecko.
5
+ #
6
+ # @option options [String] :include_tickers ('unexpired') determines whether to display all tickers or only show unexpired tickers. Valid values: all, unexpired
7
+ #
8
+ # @return [Array<Hash>] each derivative product's information.
9
+ #
10
+ # @example Get all unexpired derivatives.
11
+ # client.derivatives(include_tickers: 'unexpired')
12
+ # @example Sample response object (truncated)
13
+ # [
14
+ # {
15
+ # "market" => "Binance (Futures)",
16
+ # "symbol" => "BTCUSDT",
17
+ # "index_id" => "BTC",
18
+ # "price" => "44575.26",
19
+ # "price_percentage_change_24h" => -0.5892545887194689,
20
+ # "contract_type" => "perpetual",
21
+ # "index" => 44646.70155337,
22
+ # "basis" => -0.11242030301843862,
23
+ # "spread" => 0.01,
24
+ # "funding_rate" => 0.021205,
25
+ # "open_interest" => 1822639548.16,
26
+ # "volume_24h" => 27179643527.25483,
27
+ # "last_traded_at" => 1621341447,
28
+ # "expired_at" => nil
29
+ # },
30
+ # {
31
+ # "market" => "Bybit",
32
+ # "symbol" => "BTCUSD",
33
+ # "index_id" => "BTC",
34
+ # "price" => "44817.5",
35
+ # "price_percentage_change_24h" => -0.9426664309079656,
36
+ # "contract_type" => "perpetual",
37
+ # "index" => 44827.57,
38
+ # "basis" => 0.022468901656718915,
39
+ # "spread" => 0.01,
40
+ # "funding_rate" => 0.01,
41
+ # "open_interest" => 1664013731.0,
42
+ # "volume_24h" => 5725694670.15,
43
+ # "last_traded_at" => 1621340931,
44
+ # "expired_at" => nil
45
+ # },
46
+ # ]
47
+ def derivatives(**options)
48
+ get 'derivatives', options
49
+ end
50
+
51
+ # @deprecated Use {#derivatives} instead
52
+ def get_derivatives(options: {})
53
+ derivatives(**options)
54
+ end
55
+
56
+ # Fetches the list of derivative exchanges listed in CoinGecko.
57
+ #
58
+ # @option options [Integer] :per_page sets the number of results to return per page.
59
+ # @option options [Integer] :page sets the page for results.
60
+ # @option options [String] :order sets the sort order for results. Valid values: name_asc, name_desc, open_interest_btc_asc, open_interest_btc_desc, trade_volume_24h_btc_asc, trade_volume_24h_btc_desc.
61
+ #
62
+ # @return [Array<Hash>] each derivative exchange's information.
63
+ #
64
+ # @example Get one derivative exchange.
65
+ # client.derivative_exchanges(per_page: 1)
66
+ # @example Sample response object
67
+ # [{
68
+ # "name" => "Binance (Futures)",
69
+ # "id" => "binance_futures",
70
+ # "open_interest_btc" => 237845.78,
71
+ # "trade_volume_24h_btc" => "2209372.18",
72
+ # "number_of_perpetual_pairs" => 132,
73
+ # "number_of_futures_pairs" => 32,
74
+ # "image" =>
75
+ # "https://assets.coingecko.com/markets/images/466/small/binance_futures.jpg?1568609512",
76
+ # "year_established" => 2019,
77
+ # "country" => nil,
78
+ # "description" => "",
79
+ # "url" => "https://www.binance.com/"
80
+ # }]
81
+ def derivative_exchanges(**options)
82
+ get 'derivatives/exchanges', options
83
+ end
84
+
85
+ # @deprecated Use {#derivative_exchanges} instead
86
+ def get_derivative_exchanges(options: {})
87
+ derivative_exchanges(**options)
88
+ end
89
+
90
+ # Fetches data for a specific derivative exchange.
91
+ #
92
+ # @param id [String] the id of the derivative exchange.
93
+ #
94
+ # @option options [String] :include_tickers determines whether to display all tickers or only show unexpired tickers. Does not return any ticker data if left blank. Valid values: all, unexpired
95
+ #
96
+ # @return [Hash] the derivative exchange's information.
97
+ #
98
+ # @example Get data for the Binance Futures derivative exchange.
99
+ # client.derivative_exchange('binance_futures')
100
+ # @example Sample response object
101
+ # {
102
+ # "name" => "Binance (Futures)",
103
+ # "open_interest_btc" => 237845.78,
104
+ # "trade_volume_24h_btc" => "2226117.02",
105
+ # "number_of_perpetual_pairs" => 132,
106
+ # "number_of_futures_pairs" => 32,
107
+ # "image" =>
108
+ # "https://assets.coingecko.com/markets/images/466/small/binance_futures.jpg?1568609512",
109
+ # "year_established" => 2019,
110
+ # "country" => nil,
111
+ # "description" => "",
112
+ # "url" => "https://www.binance.com/"
113
+ # }
114
+ def derivative_exchange(id, **options)
115
+ get "derivatives/exchanges/#{id}", options
116
+ end
117
+
118
+ # @deprecated Use {#derivative_exchange} instead
119
+ def get_derivative_exchange(id:, options: {})
120
+ derivative_exchange(id, **options)
121
+ end
122
+
123
+ # Fetches the list ids and names of derivative exchanges listed in CoinGecko.
124
+ #
125
+ # @return [Array<Hash>] each derivative exchange's id and name.
126
+ #
127
+ # @example Get all unexpired derivatives.
128
+ # client.derivative_exchanges_ids_and_names
129
+ # @example Sample response object (truncated)
130
+ # [
131
+ # {
132
+ # "id" => "binance_futures",
133
+ # "name" => "Binance (Futures)"
134
+ # },
135
+ # {
136
+ # "id" => "huobi_dm",
137
+ # "name" => "Huobi Futures"
138
+ # },
139
+ # {
140
+ # "id" => "ftx",
141
+ # "name" => "FTX (Derivatives)"
142
+ # }
143
+ # ]
144
+ def derivative_exchanges_ids_and_names
145
+ get 'derivatives/exchanges/list'
146
+ end
147
+
148
+ # @deprecated Use {#derivative_exchanges_ids_and_names} instead
149
+ def get_derivative_exchanges_ids_and_names
150
+ derivative_exchanges_ids_and_names
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,84 @@
1
+ module CoingeckoRuby
2
+ class Client
3
+ module Events
4
+ # Fetches the list of events listed in CoinGecko.
5
+ # @todo CoinGecko API is not returning any list of events. Investigate why this is happening.
6
+ #
7
+ # @option options [String] :country_code country code to fetch list of events from.
8
+ # @option options [String] :type type of event to fetch.
9
+ # @option options [Integer] :page sets the page for results.
10
+ # @option options [Boolean] :upcoming_events_only (true) determines whether to fetch upcoming events only or all events.
11
+ # @option options [String] :from_date fetch events after the specified date. Date must be in the format of yyyy-mm-dd
12
+ # @option options [String] :to_date fetch events before the specified date. Date must be in the format of yyyy-mm-dd
13
+ #
14
+ # @return [Array<Hash>] each finance platform's name, category, url, facts (description), and centralized status.
15
+ #
16
+ # @example Get all upcoming events.
17
+ # client.events(upcoming_events_only: true)
18
+ def events(**options)
19
+ get 'events', options
20
+ end
21
+
22
+ # @deprecated Use {#events} instead
23
+ def get_events(options: {})
24
+ events(**options)
25
+ end
26
+
27
+ # Fetches the valid list of countries to fetch events from.
28
+ #
29
+ # @return [Hash] each country's name and code and the total country count.
30
+ #
31
+ # @example Get all event countries.
32
+ # client.event_countries
33
+ # @example Sample response object (truncated)
34
+ # {
35
+ # "data" => [{
36
+ # "country" => nil,
37
+ # "code" => ""
38
+ # },
39
+ # {
40
+ # "country" => "Malaysia",
41
+ # "code" => "MY"
42
+ # },
43
+ # {
44
+ # "country" => "Singapore",
45
+ # "code" => "SG"
46
+ # },
47
+ # {
48
+ # "country" => "United States",
49
+ # "code" => "US"
50
+ # }
51
+ # ],
52
+ # "count" => 4
53
+ # }
54
+ def event_countries
55
+ get 'events/countries'
56
+ end
57
+
58
+ # @deprecated Use {#event_countries} instead
59
+ def get_event_countries
60
+ event_countries
61
+ end
62
+
63
+ # Fetches the valid list of events to fetch.
64
+ #
65
+ # @return [Array<Hash>] the list of event types and total event types count.
66
+ #
67
+ # @example Get all event types.
68
+ # client.event_types
69
+ # @example Sample response object
70
+ # {
71
+ # "data" => ["Event", "Conference", "Meetup"],
72
+ # "count" => 3
73
+ # }
74
+ def event_types
75
+ get 'events/types'
76
+ end
77
+
78
+ # @deprecated Use {#event_types} instead
79
+ def get_event_types
80
+ event_types
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,193 @@
1
+ module CoingeckoRuby
2
+ class Client
3
+ module Exchanges
4
+ # Fetches complete data for every exchange currently supported by the CoinGecko API.
5
+ #
6
+ # @option options [Integer] :per_page (100) sets the number of results to return per page.
7
+ # @option options [Integer] :page sets the page for results.
8
+ #
9
+ # @return [Array<Hash>] returns an array of hashes of detailed exchange data.
10
+ #
11
+ # @example Fetch complete exchange data with 1 result per page.
12
+ # client.exchanges(per_page: 1)
13
+ # @example Sample response object
14
+ # [{
15
+ # "id" => "binance",
16
+ # "name" => "Binance",
17
+ # "year_established" => 2017,
18
+ # "country" => "Cayman Islands",
19
+ # "description" => "",
20
+ # "url" => "https://www.binance.com/",
21
+ # "image" => "https://assets.coingecko.com/markets/images/52/small/binance.jpg?1519353250",
22
+ # "has_trading_incentive" => false,
23
+ # "trust_score" => 10,
24
+ # "trust_score_rank" => 1,
25
+ # "trade_volume_24h_btc" => 982949.3975723931,
26
+ # "trade_volume_24h_btc_normalized" => 982949.3975723931
27
+ # }]
28
+ def exchanges(**options)
29
+ get 'exchanges', options
30
+ end
31
+
32
+ # @deprecated Use {#exchanges} instead
33
+ def get_exchanges(options: {})
34
+ exchanges(**options)
35
+ end
36
+
37
+ # Fetches complete data for a specific exchange.
38
+ #
39
+ # @param id [String] the exchange id to fetch.
40
+ #
41
+ # @return [Hash] returns detailed data for the given exchange.
42
+ #
43
+ # @example Fetch complete exchange data for Binance.
44
+ # client.exchange('binance')
45
+ def exchange(id)
46
+ get "exchanges/#{id}"
47
+ end
48
+
49
+ # @deprecated Use {#exchange} instead
50
+ def get_exchange_data(id:)
51
+ exchange(id)
52
+ end
53
+
54
+ # Fetches exchange ids for every exchange currently supported by the CoinGecko API.
55
+ #
56
+ # @return [Array<Hash>] returns an array of hashes of the exchange id and name.
57
+ #
58
+ # @example Fetch all exchange ids.
59
+ # client.exchange_ids
60
+ # @example Sample response object
61
+ # [{
62
+ # "id" => "aave",
63
+ # "name" => "Aave"
64
+ # }, {
65
+ # "id" => "aax",
66
+ # "name" => "AAX"
67
+ # }, {
68
+ # "id" => "aax_futures",
69
+ # "name" => "AAX Futures"
70
+ # }]
71
+ def exchange_ids
72
+ get 'exchanges/list'
73
+ end
74
+
75
+ # @deprecated Use {#exchange_ids} instead
76
+ def get_exchanges_ids
77
+ exchange_ids
78
+ end
79
+
80
+ # Fetches coin tickers from a specific exchange.
81
+ #
82
+ # @param id [String] the exchange id to fetch.
83
+ #
84
+ # @option options [String] :coin_ids comma-separated list of tickers to fetch from the given exchange id (e.g. 'bitcoin, eth, litecoin').
85
+ # @option options [String] :include_exchange_logo includes the exchange's logo.
86
+ # @option options [Integer] :page sets the page for results.
87
+ # @option options [String] :order ('trust_score_desc') sets the sort order for results. Valid values: trust_score_desc', 'trust_score_asc', 'volume_desc.
88
+ # @option options [Boolean] :depth (false) displays orderbook depth (2%).
89
+ #
90
+ # @return [Hash] the exchange name and tickers as provided or all tickers if coin_ids is not provided.
91
+ #
92
+ # @example Get Bitcoin tickers from Binance.
93
+ # client.exchange_tickers('binance', coin_ids: 'bitcoin')
94
+ # @example Sample response object
95
+ # {
96
+ # "name" => "Binance", "tickers" => [{
97
+ # "base" => "BTC",
98
+ # "target" => "USDT",
99
+ # "market" => {
100
+ # "name" => "Binance", "identifier" => "binance", "has_trading_incentive" => false
101
+ # },
102
+ # "last" => 48890.78,
103
+ # "volume" => 86837.96789156958,
104
+ # "converted_last" => {
105
+ # "btc" => 0.99871776, "eth" => 12.706618, "usd" => 48867
106
+ # },
107
+ # "converted_volume" => {
108
+ # "btc" => 86727, "eth" => 1103417, "usd" => 4243490314
109
+ # },
110
+ # "trust_score" => "green",
111
+ # "bid_ask_spread_percentage" => 0.01002,
112
+ # "timestamp" => "2021-05-16T07:37:00+00:00",
113
+ # "last_traded_at" => "2021-05-16T07:37:00+00:00",
114
+ # "last_fetch_at" => "2021-05-16T07:37:00+00:00",
115
+ # "is_anomaly" => false,
116
+ # "is_stale" => false,
117
+ # "trade_url" => "https://www.binance.com/en/trade/BTC_USDT?ref=37754157",
118
+ # "token_info_url" => nil,
119
+ # "coin_id" => "bitcoin",
120
+ # "target_coin_id" => "tether"
121
+ # }]
122
+ # }
123
+ def exchange_tickers(id, **options)
124
+ get "exchanges/#{id}/tickers", options
125
+ end
126
+
127
+ # @deprecated Use {#exchange_tickers} instead
128
+ def get_exchange_tickers(id:, options: {})
129
+ exchange_tickers(id, **options)
130
+ end
131
+
132
+ # Fetches news,announcments, and updates from a specific exchange.
133
+ #
134
+ # @param id [String] the exchange id to fetch.
135
+ #
136
+ # @option options [Integer] :per_page (100) sets the number of results to return per page.
137
+ # @option options [Integer] :page sets the page for results.
138
+ #
139
+ # @return [Hash] the status update data for the given exchange.
140
+ #
141
+ # @example Get the last 3 status updates from Binance.
142
+ # client.exchange_status('binance', per_page: 1)
143
+ # @example Sample response object
144
+ # {
145
+ # "status_updates" => [{
146
+ # "description" => "Juventus and Paris Saint-Germain Fan Tokens on Binance Launchpool! \r\n\r\nFarm JUV and PSG tokens By Staking BNB, BUSD & CHZ Tokens\r\n\r\nClick here➡️ https://ter.li/JUV-and-PSG-tokens",
147
+ # "category" => "general",
148
+ # "created_at" => "2020-12-14T11:18:49.085Z",
149
+ # "user" => "Darc",
150
+ # "user_title" => "Marketing",
151
+ # "pin" => false,
152
+ # "project" => {
153
+ # "type" => "Market", "id" => "binance", "name" => "Binance", "image" => {
154
+ # "thumb" => "https://assets.coingecko.com/markets/images/52/thumb/binance.jpg?1519353250", "small" => "https://assets.coingecko.com/markets/images/52/small/binance.jpg?1519353250", "large" => "https://assets.coingecko.com/markets/images/52/large/binance.jpg?1519353250"
155
+ # }
156
+ # }
157
+ # }]
158
+ # }
159
+ def exchange_status(id, **options)
160
+ get "exchanges/#{id}/status_updates", options
161
+ end
162
+
163
+ # @deprecated Use {#exchange_status} instead
164
+ def get_exchange_status_updates(id:, options: {})
165
+ exchange_status(id, **options)
166
+ end
167
+
168
+ # Fetches trade volume data from a specific exchange.
169
+ #
170
+ # @param id [String] the exchange id to fetch.
171
+ # @param days [Integer] number of days ago to fetch trade volume data. Defaults to 7 days.
172
+ #
173
+ # @return [Array<Array<Float, String>>] the exchange's trade volume data in 10-minute intervals, hourly intervals, or daily intervals depending on the number of days given
174
+ #
175
+ # @example Get Binance's trade volume from a day ago.
176
+ # client.exchange_volume('binance', days: 1)
177
+ # @example Sample response object (truncated)
178
+ # [
179
+ # [1620550200000.0, "1005476.2667217359131632087795432176371669876601688256288859094077173967202827700534809705802"], # [UNIX timestamp for exchange trade volume data, trade volume]
180
+ # [1620553800000.0, "1018442.2775982988468591292487708941265043962519659923872972786095536137127193126138169804088"],
181
+ # [1620557400000.0, "1042158.4333253484568599192332614201045319574863305612009609211497295171074087677404153278624"]
182
+ # ]
183
+ def exchange_volume(id, days: 7, **options)
184
+ get "exchanges/#{id}/volume_chart", { days: days, **options }
185
+ end
186
+
187
+ # @deprecated Use {#exchange_volume} instead
188
+ def get_exchange_volume(id:, days:)
189
+ exchange_volume(id, days: days)
190
+ end
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,100 @@
1
+ module CoingeckoRuby
2
+ class Client
3
+ module Finance
4
+ # Fetches the list of finance platforms (e.g. Celsius Network, dYdX) listed in CoinGecko.
5
+ #
6
+ # @option options [Integer] :per_page (100) sets the number of results to return per page.
7
+ # @option options [Integer] :page sets the page for results.
8
+ #
9
+ # @return [Array<Hash>] each finance platform's name, category, url, facts (description), and centralized status.
10
+ #
11
+ # @example Get all finance platforms.
12
+ # client.finance_platforms
13
+ # @example Sample response object (truncated)
14
+ # [
15
+ # {
16
+ # "name"=>"Binance Staking",
17
+ # "facts"=>"",
18
+ # "category"=>"CeFi Platform",
19
+ # "centralized"=>true,
20
+ # "website_url"=>"https://www.binance.com/en/staking"
21
+ # },
22
+ # {
23
+ # "name"=>"Celsius Network",
24
+ # "facts"=>"",
25
+ # "category"=>"CeFi Platform",
26
+ # "centralized"=>true,
27
+ # "website_url"=>"https://celsius.network/"
28
+ # },
29
+ # {
30
+ # "name"=>"Cobo",
31
+ # "facts"=>"",
32
+ # "category"=>"CeFi Platform",
33
+ # "centralized"=>true,
34
+ # "website_url"=>"https://cobo.com/"
35
+ # }
36
+ # ]
37
+ def finance_platforms(**options)
38
+ get 'finance_platforms', options
39
+ end
40
+
41
+ # @deprecated Use {#finance_platforms} instead
42
+ def get_finance_platforms(options: {})
43
+ finance_platforms(**options)
44
+ end
45
+
46
+ # Fetches the list of finance products (e.g. Binance Savings, Nexo, Fulcrum) listed in CoinGecko.
47
+ #
48
+ # @option options [Integer] :per_page (100) sets the number of results to return per page.
49
+ # @option options [Integer] :page sets the page for results.
50
+ # @option options [Integer] :start_at filter results based on the launch date of the product in UNIX timestamp format.
51
+ # @option options [Integer] :end_at filter results based on the end date of the product in UNIX timestamp format.
52
+ #
53
+ # @return [Array<Hash>] each finance product's platform, identifier, supply and borrow rate percentage, and the product duration data.
54
+ #
55
+ # @example Get all finance products.
56
+ # client.finance_products
57
+ # @example Sample response object (truncated)
58
+ # [
59
+ # {"platform"=>"Binance Savings",
60
+ # "identifier"=>"XTZ001",
61
+ # "supply_rate_percentage"=>"1.956035",
62
+ # "borrow_rate_percentage"=>nil,
63
+ # "number_duration"=>nil,
64
+ # "length_duration"=>nil,
65
+ # "start_at"=>0,
66
+ # "end_at"=>0,
67
+ # "value_at"=>0,
68
+ # "redeem_at"=>0},
69
+ # {"platform"=>"Binance Savings",
70
+ # "identifier"=>"ZEC001",
71
+ # "supply_rate_percentage"=>"0.182865",
72
+ # "borrow_rate_percentage"=>nil,
73
+ # "number_duration"=>nil,
74
+ # "length_duration"=>nil,
75
+ # "start_at"=>0,
76
+ # "end_at"=>0,
77
+ # "value_at"=>0,
78
+ # "redeem_at"=>0},
79
+ # {"platform"=>"Crypto.com",
80
+ # "identifier"=>"BAT",
81
+ # "supply_rate_percentage"=>"2.0",
82
+ # "borrow_rate_percentage"=>nil,
83
+ # "number_duration"=>nil,
84
+ # "length_duration"=>nil,
85
+ # "start_at"=>0,
86
+ # "end_at"=>0,
87
+ # "value_at"=>0,
88
+ # "redeem_at"=>0}
89
+ # ]
90
+ def finance_products(**options)
91
+ get 'finance_products', options
92
+ end
93
+
94
+ # @deprecated Use {#finance_products} instead
95
+ def get_finance_products(options: {})
96
+ finance_products(**options)
97
+ end
98
+ end
99
+ end
100
+ end