brapi-ruby-sdk 0.1.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 +80 -0
- data/README.md +70 -8
- data/lib/brapi/model.rb +1 -0
- data/lib/brapi/models/balance_sheet_entry.rb +16 -4
- data/lib/brapi/models/cash_dividend.rb +17 -0
- data/lib/brapi/models/cashflow_entry.rb +25 -0
- data/lib/brapi/models/dividends_data.rb +11 -0
- data/lib/brapi/models/financial_data_entry.rb +20 -14
- data/lib/brapi/models/historical_data_price.rb +15 -0
- data/lib/brapi/models/income_statement_entry.rb +61 -0
- data/lib/brapi/models/key_statistics_entry.rb +68 -0
- data/lib/brapi/models/pagination.rb +15 -0
- data/lib/brapi/models/quote.rb +20 -15
- data/lib/brapi/models/stock_dividend.rb +16 -0
- data/lib/brapi/models/subscription.rb +22 -0
- data/lib/brapi/models/summary_profile.rb +48 -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/models/value_added_entry.rb +69 -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 +36 -1
- metadata +32 -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,86 @@ 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
|
+
|
|
43
|
+
## [0.2.0] - 2026-05-28
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- Typed models for every fundamental module that `client.quote.retrieve(...)`
|
|
48
|
+
can return when `modules:` is passed:
|
|
49
|
+
- `Brapi::Models::SummaryProfile` — company profile (industry, sector,
|
|
50
|
+
website, CNPJ, business summary, employees, administrator fields).
|
|
51
|
+
- `Brapi::Models::KeyStatisticsEntry` — `defaultKeyStatistics` (TTM, single
|
|
52
|
+
object) and `defaultKeyStatisticsHistory*` (annual + quarterly arrays),
|
|
53
|
+
including special JSON keys like `52WeekChange` / `SandP52WeekChange`.
|
|
54
|
+
- `Brapi::Models::IncomeStatementEntry` — DRE entries (annual + quarterly).
|
|
55
|
+
- `Brapi::Models::CashflowEntry` — DFC entries (annual + quarterly).
|
|
56
|
+
- `Brapi::Models::ValueAddedEntry` — DVA entries (annual + quarterly).
|
|
57
|
+
- `Brapi::Models::HistoricalDataPrice` for `historical_data_price` entries
|
|
58
|
+
plus the surrounding `used_interval` / `used_range` / `valid_intervals` /
|
|
59
|
+
`valid_ranges` Quote-level fields returned when `range`/`interval` are set.
|
|
60
|
+
- `Brapi::Models::DividendsData` (returned when `dividends=true`) wrapping
|
|
61
|
+
three typed sub-models: `CashDividend`, `StockDividend`, `Subscription`.
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- `Brapi::Models::Quote#summary_profile`, `#default_key_statistics`,
|
|
66
|
+
`#income_statement_history` (and quarterly), `#cashflow_history` (and
|
|
67
|
+
quarterly), `#value_added_history` (and quarterly) and `#dividends_data`
|
|
68
|
+
now return typed `Brapi::Models::*` instances instead of raw Hashes /
|
|
69
|
+
Arrays. Callers that were treating these as Hashes need to switch to
|
|
70
|
+
attribute access (`quote.summary_profile.industry` instead of
|
|
71
|
+
`quote.summary_profile["industry"]`); `Model#raw` still exposes the
|
|
72
|
+
original payload when needed.
|
|
73
|
+
- `Brapi::Models::Quote#historical_data_price` (returned when `range`/
|
|
74
|
+
`interval` is passed) now resolves to `[Brapi::Models::HistoricalDataPrice]`
|
|
75
|
+
with typed `open`/`high`/`low`/`close`/`volume`/`adjusted_close` attributes
|
|
76
|
+
instead of an Array of Hashes. Code building charts off this attribute
|
|
77
|
+
needs to switch from `entry["close"]` to `entry.close`.
|
|
78
|
+
- `Brapi::Models::BalanceSheetEntry` — fixed JSON-key mismatches for
|
|
79
|
+
`goodwill` (was looking up `goodwill`, API returns `goodWill`),
|
|
80
|
+
`other_current_liabilities` (`otherCurrentLiab`), `other_liabilities`
|
|
81
|
+
(`otherLiab`) and `total_liabilities` (`totalLiab`); added `type`,
|
|
82
|
+
`minority_interest`, `capital_surplus`. Pre-existing v0.1.0 callers that
|
|
83
|
+
read these four fields will now see actual values (they returned `nil`
|
|
84
|
+
before).
|
|
85
|
+
- `Brapi::Models::FinancialDataEntry` — adds `type`, `current_price`,
|
|
86
|
+
`earnings_growth_annual` and `revenue_growth_annual` so it can model
|
|
87
|
+
`financialDataHistory[*]` (annual + quarterly) in addition to the TTM
|
|
88
|
+
`financialData` object.
|
|
89
|
+
|
|
10
90
|
## [0.1.0] - 2026-05-28
|
|
11
91
|
|
|
12
92
|
### Added
|
data/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# brapi-ruby-sdk
|
|
2
2
|
|
|
3
|
+
[](https://github.com/romulostorel/brapi-ruby-sdk/actions/workflows/ci.yml)
|
|
4
|
+
[](https://rubygems.org/gems/brapi-ruby-sdk)
|
|
5
|
+
[](https://rubygems.org/gems/brapi-ruby-sdk)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.ruby-lang.org/)
|
|
8
|
+
|
|
3
9
|
Ruby SDK for the [brapi.dev](https://brapi.dev) API — Brazilian stock market quotes, cryptocurrencies, currency exchange rates, inflation (IPCA) and prime rate (SELIC) data.
|
|
4
10
|
|
|
5
11
|
This SDK provides parity with the official [brapi TypeScript](https://github.com/brapi-dev/brapi-typescript) and [brapi Python](https://github.com/brapi-dev/brapi-python) SDKs, covering 11 endpoints in v0.1.
|
|
@@ -87,6 +93,14 @@ client.quote.retrieve("PETR4")
|
|
|
87
93
|
| `client.v2.inflation.list_available` | `GET /api/v2/inflation/available` | Countries with inflation data |
|
|
88
94
|
| `client.v2.prime_rate.retrieve(...)` | `GET /api/v2/prime-rate` | SELIC / prime-rate series |
|
|
89
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 |
|
|
90
104
|
|
|
91
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`).
|
|
92
106
|
|
|
@@ -110,8 +124,14 @@ quote.regular_market_change_percent # => -0.95
|
|
|
110
124
|
quote.market_cap # => 483937892568
|
|
111
125
|
quote.fifty_two_week_range # => "28.86 - 38.66"
|
|
112
126
|
quote.financial_data # => Brapi::Models::FinancialDataEntry
|
|
113
|
-
quote.summary_profile # =>
|
|
114
|
-
quote.
|
|
127
|
+
quote.summary_profile # => Brapi::Models::SummaryProfile
|
|
128
|
+
quote.summary_profile.industry # => "Petróleo e Gás Integrado"
|
|
129
|
+
quote.default_key_statistics # => Brapi::Models::KeyStatisticsEntry
|
|
130
|
+
quote.income_statement_history # => [Brapi::Models::IncomeStatementEntry]
|
|
131
|
+
quote.cashflow_history # => [Brapi::Models::CashflowEntry]
|
|
132
|
+
quote.value_added_history # => [Brapi::Models::ValueAddedEntry]
|
|
133
|
+
quote.historical_data_price # => [Brapi::Models::HistoricalDataPrice]
|
|
134
|
+
quote.dividends_data # => Brapi::Models::DividendsData (cash + stock + subscriptions)
|
|
115
135
|
```
|
|
116
136
|
|
|
117
137
|
### Multi-ticker
|
|
@@ -149,6 +169,49 @@ resp = Brapi.v2.prime_rate.retrieve(country: "brazil")
|
|
|
149
169
|
resp.prime_rate.each { |p| puts "#{p.date}: #{p.value}% p.a." }
|
|
150
170
|
```
|
|
151
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
|
+
|
|
152
215
|
### List/filter stocks
|
|
153
216
|
|
|
154
217
|
```ruby
|
|
@@ -195,13 +258,12 @@ The SDK automatically retries transient 5xx errors (502/503/504) up to twice wit
|
|
|
195
258
|
|
|
196
259
|
## Roadmap
|
|
197
260
|
|
|
198
|
-
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:
|
|
199
264
|
|
|
200
|
-
- `client.
|
|
201
|
-
- `client.
|
|
202
|
-
- `client.options.*` — Options chain & history
|
|
203
|
-
- `client.treasury.*` — Tesouro Direto
|
|
204
|
-
- `client.futures.*` — Futures contracts
|
|
265
|
+
- `client.v2.options.*` — Options chain & history
|
|
266
|
+
- `client.v2.futures.*` — Futures contracts
|
|
205
267
|
|
|
206
268
|
## Development
|
|
207
269
|
|
data/lib/brapi/model.rb
CHANGED
|
@@ -2,33 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
module Brapi
|
|
4
4
|
module Models
|
|
5
|
+
# Common fields of `balanceSheetHistory[*]` (annual) and
|
|
6
|
+
# `balanceSheetHistoryQuarterly[*]`. The full brapi payload exposes ~120
|
|
7
|
+
# accounting-specific fields (Brazilian GAAP + segment-specific rows);
|
|
8
|
+
# the SDK ships the most-used ones typed and keeps the rest available
|
|
9
|
+
# through Model#raw.
|
|
5
10
|
class BalanceSheetEntry < Brapi::Model
|
|
11
|
+
attribute :type, type: :string
|
|
6
12
|
attribute :end_date, type: :string
|
|
13
|
+
|
|
7
14
|
attribute :cash
|
|
8
15
|
attribute :short_term_investments
|
|
9
16
|
attribute :net_receivables
|
|
10
17
|
attribute :inventory
|
|
11
18
|
attribute :other_current_assets
|
|
12
19
|
attribute :total_current_assets
|
|
20
|
+
|
|
13
21
|
attribute :long_term_investments
|
|
14
22
|
attribute :property_plant_equipment
|
|
15
|
-
attribute :goodwill
|
|
23
|
+
attribute :goodwill, json_key: "goodWill"
|
|
16
24
|
attribute :intangible_assets
|
|
17
25
|
attribute :other_assets
|
|
18
26
|
attribute :total_assets
|
|
27
|
+
|
|
19
28
|
attribute :accounts_payable
|
|
20
29
|
attribute :short_long_term_debt
|
|
21
|
-
attribute :other_current_liabilities
|
|
30
|
+
attribute :other_current_liabilities, json_key: "otherCurrentLiab"
|
|
22
31
|
attribute :total_current_liabilities
|
|
23
32
|
attribute :long_term_debt
|
|
24
|
-
attribute :other_liabilities
|
|
25
|
-
attribute :total_liabilities
|
|
33
|
+
attribute :other_liabilities, json_key: "otherLiab"
|
|
34
|
+
attribute :total_liabilities, json_key: "totalLiab"
|
|
35
|
+
|
|
26
36
|
attribute :common_stock
|
|
27
37
|
attribute :retained_earnings
|
|
28
38
|
attribute :treasury_stock
|
|
29
39
|
attribute :other_stockholder_equity
|
|
30
40
|
attribute :total_stockholder_equity
|
|
31
41
|
attribute :net_tangible_assets
|
|
42
|
+
attribute :minority_interest
|
|
43
|
+
attribute :capital_surplus
|
|
32
44
|
end
|
|
33
45
|
end
|
|
34
46
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
class CashDividend < Brapi::Model
|
|
6
|
+
attribute :asset_issued, type: :string
|
|
7
|
+
attribute :payment_date, type: :time
|
|
8
|
+
attribute :rate, type: :float
|
|
9
|
+
attribute :related_to, type: :string
|
|
10
|
+
attribute :approved_on, type: :time
|
|
11
|
+
attribute :isin_code, type: :string
|
|
12
|
+
attribute :label, type: :string
|
|
13
|
+
attribute :last_date_prior, type: :time
|
|
14
|
+
attribute :remarks, type: :string
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
class CashflowEntry < Brapi::Model
|
|
6
|
+
attribute :type, type: :string
|
|
7
|
+
attribute :end_date, type: :string
|
|
8
|
+
attribute :operating_cash_flow
|
|
9
|
+
attribute :income_from_operations
|
|
10
|
+
attribute :net_income_before_taxes
|
|
11
|
+
attribute :adjustments_to_profit_or_loss
|
|
12
|
+
attribute :changes_in_assets_and_liabilities
|
|
13
|
+
attribute :other_operating_activities
|
|
14
|
+
attribute :cash_generated_in_operations
|
|
15
|
+
attribute :investment_cash_flow
|
|
16
|
+
attribute :financing_cash_flow
|
|
17
|
+
attribute :exchange_variation_without_cash
|
|
18
|
+
attribute :foreign_exchange_rate_without_cash
|
|
19
|
+
attribute :increase_or_decrease_in_cash
|
|
20
|
+
attribute :initial_cash_balance
|
|
21
|
+
attribute :final_cash_balance
|
|
22
|
+
attribute :free_cash_flow
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
class DividendsData < Brapi::Model
|
|
6
|
+
attribute :cash_dividends, type: [Brapi::Models::CashDividend]
|
|
7
|
+
attribute :stock_dividends, type: [Brapi::Models::StockDividend]
|
|
8
|
+
attribute :subscriptions, type: [Brapi::Models::Subscription]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -2,29 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
module Brapi
|
|
4
4
|
module Models
|
|
5
|
+
# Backs both `financialData` (single TTM object, no type/end_date)
|
|
6
|
+
# and `financialDataHistory[*]` (annual/quarterly array entries).
|
|
5
7
|
class FinancialDataEntry < Brapi::Model
|
|
8
|
+
attribute :type, type: :string
|
|
6
9
|
attribute :end_date, type: :string
|
|
10
|
+
attribute :current_price, type: :float
|
|
7
11
|
attribute :total_revenue
|
|
8
|
-
attribute :revenue_per_share
|
|
12
|
+
attribute :revenue_per_share, type: :float
|
|
9
13
|
attribute :gross_profits
|
|
10
14
|
attribute :ebitda
|
|
11
15
|
attribute :operating_cashflow
|
|
12
16
|
attribute :free_cashflow
|
|
13
17
|
attribute :total_cash
|
|
14
|
-
attribute :total_cash_per_share
|
|
18
|
+
attribute :total_cash_per_share, type: :float
|
|
15
19
|
attribute :total_debt
|
|
16
|
-
attribute :debt_to_equity
|
|
17
|
-
attribute :current_ratio
|
|
18
|
-
attribute :quick_ratio
|
|
19
|
-
attribute :return_on_assets
|
|
20
|
-
attribute :return_on_equity
|
|
21
|
-
attribute :gross_margins
|
|
22
|
-
attribute :ebitda_margins
|
|
23
|
-
attribute :operating_margins
|
|
24
|
-
attribute :profit_margins
|
|
25
|
-
attribute :earnings_growth
|
|
26
|
-
attribute :revenue_growth
|
|
27
|
-
attribute :
|
|
20
|
+
attribute :debt_to_equity, type: :float
|
|
21
|
+
attribute :current_ratio, type: :float
|
|
22
|
+
attribute :quick_ratio, type: :float
|
|
23
|
+
attribute :return_on_assets, type: :float
|
|
24
|
+
attribute :return_on_equity, type: :float
|
|
25
|
+
attribute :gross_margins, type: :float
|
|
26
|
+
attribute :ebitda_margins, type: :float
|
|
27
|
+
attribute :operating_margins, type: :float
|
|
28
|
+
attribute :profit_margins, type: :float
|
|
29
|
+
attribute :earnings_growth, type: :float
|
|
30
|
+
attribute :revenue_growth, type: :float
|
|
31
|
+
attribute :earnings_growth_annual, type: :float
|
|
32
|
+
attribute :revenue_growth_annual, type: :float
|
|
33
|
+
attribute :financial_currency, type: :string
|
|
28
34
|
end
|
|
29
35
|
end
|
|
30
36
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
class HistoricalDataPrice < Brapi::Model
|
|
6
|
+
attribute :date, type: :integer
|
|
7
|
+
attribute :open, type: :float
|
|
8
|
+
attribute :high, type: :float
|
|
9
|
+
attribute :low, type: :float
|
|
10
|
+
attribute :close, type: :float
|
|
11
|
+
attribute :volume, type: :integer
|
|
12
|
+
attribute :adjusted_close, type: :float
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
class IncomeStatementEntry < Brapi::Model
|
|
6
|
+
attribute :type, type: :string
|
|
7
|
+
attribute :end_date, type: :string
|
|
8
|
+
attribute :total_revenue
|
|
9
|
+
attribute :cost_of_revenue
|
|
10
|
+
attribute :gross_profit
|
|
11
|
+
attribute :research_development
|
|
12
|
+
attribute :selling_general_administrative
|
|
13
|
+
attribute :non_recurring
|
|
14
|
+
attribute :other_operating_expenses
|
|
15
|
+
attribute :total_operating_expenses
|
|
16
|
+
attribute :operating_income
|
|
17
|
+
attribute :total_other_income_expense_net
|
|
18
|
+
attribute :ebit
|
|
19
|
+
attribute :interest_expense
|
|
20
|
+
attribute :income_before_tax
|
|
21
|
+
attribute :income_tax_expense
|
|
22
|
+
attribute :minority_interest
|
|
23
|
+
attribute :net_income_from_continuing_ops
|
|
24
|
+
attribute :discontinued_operations
|
|
25
|
+
attribute :extraordinary_items
|
|
26
|
+
attribute :effect_of_accounting_charges
|
|
27
|
+
attribute :other_items
|
|
28
|
+
attribute :net_income
|
|
29
|
+
attribute :net_income_applicable_to_common_shares
|
|
30
|
+
attribute :sales_expenses
|
|
31
|
+
attribute :losses_due_to_non_recoverability_of_assets
|
|
32
|
+
attribute :other_operating_income
|
|
33
|
+
attribute :equity_income_result
|
|
34
|
+
attribute :financial_result
|
|
35
|
+
attribute :financial_income
|
|
36
|
+
attribute :financial_expenses
|
|
37
|
+
attribute :current_taxes
|
|
38
|
+
attribute :deferred_taxes
|
|
39
|
+
attribute :income_before_statutory_participations_and_contributions
|
|
40
|
+
attribute :basic_earnings_per_common_share, type: :float
|
|
41
|
+
attribute :diluted_earnings_per_common_share, type: :float
|
|
42
|
+
attribute :basic_earnings_per_preferred_share, type: :float
|
|
43
|
+
attribute :profit_sharing_and_statutory_contributions
|
|
44
|
+
attribute :diluted_earnings_per_preferred_share, type: :float
|
|
45
|
+
attribute :claims_and_operations_costs
|
|
46
|
+
attribute :administrative_costs
|
|
47
|
+
attribute :other_operating_income_and_expenses
|
|
48
|
+
attribute :earnings_per_share, type: :float
|
|
49
|
+
attribute :basic_earnings_per_share, type: :float
|
|
50
|
+
attribute :diluted_earnings_per_share, type: :float
|
|
51
|
+
attribute :insurance_operations
|
|
52
|
+
attribute :reinsurance_operations
|
|
53
|
+
attribute :complementary_pension_operations
|
|
54
|
+
attribute :capitalization_operations
|
|
55
|
+
attribute :clean_ebit
|
|
56
|
+
attribute :clean_ebitda
|
|
57
|
+
attribute :clean_nopat
|
|
58
|
+
attribute :clean_net_income
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
# Used for both `defaultKeyStatistics` (single TTM object, no type/end_date)
|
|
6
|
+
# and `defaultKeyStatisticsHistory[*]` (array of annual entries) and the
|
|
7
|
+
# quarterly variant. Fields not present in a given payload come back nil.
|
|
8
|
+
class KeyStatisticsEntry < Brapi::Model
|
|
9
|
+
attribute :type, type: :string
|
|
10
|
+
attribute :end_date, type: :string
|
|
11
|
+
attribute :price_hint
|
|
12
|
+
attribute :price
|
|
13
|
+
attribute :enterprise_value
|
|
14
|
+
attribute :forward_pe, type: :float, json_key: "forwardPE"
|
|
15
|
+
attribute :profit_margins, type: :float
|
|
16
|
+
attribute :float_shares
|
|
17
|
+
attribute :shares_outstanding
|
|
18
|
+
attribute :shares_short
|
|
19
|
+
attribute :shares_short_prior_month
|
|
20
|
+
attribute :shares_short_previous_month_date
|
|
21
|
+
attribute :date_short_interest
|
|
22
|
+
attribute :shares_percent_shares_out, type: :float
|
|
23
|
+
attribute :held_percent_insiders, type: :float
|
|
24
|
+
attribute :held_percent_institutions, type: :float
|
|
25
|
+
attribute :short_ratio, type: :float
|
|
26
|
+
attribute :short_percent_of_float, type: :float
|
|
27
|
+
attribute :beta, type: :float
|
|
28
|
+
attribute :implied_shares_outstanding
|
|
29
|
+
attribute :category, type: :string
|
|
30
|
+
attribute :book_value, type: :float
|
|
31
|
+
attribute :price_to_book, type: :float
|
|
32
|
+
attribute :fund_family, type: :string
|
|
33
|
+
attribute :legal_type, type: :string
|
|
34
|
+
attribute :last_fiscal_year_end
|
|
35
|
+
attribute :next_fiscal_year_end
|
|
36
|
+
attribute :most_recent_quarter
|
|
37
|
+
attribute :earnings_quarterly_growth, type: :float
|
|
38
|
+
attribute :net_income_to_common
|
|
39
|
+
attribute :trailing_eps, type: :float
|
|
40
|
+
attribute :forward_eps, type: :float
|
|
41
|
+
attribute :peg_ratio, type: :float
|
|
42
|
+
attribute :last_split_factor, type: :string
|
|
43
|
+
attribute :last_split_date
|
|
44
|
+
attribute :enterprise_to_revenue, type: :float
|
|
45
|
+
attribute :enterprise_to_ebitda, type: :float
|
|
46
|
+
attribute :fifty_two_week_change, type: :float, json_key: "52WeekChange"
|
|
47
|
+
attribute :sandp_fifty_two_week_change, type: :float, json_key: "SandP52WeekChange"
|
|
48
|
+
attribute :last_dividend_value, type: :float
|
|
49
|
+
attribute :last_dividend_date
|
|
50
|
+
attribute :ytd_return, type: :float
|
|
51
|
+
attribute :beta3_year, type: :float
|
|
52
|
+
attribute :total_assets
|
|
53
|
+
attribute :yield, type: :float
|
|
54
|
+
attribute :fund_inception_date
|
|
55
|
+
attribute :three_year_average_return, type: :float
|
|
56
|
+
attribute :five_year_average_return, type: :float
|
|
57
|
+
attribute :morning_star_overall_rating
|
|
58
|
+
attribute :morning_star_risk_rating
|
|
59
|
+
attribute :annual_report_expense_ratio, type: :float
|
|
60
|
+
attribute :last_cap_gain, type: :float
|
|
61
|
+
attribute :annual_holdings_turnover, type: :float
|
|
62
|
+
attribute :market_cap
|
|
63
|
+
attribute :trailing_pe, type: :float, json_key: "trailingPE"
|
|
64
|
+
attribute :earnings_per_share, type: :float
|
|
65
|
+
attribute :dividend_yield, type: :float
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -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
|
data/lib/brapi/models/quote.rb
CHANGED
|
@@ -34,27 +34,32 @@ module Brapi
|
|
|
34
34
|
attribute :earnings_per_share, type: :float
|
|
35
35
|
attribute :logourl, type: :string
|
|
36
36
|
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
attribute :summary_profile
|
|
37
|
+
# Fundamental module slots (typed)
|
|
38
|
+
attribute :summary_profile, type: Brapi::Models::SummaryProfile
|
|
40
39
|
attribute :balance_sheet_history, type: [Brapi::Models::BalanceSheetEntry]
|
|
41
40
|
attribute :balance_sheet_history_quarterly, type: [Brapi::Models::BalanceSheetEntry]
|
|
42
|
-
attribute :default_key_statistics
|
|
43
|
-
attribute :default_key_statistics_history
|
|
44
|
-
attribute :default_key_statistics_history_quarterly
|
|
45
|
-
attribute :income_statement_history
|
|
46
|
-
attribute :income_statement_history_quarterly
|
|
41
|
+
attribute :default_key_statistics, type: Brapi::Models::KeyStatisticsEntry
|
|
42
|
+
attribute :default_key_statistics_history, type: [Brapi::Models::KeyStatisticsEntry]
|
|
43
|
+
attribute :default_key_statistics_history_quarterly, type: [Brapi::Models::KeyStatisticsEntry]
|
|
44
|
+
attribute :income_statement_history, type: [Brapi::Models::IncomeStatementEntry]
|
|
45
|
+
attribute :income_statement_history_quarterly, type: [Brapi::Models::IncomeStatementEntry]
|
|
47
46
|
attribute :financial_data, type: Brapi::Models::FinancialDataEntry
|
|
48
47
|
attribute :financial_data_history, type: [Brapi::Models::FinancialDataEntry]
|
|
49
48
|
attribute :financial_data_history_quarterly, type: [Brapi::Models::FinancialDataEntry]
|
|
50
|
-
attribute :value_added_history
|
|
51
|
-
attribute :value_added_history_quarterly
|
|
52
|
-
attribute :cashflow_history
|
|
53
|
-
attribute :cashflow_history_quarterly
|
|
49
|
+
attribute :value_added_history, type: [Brapi::Models::ValueAddedEntry]
|
|
50
|
+
attribute :value_added_history_quarterly, type: [Brapi::Models::ValueAddedEntry]
|
|
51
|
+
attribute :cashflow_history, type: [Brapi::Models::CashflowEntry]
|
|
52
|
+
attribute :cashflow_history_quarterly, type: [Brapi::Models::CashflowEntry]
|
|
54
53
|
|
|
55
|
-
# Historical price data when `range`/`interval` are passed.
|
|
56
|
-
attribute :
|
|
57
|
-
attribute :
|
|
54
|
+
# Historical price data — returned when `range`/`interval` are passed.
|
|
55
|
+
attribute :used_interval, type: :string
|
|
56
|
+
attribute :used_range, type: :string
|
|
57
|
+
attribute :valid_intervals
|
|
58
|
+
attribute :valid_ranges
|
|
59
|
+
attribute :historical_data_price, type: [Brapi::Models::HistoricalDataPrice]
|
|
60
|
+
|
|
61
|
+
# Dividends — returned when `dividends=true`.
|
|
62
|
+
attribute :dividends_data, type: Brapi::Models::DividendsData
|
|
58
63
|
end
|
|
59
64
|
end
|
|
60
65
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
class StockDividend < Brapi::Model
|
|
6
|
+
attribute :asset_issued, type: :string
|
|
7
|
+
attribute :factor, type: :float
|
|
8
|
+
attribute :complete_factor, type: :string
|
|
9
|
+
attribute :approved_on, type: :time
|
|
10
|
+
attribute :isin_code, type: :string
|
|
11
|
+
attribute :label, type: :string
|
|
12
|
+
attribute :last_date_prior, type: :time
|
|
13
|
+
attribute :remarks, type: :string
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Brapi
|
|
4
|
+
module Models
|
|
5
|
+
# NOTE: field list is inferred from CashDividend / StockDividend shape — the
|
|
6
|
+
# brapi `subscriptions` payload captured during v0.2 development was empty.
|
|
7
|
+
# If the live API returns different keys, attribute readers will return nil
|
|
8
|
+
# silently; `Model#raw` still exposes the original Hash. Update fields once
|
|
9
|
+
# a real payload is observed.
|
|
10
|
+
class Subscription < Brapi::Model
|
|
11
|
+
attribute :asset_issued, type: :string
|
|
12
|
+
attribute :factor, type: :float
|
|
13
|
+
attribute :price_unit, type: :float
|
|
14
|
+
attribute :approved_on, type: :time
|
|
15
|
+
attribute :isin_code, type: :string
|
|
16
|
+
attribute :label, type: :string
|
|
17
|
+
attribute :last_date_prior, type: :time
|
|
18
|
+
attribute :subscription_date, type: :time
|
|
19
|
+
attribute :remarks, type: :string
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|