brapi-ruby-sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +56 -6
- data/lib/brapi/model.rb +1 -0
- data/lib/brapi/models/pagination.rb +15 -0
- data/lib/brapi/models/v2/fii.rb +54 -0
- data/lib/brapi/models/v2/fii_dividend.rb +19 -0
- data/lib/brapi/models/v2/fii_dividends_response.rb +13 -0
- data/lib/brapi/models/v2/fii_historical_response.rb +13 -0
- data/lib/brapi/models/v2/fii_history.rb +15 -0
- data/lib/brapi/models/v2/fii_indicators_response.rb +13 -0
- data/lib/brapi/models/v2/fii_list_response.rb +14 -0
- data/lib/brapi/models/v2/macro_list_available_response.rb +15 -0
- data/lib/brapi/models/v2/macro_observation.rb +12 -0
- data/lib/brapi/models/v2/macro_result.rb +14 -0
- data/lib/brapi/models/v2/macro_retrieve_response.rb +13 -0
- data/lib/brapi/models/v2/macro_series.rb +17 -0
- data/lib/brapi/models/v2/treasury_bond.rb +28 -0
- data/lib/brapi/models/v2/treasury_indicators_response.rb +13 -0
- data/lib/brapi/models/v2/treasury_list_response.rb +14 -0
- data/lib/brapi/models/v2/treasury_rate_info.rb +13 -0
- data/lib/brapi/resource.rb +7 -0
- data/lib/brapi/resources/v2/fii.rb +33 -0
- data/lib/brapi/resources/v2/macro.rb +21 -0
- data/lib/brapi/resources/v2/treasury.rb +21 -0
- data/lib/brapi/resources/v2.rb +12 -0
- data/lib/brapi/version.rb +1 -1
- data/lib/brapi.rb +24 -0
- metadata +22 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 05b2bc6fb4061903f31d59574c62333d8410d7228d3e9b1664a3efc04e024eee
|
|
4
|
+
data.tar.gz: 299938eb28c85c3b53d0c56e78f40f3ff552bc662b513ea1bb2db051db3d35f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2aeaa5ecd337d64825b59a7ff6617a74c9de2f8b14a0d83891f23c51ca79a5c7dec5918da537604d43fe13ee23eb602c50295b851d83258f1453f71c9ccf6929
|
|
7
|
+
data.tar.gz: 10792774a48f8862197fa6abfa230822121d1d1d519d75d0021dbab3597963dd1caf5e7acfd8f3da589e186a8ddfbe18fd65f0330ff6ddae34d190676dbacd9e
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-05-28
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **FIIs (Fundos Imobiliários)** — new `client.v2.fii.*` resource backed by
|
|
15
|
+
`/api/v2/fii/...`:
|
|
16
|
+
- `client.v2.fii.list(**params)` — paginated listing
|
|
17
|
+
- `client.v2.fii.indicators(symbols, **params)` — current NAV / yield / etc.
|
|
18
|
+
- `client.v2.fii.historical(symbols, **params)` — OHLCV history
|
|
19
|
+
- `client.v2.fii.dividends(symbols, **params)` — payment history
|
|
20
|
+
- **Macro (séries temporais)** — new `client.v2.macro.*` resource backed by
|
|
21
|
+
`/api/v2/macro`:
|
|
22
|
+
- `client.v2.macro.retrieve(symbols, **params)` — series + observations
|
|
23
|
+
for SELIC, IPCA, CDI and other indicators
|
|
24
|
+
- `client.v2.macro.list_available` — all available series + categories
|
|
25
|
+
- **Tesouro Direto** — new `client.v2.treasury.*` resource backed by
|
|
26
|
+
`/api/v2/treasury/...`:
|
|
27
|
+
- `client.v2.treasury.list(**params)` — paginated bond listing
|
|
28
|
+
- `client.v2.treasury.indicators(symbols, **params)` — current rates +
|
|
29
|
+
prices for specific bonds
|
|
30
|
+
- Typed models for every new shape: `Fii`, `FiiDividend`, `FiiHistory`,
|
|
31
|
+
`MacroSeries`, `MacroObservation`, `MacroResult`, `TreasuryBond`,
|
|
32
|
+
`TreasuryRateInfo`, `Pagination`, plus per-endpoint Response classes.
|
|
33
|
+
- `Brapi::Models::V2::Pagination` reused across the paginated FII and
|
|
34
|
+
Treasury list endpoints.
|
|
35
|
+
|
|
36
|
+
### Notes
|
|
37
|
+
|
|
38
|
+
- All v0.3 endpoints require a paid brapi token (Startup or Pro plan).
|
|
39
|
+
- Schemas were captured directly from the live API (MXRF11, SELIC,
|
|
40
|
+
tesouro-selic-01032031); an ad-hoc smoke test against brapi.dev
|
|
41
|
+
confirmed round-trip parsing for every new endpoint.
|
|
42
|
+
|
|
10
43
|
## [0.2.0] - 2026-05-28
|
|
11
44
|
|
|
12
45
|
### Added
|
data/README.md
CHANGED
|
@@ -93,6 +93,14 @@ client.quote.retrieve("PETR4")
|
|
|
93
93
|
| `client.v2.inflation.list_available` | `GET /api/v2/inflation/available` | Countries with inflation data |
|
|
94
94
|
| `client.v2.prime_rate.retrieve(...)` | `GET /api/v2/prime-rate` | SELIC / prime-rate series |
|
|
95
95
|
| `client.v2.prime_rate.list_available` | `GET /api/v2/prime-rate/available` | Countries with prime-rate data |
|
|
96
|
+
| `client.v2.fii.list(...)` | `GET /api/v2/fii/list` | Real Estate Funds (FIIs) listing |
|
|
97
|
+
| `client.v2.fii.indicators(syms, ...)` | `GET /api/v2/fii/indicators` | FII indicators (NAV, dividend yield) |
|
|
98
|
+
| `client.v2.fii.historical(syms, ...)` | `GET /api/v2/fii/historical` | FII OHLCV historical prices |
|
|
99
|
+
| `client.v2.fii.dividends(syms, ...)` | `GET /api/v2/fii/dividends` | FII dividend payment history |
|
|
100
|
+
| `client.v2.macro.retrieve(syms, ...)` | `GET /api/v2/macro` | Macro time series (SELIC, IPCA, CDI…) |
|
|
101
|
+
| `client.v2.macro.list_available` | `GET /api/v2/macro/available` | Available macro series |
|
|
102
|
+
| `client.v2.treasury.list(...)` | `GET /api/v2/treasury/list` | Tesouro Direto bonds listing |
|
|
103
|
+
| `client.v2.treasury.indicators(syms…)` | `GET /api/v2/treasury/indicators` | Current rates / prices for bonds |
|
|
96
104
|
|
|
97
105
|
All params are passed as Ruby kwargs (snake_case) and the SDK converts them to the camelCase expected by the API (e.g. `sort_by: "volume"` → `?sortBy=volume`).
|
|
98
106
|
|
|
@@ -161,6 +169,49 @@ resp = Brapi.v2.prime_rate.retrieve(country: "brazil")
|
|
|
161
169
|
resp.prime_rate.each { |p| puts "#{p.date}: #{p.value}% p.a." }
|
|
162
170
|
```
|
|
163
171
|
|
|
172
|
+
### Real Estate Funds (FIIs)
|
|
173
|
+
|
|
174
|
+
```ruby
|
|
175
|
+
# Browse FIIs with pagination
|
|
176
|
+
page = Brapi.v2.fii.list(limit: 20)
|
|
177
|
+
page.fiis.each { |f| puts "#{f.symbol} (#{f.segmento_atuacao}): R$ #{f.price}" }
|
|
178
|
+
puts "Page #{page.pagination.page}/#{page.pagination.total_pages}"
|
|
179
|
+
|
|
180
|
+
# Current indicators for specific FIIs
|
|
181
|
+
ind = Brapi.v2.fii.indicators(%w[MXRF11 KNRI11])
|
|
182
|
+
ind.fiis.each { |f| puts "#{f.symbol} NAV=#{f.nav_per_share} DY12m=#{f.dividend_yield12m}" }
|
|
183
|
+
|
|
184
|
+
# Dividend history
|
|
185
|
+
divs = Brapi.v2.fii.dividends("MXRF11")
|
|
186
|
+
divs.dividends.each { |d| puts "#{d.payment_date}: R$ #{d.rate}" }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Macro time series (SELIC, IPCA, CDI...)
|
|
190
|
+
|
|
191
|
+
```ruby
|
|
192
|
+
resp = Brapi.v2.macro.retrieve("SELIC")
|
|
193
|
+
result = resp.results.first
|
|
194
|
+
puts "#{result.series.name} (#{result.series.unit})"
|
|
195
|
+
result.observations.each { |o| puts "#{o.date}: #{o.value}" }
|
|
196
|
+
|
|
197
|
+
# List available series
|
|
198
|
+
Brapi.v2.macro.list_available.results.each { |s| puts "#{s.slug}: #{s.name}" }
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Tesouro Direto (Treasury)
|
|
202
|
+
|
|
203
|
+
```ruby
|
|
204
|
+
# Browse available bonds
|
|
205
|
+
page = Brapi.v2.treasury.list
|
|
206
|
+
page.results.each do |bond|
|
|
207
|
+
puts "#{bond.symbol}: buy=#{bond.buy_rate}% sell_price=R$ #{bond.sell_price}"
|
|
208
|
+
puts " Rate interpretation: #{bond.rate_info.description}"
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Current rates for specific bonds
|
|
212
|
+
Brapi.v2.treasury.indicators("tesouro-selic-01032031")
|
|
213
|
+
```
|
|
214
|
+
|
|
164
215
|
### List/filter stocks
|
|
165
216
|
|
|
166
217
|
```ruby
|
|
@@ -207,13 +258,12 @@ The SDK automatically retries transient 5xx errors (502/503/504) up to twice wit
|
|
|
207
258
|
|
|
208
259
|
## Roadmap
|
|
209
260
|
|
|
210
|
-
v0.1
|
|
261
|
+
v0.1 shipped the 11 endpoints supported by the official SDKs. v0.2 added typed
|
|
262
|
+
models for every Quote fundamental module. v0.3 added FIIs, Macro and Tesouro
|
|
263
|
+
Direto. Future minor versions:
|
|
211
264
|
|
|
212
|
-
- `client.
|
|
213
|
-
- `client.
|
|
214
|
-
- `client.options.*` — Options chain & history
|
|
215
|
-
- `client.treasury.*` — Tesouro Direto
|
|
216
|
-
- `client.futures.*` — Futures contracts
|
|
265
|
+
- `client.v2.options.*` — Options chain & history
|
|
266
|
+
- `client.v2.futures.*` — Futures contracts
|
|
217
267
|
|
|
218
268
|
## Development
|
|
219
269
|
|
data/lib/brapi/model.rb
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
# Pagination metadata returned by paginated brapi endpoints
|
|
6
|
+
# (e.g. /api/v2/fii/list, /api/v2/treasury/list, /api/quote/list).
|
|
7
|
+
class Pagination < Brapi::Model
|
|
8
|
+
attribute :page, type: :integer
|
|
9
|
+
attribute :limit, type: :integer
|
|
10
|
+
attribute :total_items, type: :integer
|
|
11
|
+
attribute :total_pages, type: :integer
|
|
12
|
+
attribute :has_next_page, type: :boolean
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
# Single class backing both /api/v2/fii/list (basic info) and
|
|
7
|
+
# /api/v2/fii/indicators (basic info + current indicators).
|
|
8
|
+
# Indicator-only fields come back nil from the list endpoint.
|
|
9
|
+
class Fii < Brapi::Model
|
|
10
|
+
attribute :symbol, type: :string
|
|
11
|
+
attribute :name, type: :string
|
|
12
|
+
attribute :cnpj, type: :string
|
|
13
|
+
attribute :mandate, type: :string
|
|
14
|
+
# NOTE: brapi exposes these two fields in Portuguese (`segmentoAtuacao`,
|
|
15
|
+
# `tipoGestao`); everything else in the response uses English. If the
|
|
16
|
+
# upstream renames them in a future API revision, callers reading
|
|
17
|
+
# `#segmento_atuacao` / `#tipo_gestao` will silently get nil and need
|
|
18
|
+
# the attribute names updated here.
|
|
19
|
+
attribute :segmento_atuacao, type: :string
|
|
20
|
+
attribute :tipo_gestao, type: :string
|
|
21
|
+
attribute :segment_type, type: :string
|
|
22
|
+
|
|
23
|
+
attribute :administrator_name, type: :string
|
|
24
|
+
attribute :administrator_cnpj, type: :string
|
|
25
|
+
attribute :administrator_address, type: :string
|
|
26
|
+
attribute :administrator_address_number, type: :string
|
|
27
|
+
attribute :administrator_address_complement, type: :string
|
|
28
|
+
attribute :administrator_district, type: :string
|
|
29
|
+
attribute :administrator_city, type: :string
|
|
30
|
+
attribute :administrator_state, type: :string
|
|
31
|
+
attribute :administrator_zip_code, type: :string
|
|
32
|
+
attribute :administrator_phone1, type: :string
|
|
33
|
+
attribute :administrator_phone2, type: :string
|
|
34
|
+
attribute :administrator_phone3, type: :string
|
|
35
|
+
attribute :administrator_website, type: :string
|
|
36
|
+
attribute :administrator_email, type: :string
|
|
37
|
+
|
|
38
|
+
attribute :price, type: :float
|
|
39
|
+
attribute :nav_per_share, type: :float
|
|
40
|
+
attribute :price_to_nav, type: :float
|
|
41
|
+
attribute :dividend_yield12m, type: :float, json_key: "dividendYield12m"
|
|
42
|
+
attribute :total_investors, type: :integer
|
|
43
|
+
|
|
44
|
+
# Indicators-only fields (nil when returned by /fii/list)
|
|
45
|
+
attribute :as_of_date, type: :date
|
|
46
|
+
attribute :dividend_yield1m, type: :float, json_key: "dividendYield1m"
|
|
47
|
+
attribute :monthly_return, type: :float
|
|
48
|
+
attribute :shares_outstanding, type: :integer
|
|
49
|
+
attribute :equity
|
|
50
|
+
attribute :total_assets
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class FiiDividend < Brapi::Model
|
|
7
|
+
attribute :symbol, type: :string
|
|
8
|
+
attribute :label, type: :string
|
|
9
|
+
attribute :rate, type: :float
|
|
10
|
+
attribute :related_to, type: :string
|
|
11
|
+
attribute :approved_on, type: :time
|
|
12
|
+
attribute :last_date_prior, type: :time
|
|
13
|
+
attribute :payment_date, type: :time
|
|
14
|
+
attribute :isin_code, type: :string
|
|
15
|
+
attribute :remarks, type: :string
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class FiiDividendsResponse < Brapi::Model
|
|
7
|
+
attribute :dividends, type: [Brapi::Models::V2::FiiDividend]
|
|
8
|
+
attribute :requested_at, type: :time
|
|
9
|
+
attribute :took, type: :integer
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class FiiHistoricalResponse < Brapi::Model
|
|
7
|
+
attribute :fiis, type: [Brapi::Models::V2::FiiHistory]
|
|
8
|
+
attribute :requested_at, type: :time
|
|
9
|
+
attribute :took, type: :integer
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
# Wraps a single FII's historical price series. The historical_data_price
|
|
7
|
+
# entries reuse Brapi::Models::HistoricalDataPrice (same OHLCV shape as
|
|
8
|
+
# /api/quote/{ticker}?range=...).
|
|
9
|
+
class FiiHistory < Brapi::Model
|
|
10
|
+
attribute :symbol, type: :string
|
|
11
|
+
attribute :historical_data_price, type: [Brapi::Models::HistoricalDataPrice]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class FiiIndicatorsResponse < Brapi::Model
|
|
7
|
+
attribute :fiis, type: [Brapi::Models::V2::Fii]
|
|
8
|
+
attribute :requested_at, type: :time
|
|
9
|
+
attribute :took, type: :integer
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class FiiListResponse < Brapi::Model
|
|
7
|
+
attribute :fiis, type: [Brapi::Models::V2::Fii]
|
|
8
|
+
attribute :pagination, type: Brapi::Models::Pagination
|
|
9
|
+
attribute :requested_at, type: :time
|
|
10
|
+
attribute :took, type: :integer
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class MacroListAvailableResponse < Brapi::Model
|
|
7
|
+
attribute :results, type: [Brapi::Models::V2::MacroSeries]
|
|
8
|
+
attribute :categories
|
|
9
|
+
attribute :count, type: :integer
|
|
10
|
+
attribute :requested_at, type: :time
|
|
11
|
+
attribute :took, type: :integer
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
# One result entry from /api/v2/macro: a MacroSeries description plus
|
|
7
|
+
# the observation rows (date + value) for that series.
|
|
8
|
+
class MacroResult < Brapi::Model
|
|
9
|
+
attribute :series, type: Brapi::Models::V2::MacroSeries
|
|
10
|
+
attribute :observations, type: [Brapi::Models::V2::MacroObservation]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class MacroRetrieveResponse < Brapi::Model
|
|
7
|
+
attribute :results, type: [Brapi::Models::V2::MacroResult]
|
|
8
|
+
attribute :requested_at, type: :time
|
|
9
|
+
attribute :took, type: :integer
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class MacroSeries < Brapi::Model
|
|
7
|
+
attribute :slug, type: :string
|
|
8
|
+
attribute :name, type: :string
|
|
9
|
+
attribute :description, type: :string
|
|
10
|
+
attribute :unit, type: :string
|
|
11
|
+
attribute :frequency, type: :string
|
|
12
|
+
attribute :category, type: :string
|
|
13
|
+
attribute :start_date, type: :date
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
# Single Tesouro Direto bond as returned by /api/v2/treasury/list and
|
|
7
|
+
# /api/v2/treasury/indicators (both endpoints share the same shape).
|
|
8
|
+
#
|
|
9
|
+
# buyRate / sellRate semantics depend on the bond's indexer — see
|
|
10
|
+
# TreasuryRateInfo#rate_type / #description.
|
|
11
|
+
class TreasuryBond < Brapi::Model
|
|
12
|
+
attribute :symbol, type: :string
|
|
13
|
+
attribute :bond_type, type: :string
|
|
14
|
+
attribute :indexer, type: :string
|
|
15
|
+
attribute :coupon_type, type: :string
|
|
16
|
+
attribute :maturity_date, type: :date
|
|
17
|
+
attribute :duration_days, type: :integer
|
|
18
|
+
attribute :base_date, type: :date
|
|
19
|
+
attribute :buy_rate, type: :float
|
|
20
|
+
attribute :sell_rate, type: :float
|
|
21
|
+
attribute :buy_price, type: :float
|
|
22
|
+
attribute :sell_price, type: :float
|
|
23
|
+
attribute :base_price, type: :float
|
|
24
|
+
attribute :rate_info, type: Brapi::Models::V2::TreasuryRateInfo
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class TreasuryIndicatorsResponse < Brapi::Model
|
|
7
|
+
attribute :results, type: [Brapi::Models::V2::TreasuryBond]
|
|
8
|
+
attribute :requested_at, type: :time
|
|
9
|
+
attribute :took, type: :integer
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class TreasuryListResponse < Brapi::Model
|
|
7
|
+
attribute :results, type: [Brapi::Models::V2::TreasuryBond]
|
|
8
|
+
attribute :pagination, type: Brapi::Models::Pagination
|
|
9
|
+
attribute :requested_at, type: :time
|
|
10
|
+
attribute :took, type: :integer
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
module V2
|
|
6
|
+
class TreasuryRateInfo < Brapi::Model
|
|
7
|
+
attribute :rate_type, type: :string
|
|
8
|
+
attribute :rate_unit, type: :string
|
|
9
|
+
attribute :description, type: :string
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/brapi/resource.rb
CHANGED
|
@@ -14,6 +14,13 @@ module Brapi
|
|
|
14
14
|
client.request(:get, path, params: camelize_keys(params))
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# Brapi endpoints that accept a `symbols` query param take a comma-separated
|
|
18
|
+
# list. Accepts a single String, a single Symbol, or any Enumerable of the
|
|
19
|
+
# two; always returns a String.
|
|
20
|
+
def format_symbols(symbols)
|
|
21
|
+
Array(symbols).join(",")
|
|
22
|
+
end
|
|
23
|
+
|
|
17
24
|
def camelize_keys(params)
|
|
18
25
|
return params if params.nil? || params.empty?
|
|
19
26
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Resources
|
|
5
|
+
class V2
|
|
6
|
+
class Fii < Brapi::Resource
|
|
7
|
+
# GET /api/v2/fii/list
|
|
8
|
+
def list(**params)
|
|
9
|
+
raw = get("/api/v2/fii/list", params: params)
|
|
10
|
+
Brapi::Models::V2::FiiListResponse.from_h(raw)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /api/v2/fii/indicators?symbols=...
|
|
14
|
+
def indicators(symbols, **params)
|
|
15
|
+
raw = get("/api/v2/fii/indicators", params: params.merge(symbols: format_symbols(symbols)))
|
|
16
|
+
Brapi::Models::V2::FiiIndicatorsResponse.from_h(raw)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# GET /api/v2/fii/historical?symbols=...
|
|
20
|
+
def historical(symbols, **params)
|
|
21
|
+
raw = get("/api/v2/fii/historical", params: params.merge(symbols: format_symbols(symbols)))
|
|
22
|
+
Brapi::Models::V2::FiiHistoricalResponse.from_h(raw)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# GET /api/v2/fii/dividends?symbols=...
|
|
26
|
+
def dividends(symbols, **params)
|
|
27
|
+
raw = get("/api/v2/fii/dividends", params: params.merge(symbols: format_symbols(symbols)))
|
|
28
|
+
Brapi::Models::V2::FiiDividendsResponse.from_h(raw)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Resources
|
|
5
|
+
class V2
|
|
6
|
+
class Macro < Brapi::Resource
|
|
7
|
+
# GET /api/v2/macro?symbols=...
|
|
8
|
+
def retrieve(symbols, **params)
|
|
9
|
+
raw = get("/api/v2/macro", params: params.merge(symbols: format_symbols(symbols)))
|
|
10
|
+
Brapi::Models::V2::MacroRetrieveResponse.from_h(raw)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /api/v2/macro/available
|
|
14
|
+
def list_available
|
|
15
|
+
raw = get("/api/v2/macro/available")
|
|
16
|
+
Brapi::Models::V2::MacroListAvailableResponse.from_h(raw)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Resources
|
|
5
|
+
class V2
|
|
6
|
+
class Treasury < Brapi::Resource
|
|
7
|
+
# GET /api/v2/treasury/list
|
|
8
|
+
def list(**params)
|
|
9
|
+
raw = get("/api/v2/treasury/list", params: params)
|
|
10
|
+
Brapi::Models::V2::TreasuryListResponse.from_h(raw)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /api/v2/treasury/indicators?symbols=...
|
|
14
|
+
def indicators(symbols, **params)
|
|
15
|
+
raw = get("/api/v2/treasury/indicators", params: params.merge(symbols: format_symbols(symbols)))
|
|
16
|
+
Brapi::Models::V2::TreasuryIndicatorsResponse.from_h(raw)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/brapi/resources/v2.rb
CHANGED
|
@@ -24,6 +24,18 @@ module Brapi
|
|
|
24
24
|
def prime_rate
|
|
25
25
|
@prime_rate ||= Brapi::Resources::V2::PrimeRate.new(client)
|
|
26
26
|
end
|
|
27
|
+
|
|
28
|
+
def fii
|
|
29
|
+
@fii ||= Brapi::Resources::V2::Fii.new(client)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def macro
|
|
33
|
+
@macro ||= Brapi::Resources::V2::Macro.new(client)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def treasury
|
|
37
|
+
@treasury ||= Brapi::Resources::V2::Treasury.new(client)
|
|
38
|
+
end
|
|
27
39
|
end
|
|
28
40
|
end
|
|
29
41
|
end
|
data/lib/brapi/version.rb
CHANGED
data/lib/brapi.rb
CHANGED
|
@@ -42,6 +42,27 @@ require "brapi/models/v2/prime_rate_entry"
|
|
|
42
42
|
require "brapi/models/v2/prime_rate_retrieve_response"
|
|
43
43
|
require "brapi/models/v2/prime_rate_list_available_response"
|
|
44
44
|
|
|
45
|
+
require "brapi/models/pagination"
|
|
46
|
+
|
|
47
|
+
require "brapi/models/v2/fii"
|
|
48
|
+
require "brapi/models/v2/fii_dividend"
|
|
49
|
+
require "brapi/models/v2/fii_history"
|
|
50
|
+
require "brapi/models/v2/fii_list_response"
|
|
51
|
+
require "brapi/models/v2/fii_indicators_response"
|
|
52
|
+
require "brapi/models/v2/fii_historical_response"
|
|
53
|
+
require "brapi/models/v2/fii_dividends_response"
|
|
54
|
+
|
|
55
|
+
require "brapi/models/v2/macro_series"
|
|
56
|
+
require "brapi/models/v2/macro_observation"
|
|
57
|
+
require "brapi/models/v2/macro_result"
|
|
58
|
+
require "brapi/models/v2/macro_retrieve_response"
|
|
59
|
+
require "brapi/models/v2/macro_list_available_response"
|
|
60
|
+
|
|
61
|
+
require "brapi/models/v2/treasury_rate_info"
|
|
62
|
+
require "brapi/models/v2/treasury_bond"
|
|
63
|
+
require "brapi/models/v2/treasury_list_response"
|
|
64
|
+
require "brapi/models/v2/treasury_indicators_response"
|
|
65
|
+
|
|
45
66
|
# Resources — v2 (parent class) must load before its nested classes
|
|
46
67
|
require "brapi/resources/quote"
|
|
47
68
|
require "brapi/resources/available"
|
|
@@ -50,6 +71,9 @@ require "brapi/resources/v2/crypto"
|
|
|
50
71
|
require "brapi/resources/v2/currency"
|
|
51
72
|
require "brapi/resources/v2/inflation"
|
|
52
73
|
require "brapi/resources/v2/prime_rate"
|
|
74
|
+
require "brapi/resources/v2/fii"
|
|
75
|
+
require "brapi/resources/v2/macro"
|
|
76
|
+
require "brapi/resources/v2/treasury"
|
|
53
77
|
|
|
54
78
|
require "brapi/client"
|
|
55
79
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: brapi-ruby-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rômulo Storel
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-05-
|
|
10
|
+
date: 2026-05-29 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: faraday
|
|
@@ -63,6 +63,7 @@ files:
|
|
|
63
63
|
- lib/brapi/models/historical_data_price.rb
|
|
64
64
|
- lib/brapi/models/income_statement_entry.rb
|
|
65
65
|
- lib/brapi/models/key_statistics_entry.rb
|
|
66
|
+
- lib/brapi/models/pagination.rb
|
|
66
67
|
- lib/brapi/models/quote.rb
|
|
67
68
|
- lib/brapi/models/quote_list_item.rb
|
|
68
69
|
- lib/brapi/models/quote_list_response.rb
|
|
@@ -76,12 +77,28 @@ files:
|
|
|
76
77
|
- lib/brapi/models/v2/currency.rb
|
|
77
78
|
- lib/brapi/models/v2/currency_list_available_response.rb
|
|
78
79
|
- lib/brapi/models/v2/currency_retrieve_response.rb
|
|
80
|
+
- lib/brapi/models/v2/fii.rb
|
|
81
|
+
- lib/brapi/models/v2/fii_dividend.rb
|
|
82
|
+
- lib/brapi/models/v2/fii_dividends_response.rb
|
|
83
|
+
- lib/brapi/models/v2/fii_historical_response.rb
|
|
84
|
+
- lib/brapi/models/v2/fii_history.rb
|
|
85
|
+
- lib/brapi/models/v2/fii_indicators_response.rb
|
|
86
|
+
- lib/brapi/models/v2/fii_list_response.rb
|
|
79
87
|
- lib/brapi/models/v2/inflation_entry.rb
|
|
80
88
|
- lib/brapi/models/v2/inflation_list_available_response.rb
|
|
81
89
|
- lib/brapi/models/v2/inflation_retrieve_response.rb
|
|
90
|
+
- lib/brapi/models/v2/macro_list_available_response.rb
|
|
91
|
+
- lib/brapi/models/v2/macro_observation.rb
|
|
92
|
+
- lib/brapi/models/v2/macro_result.rb
|
|
93
|
+
- lib/brapi/models/v2/macro_retrieve_response.rb
|
|
94
|
+
- lib/brapi/models/v2/macro_series.rb
|
|
82
95
|
- lib/brapi/models/v2/prime_rate_entry.rb
|
|
83
96
|
- lib/brapi/models/v2/prime_rate_list_available_response.rb
|
|
84
97
|
- lib/brapi/models/v2/prime_rate_retrieve_response.rb
|
|
98
|
+
- lib/brapi/models/v2/treasury_bond.rb
|
|
99
|
+
- lib/brapi/models/v2/treasury_indicators_response.rb
|
|
100
|
+
- lib/brapi/models/v2/treasury_list_response.rb
|
|
101
|
+
- lib/brapi/models/v2/treasury_rate_info.rb
|
|
85
102
|
- lib/brapi/models/value_added_entry.rb
|
|
86
103
|
- lib/brapi/resource.rb
|
|
87
104
|
- lib/brapi/resources/available.rb
|
|
@@ -89,8 +106,11 @@ files:
|
|
|
89
106
|
- lib/brapi/resources/v2.rb
|
|
90
107
|
- lib/brapi/resources/v2/crypto.rb
|
|
91
108
|
- lib/brapi/resources/v2/currency.rb
|
|
109
|
+
- lib/brapi/resources/v2/fii.rb
|
|
92
110
|
- lib/brapi/resources/v2/inflation.rb
|
|
111
|
+
- lib/brapi/resources/v2/macro.rb
|
|
93
112
|
- lib/brapi/resources/v2/prime_rate.rb
|
|
113
|
+
- lib/brapi/resources/v2/treasury.rb
|
|
94
114
|
- lib/brapi/version.rb
|
|
95
115
|
homepage: https://github.com/romulostorel/brapi-ruby-sdk
|
|
96
116
|
licenses:
|