finbrain-python 0.2.7__tar.gz → 0.2.8__tar.gz
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.
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/CHANGELOG.md +18 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/PKG-INFO +36 -11
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/README.md +35 -10
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/house_trades.py +16 -5
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/screener.py +9 -4
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/senate_trades.py +16 -5
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/house_trades.py +29 -10
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/screener.py +9 -4
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/senate_trades.py +28 -10
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/PKG-INFO +36 -11
- finbrain_python-0.2.8/src/finbrain_python.egg-info/scm_version.json +8 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_house_trades.py +26 -3
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_integration.py +26 -6
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_screener.py +18 -6
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_senate_trades.py +25 -4
- finbrain_python-0.2.7/src/finbrain_python.egg-info/scm_version.json +0 -8
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/.gitattributes +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/.github/workflows/ci.yml +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/.github/workflows/release.yml +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/.gitignore +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/LICENSE +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/RELEASE.md +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/examples/async_example.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/examples/transactions_plotting_example.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/pyproject.toml +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/setup.cfg +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/__init__.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/__init__.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/client.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/__init__.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/_utils.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/analyst_ratings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/app_ratings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/available.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/corporate_lobbying.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/government_contracts.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/insider_transactions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/linkedin_data.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/news.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/options.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/patent_filings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/predictions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/recent.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/reddit_mentions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/sentiments.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/client.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/__init__.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/_utils.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/analyst_ratings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/app_ratings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/available.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/corporate_lobbying.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/government_contracts.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/insider_transactions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/linkedin_data.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/news.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/options.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/patent_filings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/predictions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/recent.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/reddit_mentions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/sentiments.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/exceptions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/plotting.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/py.typed +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/SOURCES.txt +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/dependency_links.txt +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/requires.txt +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/scm_file_list.json +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/top_level.txt +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/__init__.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/conftest.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_analyst_ratings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_app_ratings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_async_client.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_available.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_client.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_corporate_lobbying.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_envelope.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_government_contracts.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_insider_transactions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_linkedin_data.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_news.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_options.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_patent_filings.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_plotting.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_predictions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_recent.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_reddit_mentions.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_sentiments.py +0 -0
- {finbrain_python-0.2.7 → finbrain_python-0.2.8}/tests/test_utils.py +0 -0
|
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.8] - 2026-07-28
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Congressional account owner**: House and Senate trade rows now carry `owner` — the beneficial owner of the traded account: `SELF`, `SP` (spouse), `DC` (dependent child), `JT` (joint), or an account code. Senate filings that leave the owner column blank report `UNKNOWN`; House filings that leave it blank report `SELF`, per the House PTR-form instructions. Available on `fb.house_trades.ticker()`, `fb.senate_trades.ticker()`, their async equivalents, and the `fb.screener.congress_house()` / `fb.screener.congress_senate()` rows
|
|
13
|
+
- **Congressional amount normalization metadata**: ticker-level trade rows also carry `amountRaw` and `amountFlag`. `amount` is now normalized to the ten statutory STOCK Act brackets whenever the filed string is an unambiguous formatting variant of one (open-ended categories like `Over $1,000,000` are kept as filed); on normalized rows `amountRaw` preserves the string as originally filed. When the filed amount could not be safely normalized, `amount` keeps the raw filed string (or `Unknown` when the filing had no usable amount) and `amountFlag` is `review` or `ambiguous`; on all other rows both fields are `null`
|
|
14
|
+
- **Documentation**: README "Congressional trade fields" section covering the new fields, and expanded docstrings on the sync/async ticker and screener methods
|
|
15
|
+
- **Tests**: Unit tests assert the new fields pass through in both the raw-dict and DataFrame branches, including the null cases; integration tests assert the keys are present on live responses
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **DataFrame shape**: `fb.house_trades.ticker(..., as_dataframe=True)` and `fb.senate_trades.ticker(..., as_dataframe=True)` gain `owner`, `amountRaw` and `amountFlag` columns; the congress screener frames gain an `owner` column. Code that asserts an exact column set (`set(df.columns) == {...}`) or compares frames for equality needs updating
|
|
20
|
+
|
|
21
|
+
### Notes
|
|
22
|
+
|
|
23
|
+
- `owner` is `null` on rows collected before the upstream pipeline captured the field, like `disclosureDate` — the `.dropna()` and `pandas.isna()` caveats from 0.2.6 apply to it as well
|
|
24
|
+
- The raw-dict branch is purely additive — no call-site changes are required to receive the new fields
|
|
25
|
+
|
|
8
26
|
## [0.2.7] - 2026-07-24
|
|
9
27
|
|
|
10
28
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: finbrain-python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Official Python client for the FinBrain API
|
|
5
5
|
Author-email: Ahmet Salim Bilgin <ahmet@finbrain.tech>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -84,7 +84,8 @@ fb.analyst_ratings.ticker("AMZN",
|
|
|
84
84
|
as_dataframe=True)
|
|
85
85
|
|
|
86
86
|
# ---------- house trades ----------
|
|
87
|
-
# Rows include `disclosureDate`
|
|
87
|
+
# Rows include `disclosureDate`, `owner`, `amountRaw` and `amountFlag`
|
|
88
|
+
# alongside the transaction `date` — see "Congressional trade fields" below.
|
|
88
89
|
fb.house_trades.ticker("AMZN",
|
|
89
90
|
date_from="2025-01-01",
|
|
90
91
|
date_to="2025-06-30",
|
|
@@ -156,7 +157,7 @@ fb.screener.insider_trading(limit=50)
|
|
|
156
157
|
fb.screener.reddit_mentions(limit=100, as_dataframe=True)
|
|
157
158
|
fb.screener.government_contracts(limit=100, as_dataframe=True)
|
|
158
159
|
fb.screener.patent_filings(limit=100, as_dataframe=True)
|
|
159
|
-
fb.screener.congress_house(limit=50) # rows carry `disclosureDate`
|
|
160
|
+
fb.screener.congress_house(limit=50) # rows carry `disclosureDate` and `owner`
|
|
160
161
|
fb.screener.congress_senate(limit=50)
|
|
161
162
|
|
|
162
163
|
# ---------- recent data ----------
|
|
@@ -164,7 +165,7 @@ fb.recent.news(limit=100, as_dataframe=True)
|
|
|
164
165
|
fb.recent.analyst_ratings(limit=50)
|
|
165
166
|
```
|
|
166
167
|
|
|
167
|
-
### Congressional trade
|
|
168
|
+
### Congressional trade fields
|
|
168
169
|
|
|
169
170
|
House and Senate trade rows carry **two** dates, and the gap between them is
|
|
170
171
|
the reporting lag — often weeks:
|
|
@@ -174,13 +175,31 @@ the reporting lag — often weeks:
|
|
|
174
175
|
| `date` | Transaction date — when the member actually bought or sold |
|
|
175
176
|
| `disclosureDate` | Public disclosure date — when the periodic transaction report ran |
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
Rows also identify **whose account** traded and how the filed amount was
|
|
179
|
+
normalized:
|
|
180
|
+
|
|
181
|
+
| Field | Meaning |
|
|
182
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
183
|
+
| `owner` | Beneficial owner of the account: `SELF`, `SP` (spouse), `DC` (dependent child), `JT` (joint), or an account code |
|
|
184
|
+
| `amountRaw` | The amount string as originally filed — set only when `amount` was rewritten to the canonical STOCK Act bracket, `null` otherwise |
|
|
185
|
+
| `amountFlag` | `null` on clean rows; `review` or `ambiguous` when the filed amount could not be safely normalized (then `amount` keeps the raw string as filed) |
|
|
186
|
+
|
|
187
|
+
`amount` is normalized to the ten statutory STOCK Act brackets (e.g.
|
|
188
|
+
`"$1,001 - $15,000"`) whenever the filed string is an unambiguous formatting
|
|
189
|
+
variant of one; open-ended filing categories like `"Over $1,000,000"` are
|
|
190
|
+
kept as filed. A filing with no usable amount at all reports `amount` as
|
|
191
|
+
`"Unknown"` with `amountFlag` = `review`. Senate filings that leave the owner
|
|
192
|
+
column blank report `owner` as `UNKNOWN`; House filings that leave it blank
|
|
193
|
+
report `SELF`, per the House PTR-form instructions.
|
|
194
|
+
|
|
195
|
+
`disclosureDate` and `owner` are `null` on historical rows collected before
|
|
196
|
+
the fields were captured upstream. With `as_dataframe=True`, `date` is the
|
|
197
|
+
**index** and the other fields are columns whose missing values read as
|
|
198
|
+
`None` or `NaN` depending on your pandas version — test them with
|
|
199
|
+
`pandas.isna()` rather than `is None`. Note that `.dropna()` on such a frame
|
|
200
|
+
will discard every row with any missing field — use `.dropna(subset=[...])`.
|
|
201
|
+
`disclosureDate` and `owner` are also present on
|
|
202
|
+
`fb.screener.congress_house()` and `fb.screener.congress_senate()` rows.
|
|
184
203
|
|
|
185
204
|
`date_from` / `date_to` bound the **transaction** date, not the disclosure
|
|
186
205
|
date — a trade executed inside the window is returned even if it was disclosed
|
|
@@ -193,6 +212,12 @@ lag_days = [
|
|
|
193
212
|
for t in trades
|
|
194
213
|
if t["disclosureDate"]
|
|
195
214
|
]
|
|
215
|
+
|
|
216
|
+
# Only the member's own trades, skipping flagged amounts
|
|
217
|
+
own = [
|
|
218
|
+
t for t in trades
|
|
219
|
+
if t["owner"] == "SELF" and t["amountFlag"] is None
|
|
220
|
+
]
|
|
196
221
|
```
|
|
197
222
|
|
|
198
223
|
## ⚡ Async Usage
|
|
@@ -56,7 +56,8 @@ fb.analyst_ratings.ticker("AMZN",
|
|
|
56
56
|
as_dataframe=True)
|
|
57
57
|
|
|
58
58
|
# ---------- house trades ----------
|
|
59
|
-
# Rows include `disclosureDate`
|
|
59
|
+
# Rows include `disclosureDate`, `owner`, `amountRaw` and `amountFlag`
|
|
60
|
+
# alongside the transaction `date` — see "Congressional trade fields" below.
|
|
60
61
|
fb.house_trades.ticker("AMZN",
|
|
61
62
|
date_from="2025-01-01",
|
|
62
63
|
date_to="2025-06-30",
|
|
@@ -128,7 +129,7 @@ fb.screener.insider_trading(limit=50)
|
|
|
128
129
|
fb.screener.reddit_mentions(limit=100, as_dataframe=True)
|
|
129
130
|
fb.screener.government_contracts(limit=100, as_dataframe=True)
|
|
130
131
|
fb.screener.patent_filings(limit=100, as_dataframe=True)
|
|
131
|
-
fb.screener.congress_house(limit=50) # rows carry `disclosureDate`
|
|
132
|
+
fb.screener.congress_house(limit=50) # rows carry `disclosureDate` and `owner`
|
|
132
133
|
fb.screener.congress_senate(limit=50)
|
|
133
134
|
|
|
134
135
|
# ---------- recent data ----------
|
|
@@ -136,7 +137,7 @@ fb.recent.news(limit=100, as_dataframe=True)
|
|
|
136
137
|
fb.recent.analyst_ratings(limit=50)
|
|
137
138
|
```
|
|
138
139
|
|
|
139
|
-
### Congressional trade
|
|
140
|
+
### Congressional trade fields
|
|
140
141
|
|
|
141
142
|
House and Senate trade rows carry **two** dates, and the gap between them is
|
|
142
143
|
the reporting lag — often weeks:
|
|
@@ -146,13 +147,31 @@ the reporting lag — often weeks:
|
|
|
146
147
|
| `date` | Transaction date — when the member actually bought or sold |
|
|
147
148
|
| `disclosureDate` | Public disclosure date — when the periodic transaction report ran |
|
|
148
149
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
Rows also identify **whose account** traded and how the filed amount was
|
|
151
|
+
normalized:
|
|
152
|
+
|
|
153
|
+
| Field | Meaning |
|
|
154
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
155
|
+
| `owner` | Beneficial owner of the account: `SELF`, `SP` (spouse), `DC` (dependent child), `JT` (joint), or an account code |
|
|
156
|
+
| `amountRaw` | The amount string as originally filed — set only when `amount` was rewritten to the canonical STOCK Act bracket, `null` otherwise |
|
|
157
|
+
| `amountFlag` | `null` on clean rows; `review` or `ambiguous` when the filed amount could not be safely normalized (then `amount` keeps the raw string as filed) |
|
|
158
|
+
|
|
159
|
+
`amount` is normalized to the ten statutory STOCK Act brackets (e.g.
|
|
160
|
+
`"$1,001 - $15,000"`) whenever the filed string is an unambiguous formatting
|
|
161
|
+
variant of one; open-ended filing categories like `"Over $1,000,000"` are
|
|
162
|
+
kept as filed. A filing with no usable amount at all reports `amount` as
|
|
163
|
+
`"Unknown"` with `amountFlag` = `review`. Senate filings that leave the owner
|
|
164
|
+
column blank report `owner` as `UNKNOWN`; House filings that leave it blank
|
|
165
|
+
report `SELF`, per the House PTR-form instructions.
|
|
166
|
+
|
|
167
|
+
`disclosureDate` and `owner` are `null` on historical rows collected before
|
|
168
|
+
the fields were captured upstream. With `as_dataframe=True`, `date` is the
|
|
169
|
+
**index** and the other fields are columns whose missing values read as
|
|
170
|
+
`None` or `NaN` depending on your pandas version — test them with
|
|
171
|
+
`pandas.isna()` rather than `is None`. Note that `.dropna()` on such a frame
|
|
172
|
+
will discard every row with any missing field — use `.dropna(subset=[...])`.
|
|
173
|
+
`disclosureDate` and `owner` are also present on
|
|
174
|
+
`fb.screener.congress_house()` and `fb.screener.congress_senate()` rows.
|
|
156
175
|
|
|
157
176
|
`date_from` / `date_to` bound the **transaction** date, not the disclosure
|
|
158
177
|
date — a trade executed inside the window is returned even if it was disclosed
|
|
@@ -165,6 +184,12 @@ lag_days = [
|
|
|
165
184
|
for t in trades
|
|
166
185
|
if t["disclosureDate"]
|
|
167
186
|
]
|
|
187
|
+
|
|
188
|
+
# Only the member's own trades, skipping flagged amounts
|
|
189
|
+
own = [
|
|
190
|
+
t for t in trades
|
|
191
|
+
if t["owner"] == "SELF" and t["amountFlag"] is None
|
|
192
|
+
]
|
|
168
193
|
```
|
|
169
194
|
|
|
170
195
|
## ⚡ Async Usage
|
|
@@ -28,11 +28,22 @@ class AsyncHouseTradesAPI:
|
|
|
28
28
|
Fetch House-member trades for a symbol (async).
|
|
29
29
|
|
|
30
30
|
Each row in ``trades`` carries ``date`` (the transaction date),
|
|
31
|
-
``politician``, ``transactionType``, ``amount``
|
|
32
|
-
``disclosureDate`` — the date the
|
|
33
|
-
member's periodic transaction
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
``politician``, ``transactionType``, ``amount``, ``owner``,
|
|
32
|
+
``amountRaw``, ``amountFlag`` and ``disclosureDate`` — the date the
|
|
33
|
+
trade was publicly disclosed in the member's periodic transaction
|
|
34
|
+
report.
|
|
35
|
+
|
|
36
|
+
``owner`` is the beneficial owner of the traded account: ``"SELF"``,
|
|
37
|
+
``"SP"`` (spouse), ``"DC"`` (dependent child), ``"JT"`` (joint), or
|
|
38
|
+
an account code; House filings that leave the owner column blank
|
|
39
|
+
report as ``"SELF"``. ``amountRaw`` preserves the originally filed
|
|
40
|
+
amount string on rows whose ``amount`` was normalized to a STOCK Act
|
|
41
|
+
bracket; ``amountFlag`` is ``"review"`` or ``"ambiguous"`` when the
|
|
42
|
+
amount could not be safely normalized (``None`` otherwise).
|
|
43
|
+
|
|
44
|
+
``disclosureDate`` and ``owner`` are ``None`` for historical rows
|
|
45
|
+
collected before the fields were captured (``NaN`` in the DataFrame
|
|
46
|
+
branch on newer pandas — use ``pandas.isna``).
|
|
36
47
|
|
|
37
48
|
``date_from``/``date_to`` bound the transaction date, not the
|
|
38
49
|
disclosure date.
|
|
@@ -111,8 +111,10 @@ class AsyncScreenerAPI:
|
|
|
111
111
|
Screen House trades across all tickers.
|
|
112
112
|
|
|
113
113
|
Rows carry ``symbol``, ``name``, ``date``, ``politician``,
|
|
114
|
-
``transactionType``, ``amount
|
|
115
|
-
|
|
114
|
+
``transactionType``, ``amount``, ``owner`` (beneficial owner of the
|
|
115
|
+
account: ``"SELF"``, ``"SP"``, ``"DC"``, ``"JT"``, or an account
|
|
116
|
+
code) and ``disclosureDate`` (the public disclosure date). ``owner``
|
|
117
|
+
and ``disclosureDate`` are ``None`` on historical rows.
|
|
116
118
|
"""
|
|
117
119
|
params = self._build_params(limit=limit)
|
|
118
120
|
return await self._get("screener/congress/house", params, as_dataframe)
|
|
@@ -129,8 +131,11 @@ class AsyncScreenerAPI:
|
|
|
129
131
|
Screen Senate trades across all tickers.
|
|
130
132
|
|
|
131
133
|
Rows carry ``symbol``, ``name``, ``date``, ``politician``,
|
|
132
|
-
``transactionType``, ``amount
|
|
133
|
-
|
|
134
|
+
``transactionType``, ``amount``, ``owner`` (beneficial owner of the
|
|
135
|
+
account: ``"SELF"``, ``"SP"``, ``"DC"``, ``"JT"``, an account code,
|
|
136
|
+
or ``"UNKNOWN"`` for blank Senate filings) and ``disclosureDate``
|
|
137
|
+
(the public disclosure date). ``owner`` and ``disclosureDate`` are
|
|
138
|
+
``None`` on historical rows.
|
|
134
139
|
"""
|
|
135
140
|
params = self._build_params(limit=limit)
|
|
136
141
|
return await self._get("screener/congress/senate", params, as_dataframe)
|
|
@@ -28,11 +28,22 @@ class AsyncSenateTradesAPI:
|
|
|
28
28
|
Fetch Senate-member trades for a symbol (async).
|
|
29
29
|
|
|
30
30
|
Each row in ``trades`` carries ``date`` (the transaction date),
|
|
31
|
-
``politician``, ``transactionType``, ``amount``
|
|
32
|
-
``disclosureDate`` — the date the
|
|
33
|
-
member's periodic transaction
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
``politician``, ``transactionType``, ``amount``, ``owner``,
|
|
32
|
+
``amountRaw``, ``amountFlag`` and ``disclosureDate`` — the date the
|
|
33
|
+
trade was publicly disclosed in the member's periodic transaction
|
|
34
|
+
report.
|
|
35
|
+
|
|
36
|
+
``owner`` is the beneficial owner of the traded account: ``"SELF"``,
|
|
37
|
+
``"SP"`` (spouse), ``"DC"`` (dependent child), ``"JT"`` (joint), an
|
|
38
|
+
account code, or ``"UNKNOWN"`` when the Senate filing left the owner
|
|
39
|
+
column blank. ``amountRaw`` preserves the originally filed amount
|
|
40
|
+
string on rows whose ``amount`` was normalized to a STOCK Act
|
|
41
|
+
bracket; ``amountFlag`` is ``"review"`` or ``"ambiguous"`` when the
|
|
42
|
+
amount could not be safely normalized (``None`` otherwise).
|
|
43
|
+
|
|
44
|
+
``disclosureDate`` and ``owner`` are ``None`` for historical rows
|
|
45
|
+
collected before the fields were captured (``NaN`` in the DataFrame
|
|
46
|
+
branch on newer pandas — use ``pandas.isna``).
|
|
36
47
|
|
|
37
48
|
``date_from``/``date_to`` bound the transaction date, not the
|
|
38
49
|
disclosure date.
|
|
@@ -51,15 +51,33 @@ class HouseTradesAPI:
|
|
|
51
51
|
dict | pandas.DataFrame
|
|
52
52
|
The raw dict has a ``trades`` list whose rows carry ``date``
|
|
53
53
|
(the transaction date), ``politician``, ``transactionType``,
|
|
54
|
-
``amount``
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
``
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
``amount``, ``owner``, ``amountRaw``, ``amountFlag`` and
|
|
55
|
+
``disclosureDate`` — the date the trade was publicly disclosed
|
|
56
|
+
in the member's periodic transaction report. The gap between the
|
|
57
|
+
two dates is the reporting lag.
|
|
58
|
+
|
|
59
|
+
``owner`` is the beneficial owner of the traded account:
|
|
60
|
+
``"SELF"``, ``"SP"`` (spouse), ``"DC"`` (dependent child),
|
|
61
|
+
``"JT"`` (joint), or an account code. House filings that leave
|
|
62
|
+
the owner column blank report as ``"SELF"``, per the House
|
|
63
|
+
instructions for the PTR form.
|
|
64
|
+
|
|
65
|
+
``amount`` is normalized to the statutory STOCK Act bracket
|
|
66
|
+
(e.g. ``"$1,001 - $15,000"``) whenever the filed string is an
|
|
67
|
+
unambiguous formatting variant of one. On rows that were
|
|
68
|
+
normalized, ``amountRaw`` preserves the string as originally
|
|
69
|
+
filed. When the filed amount could not be safely normalized,
|
|
70
|
+
``amount`` keeps the raw filed string (or ``"Unknown"`` when the
|
|
71
|
+
filing had no usable amount) and ``amountFlag`` is ``"review"``
|
|
72
|
+
or ``"ambiguous"``; on all other rows ``amountRaw`` and
|
|
73
|
+
``amountFlag`` are ``None``.
|
|
74
|
+
|
|
75
|
+
``disclosureDate`` and ``owner`` are ``None`` for historical
|
|
76
|
+
rows collected before the fields were captured upstream. In the
|
|
77
|
+
DataFrame branch ``date`` becomes the index and the remaining
|
|
78
|
+
fields are columns whose missing values read as ``None`` or
|
|
79
|
+
``NaN`` depending on the pandas version — test them with
|
|
80
|
+
:func:`pandas.isna`.
|
|
63
81
|
|
|
64
82
|
Notes
|
|
65
83
|
-----
|
|
@@ -71,7 +89,8 @@ class HouseTradesAPI:
|
|
|
71
89
|
|
|
72
90
|
{"date": "2026-06-15", "politician": "Jane Doe",
|
|
73
91
|
"transactionType": "Purchase", "amount": "$1,001 - $15,000",
|
|
74
|
-
"
|
|
92
|
+
"owner": "JT", "amountRaw": "$1,001 - $15,000 *",
|
|
93
|
+
"amountFlag": None, "disclosureDate": "2026-07-01"}
|
|
75
94
|
|
|
76
95
|
"""
|
|
77
96
|
params: Dict[str, str] = {}
|
|
@@ -116,8 +116,10 @@ class ScreenerAPI:
|
|
|
116
116
|
Screen House trades across all tickers.
|
|
117
117
|
|
|
118
118
|
Rows carry ``symbol``, ``name``, ``date``, ``politician``,
|
|
119
|
-
``transactionType``, ``amount
|
|
120
|
-
|
|
119
|
+
``transactionType``, ``amount``, ``owner`` (beneficial owner of the
|
|
120
|
+
account: ``"SELF"``, ``"SP"``, ``"DC"``, ``"JT"``, or an account
|
|
121
|
+
code) and ``disclosureDate`` (the public disclosure date). ``owner``
|
|
122
|
+
and ``disclosureDate`` are ``None`` on historical rows.
|
|
121
123
|
"""
|
|
122
124
|
params = self._build_params(limit=limit)
|
|
123
125
|
return self._get("screener/congress/house", params, as_dataframe)
|
|
@@ -134,8 +136,11 @@ class ScreenerAPI:
|
|
|
134
136
|
Screen Senate trades across all tickers.
|
|
135
137
|
|
|
136
138
|
Rows carry ``symbol``, ``name``, ``date``, ``politician``,
|
|
137
|
-
``transactionType``, ``amount
|
|
138
|
-
|
|
139
|
+
``transactionType``, ``amount``, ``owner`` (beneficial owner of the
|
|
140
|
+
account: ``"SELF"``, ``"SP"``, ``"DC"``, ``"JT"``, an account code,
|
|
141
|
+
or ``"UNKNOWN"`` for blank Senate filings) and ``disclosureDate``
|
|
142
|
+
(the public disclosure date). ``owner`` and ``disclosureDate`` are
|
|
143
|
+
``None`` on historical rows.
|
|
139
144
|
"""
|
|
140
145
|
params = self._build_params(limit=limit)
|
|
141
146
|
return self._get("screener/congress/senate", params, as_dataframe)
|
|
@@ -51,15 +51,32 @@ class SenateTradesAPI:
|
|
|
51
51
|
dict | pandas.DataFrame
|
|
52
52
|
The raw dict has a ``trades`` list whose rows carry ``date``
|
|
53
53
|
(the transaction date), ``politician``, ``transactionType``,
|
|
54
|
-
``amount``
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
``
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
``amount``, ``owner``, ``amountRaw``, ``amountFlag`` and
|
|
55
|
+
``disclosureDate`` — the date the trade was publicly disclosed
|
|
56
|
+
in the member's periodic transaction report. The gap between the
|
|
57
|
+
two dates is the reporting lag.
|
|
58
|
+
|
|
59
|
+
``owner`` is the beneficial owner of the traded account:
|
|
60
|
+
``"SELF"``, ``"SP"`` (spouse), ``"DC"`` (dependent child),
|
|
61
|
+
``"JT"`` (joint), an account code, or ``"UNKNOWN"`` when the
|
|
62
|
+
Senate filing left the owner column blank.
|
|
63
|
+
|
|
64
|
+
``amount`` is normalized to the statutory STOCK Act bracket
|
|
65
|
+
(e.g. ``"$1,001 - $15,000"``) whenever the filed string is an
|
|
66
|
+
unambiguous formatting variant of one. On rows that were
|
|
67
|
+
normalized, ``amountRaw`` preserves the string as originally
|
|
68
|
+
filed. When the filed amount could not be safely normalized,
|
|
69
|
+
``amount`` keeps the raw filed string (or ``"Unknown"`` when the
|
|
70
|
+
filing had no usable amount) and ``amountFlag`` is ``"review"``
|
|
71
|
+
or ``"ambiguous"``; on all other rows ``amountRaw`` and
|
|
72
|
+
``amountFlag`` are ``None``.
|
|
73
|
+
|
|
74
|
+
``disclosureDate`` and ``owner`` are ``None`` for historical
|
|
75
|
+
rows collected before the fields were captured upstream. In the
|
|
76
|
+
DataFrame branch ``date`` becomes the index and the remaining
|
|
77
|
+
fields are columns whose missing values read as ``None`` or
|
|
78
|
+
``NaN`` depending on the pandas version — test them with
|
|
79
|
+
:func:`pandas.isna`.
|
|
63
80
|
|
|
64
81
|
Notes
|
|
65
82
|
-----
|
|
@@ -71,7 +88,8 @@ class SenateTradesAPI:
|
|
|
71
88
|
|
|
72
89
|
{"date": "2026-06-10", "politician": "Jane Doe",
|
|
73
90
|
"transactionType": "Purchase", "amount": "$1,001 - $15,000",
|
|
74
|
-
"
|
|
91
|
+
"owner": "SP", "amountRaw": "$1,001-$15,000",
|
|
92
|
+
"amountFlag": None, "disclosureDate": "2026-06-25"}
|
|
75
93
|
|
|
76
94
|
"""
|
|
77
95
|
params: Dict[str, str] = {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: finbrain-python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Official Python client for the FinBrain API
|
|
5
5
|
Author-email: Ahmet Salim Bilgin <ahmet@finbrain.tech>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -84,7 +84,8 @@ fb.analyst_ratings.ticker("AMZN",
|
|
|
84
84
|
as_dataframe=True)
|
|
85
85
|
|
|
86
86
|
# ---------- house trades ----------
|
|
87
|
-
# Rows include `disclosureDate`
|
|
87
|
+
# Rows include `disclosureDate`, `owner`, `amountRaw` and `amountFlag`
|
|
88
|
+
# alongside the transaction `date` — see "Congressional trade fields" below.
|
|
88
89
|
fb.house_trades.ticker("AMZN",
|
|
89
90
|
date_from="2025-01-01",
|
|
90
91
|
date_to="2025-06-30",
|
|
@@ -156,7 +157,7 @@ fb.screener.insider_trading(limit=50)
|
|
|
156
157
|
fb.screener.reddit_mentions(limit=100, as_dataframe=True)
|
|
157
158
|
fb.screener.government_contracts(limit=100, as_dataframe=True)
|
|
158
159
|
fb.screener.patent_filings(limit=100, as_dataframe=True)
|
|
159
|
-
fb.screener.congress_house(limit=50) # rows carry `disclosureDate`
|
|
160
|
+
fb.screener.congress_house(limit=50) # rows carry `disclosureDate` and `owner`
|
|
160
161
|
fb.screener.congress_senate(limit=50)
|
|
161
162
|
|
|
162
163
|
# ---------- recent data ----------
|
|
@@ -164,7 +165,7 @@ fb.recent.news(limit=100, as_dataframe=True)
|
|
|
164
165
|
fb.recent.analyst_ratings(limit=50)
|
|
165
166
|
```
|
|
166
167
|
|
|
167
|
-
### Congressional trade
|
|
168
|
+
### Congressional trade fields
|
|
168
169
|
|
|
169
170
|
House and Senate trade rows carry **two** dates, and the gap between them is
|
|
170
171
|
the reporting lag — often weeks:
|
|
@@ -174,13 +175,31 @@ the reporting lag — often weeks:
|
|
|
174
175
|
| `date` | Transaction date — when the member actually bought or sold |
|
|
175
176
|
| `disclosureDate` | Public disclosure date — when the periodic transaction report ran |
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
Rows also identify **whose account** traded and how the filed amount was
|
|
179
|
+
normalized:
|
|
180
|
+
|
|
181
|
+
| Field | Meaning |
|
|
182
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
183
|
+
| `owner` | Beneficial owner of the account: `SELF`, `SP` (spouse), `DC` (dependent child), `JT` (joint), or an account code |
|
|
184
|
+
| `amountRaw` | The amount string as originally filed — set only when `amount` was rewritten to the canonical STOCK Act bracket, `null` otherwise |
|
|
185
|
+
| `amountFlag` | `null` on clean rows; `review` or `ambiguous` when the filed amount could not be safely normalized (then `amount` keeps the raw string as filed) |
|
|
186
|
+
|
|
187
|
+
`amount` is normalized to the ten statutory STOCK Act brackets (e.g.
|
|
188
|
+
`"$1,001 - $15,000"`) whenever the filed string is an unambiguous formatting
|
|
189
|
+
variant of one; open-ended filing categories like `"Over $1,000,000"` are
|
|
190
|
+
kept as filed. A filing with no usable amount at all reports `amount` as
|
|
191
|
+
`"Unknown"` with `amountFlag` = `review`. Senate filings that leave the owner
|
|
192
|
+
column blank report `owner` as `UNKNOWN`; House filings that leave it blank
|
|
193
|
+
report `SELF`, per the House PTR-form instructions.
|
|
194
|
+
|
|
195
|
+
`disclosureDate` and `owner` are `null` on historical rows collected before
|
|
196
|
+
the fields were captured upstream. With `as_dataframe=True`, `date` is the
|
|
197
|
+
**index** and the other fields are columns whose missing values read as
|
|
198
|
+
`None` or `NaN` depending on your pandas version — test them with
|
|
199
|
+
`pandas.isna()` rather than `is None`. Note that `.dropna()` on such a frame
|
|
200
|
+
will discard every row with any missing field — use `.dropna(subset=[...])`.
|
|
201
|
+
`disclosureDate` and `owner` are also present on
|
|
202
|
+
`fb.screener.congress_house()` and `fb.screener.congress_senate()` rows.
|
|
184
203
|
|
|
185
204
|
`date_from` / `date_to` bound the **transaction** date, not the disclosure
|
|
186
205
|
date — a trade executed inside the window is returned even if it was disclosed
|
|
@@ -193,6 +212,12 @@ lag_days = [
|
|
|
193
212
|
for t in trades
|
|
194
213
|
if t["disclosureDate"]
|
|
195
214
|
]
|
|
215
|
+
|
|
216
|
+
# Only the member's own trades, skipping flagged amounts
|
|
217
|
+
own = [
|
|
218
|
+
t for t in trades
|
|
219
|
+
if t["owner"] == "SELF" and t["amountFlag"] is None
|
|
220
|
+
]
|
|
196
221
|
```
|
|
197
222
|
|
|
198
223
|
## ⚡ Async Usage
|
|
@@ -21,6 +21,9 @@ def test_house_trades_raw_ok(client, _activate_responses):
|
|
|
21
21
|
"politician": "Nancy Pelosi",
|
|
22
22
|
"transactionType": "Purchase",
|
|
23
23
|
"amount": "$15,001 - $50,000",
|
|
24
|
+
"owner": "JT",
|
|
25
|
+
"amountRaw": "$15,001 - $50,000 *",
|
|
26
|
+
"amountFlag": None,
|
|
24
27
|
"disclosureDate": "2024-02-05",
|
|
25
28
|
}
|
|
26
29
|
],
|
|
@@ -33,6 +36,10 @@ def test_house_trades_raw_ok(client, _activate_responses):
|
|
|
33
36
|
assert isinstance(data["trades"], list)
|
|
34
37
|
assert data["trades"][0]["politician"] == "Nancy Pelosi"
|
|
35
38
|
assert data["trades"][0]["disclosureDate"] == "2024-02-05"
|
|
39
|
+
assert data["trades"][0]["owner"] == "JT"
|
|
40
|
+
# The bracket was normalized, so the originally filed string survives.
|
|
41
|
+
assert data["trades"][0]["amountRaw"] == "$15,001 - $50,000 *"
|
|
42
|
+
assert data["trades"][0]["amountFlag"] is None
|
|
36
43
|
|
|
37
44
|
|
|
38
45
|
# ─────────── DataFrame branch ───────────────────────────────────────────
|
|
@@ -48,13 +55,19 @@ def test_house_trades_dataframe_ok(client, _activate_responses):
|
|
|
48
55
|
"politician": "Nancy Pelosi",
|
|
49
56
|
"transactionType": "Purchase",
|
|
50
57
|
"amount": "$15,001 - $50,000",
|
|
58
|
+
"owner": "SP",
|
|
59
|
+
"amountRaw": None,
|
|
60
|
+
"amountFlag": None,
|
|
51
61
|
"disclosureDate": "2024-02-05",
|
|
52
62
|
},
|
|
53
63
|
{
|
|
54
64
|
"date": "2024-01-10",
|
|
55
65
|
"politician": "Pete Sessions",
|
|
56
66
|
"transactionType": "Sale",
|
|
57
|
-
"amount": "
|
|
67
|
+
"amount": "Unknown",
|
|
68
|
+
"owner": None,
|
|
69
|
+
"amountRaw": None,
|
|
70
|
+
"amountFlag": "review",
|
|
58
71
|
"disclosureDate": None,
|
|
59
72
|
},
|
|
60
73
|
],
|
|
@@ -70,6 +83,9 @@ def test_house_trades_dataframe_ok(client, _activate_responses):
|
|
|
70
83
|
"politician",
|
|
71
84
|
"transactionType",
|
|
72
85
|
"amount",
|
|
86
|
+
"owner",
|
|
87
|
+
"amountRaw",
|
|
88
|
+
"amountFlag",
|
|
73
89
|
"disclosureDate",
|
|
74
90
|
}
|
|
75
91
|
assert df.index.name == "date"
|
|
@@ -80,9 +96,16 @@ def test_house_trades_dataframe_ok(client, _activate_responses):
|
|
|
80
96
|
assert df.loc["2024-01-15", "transactionType"] == "Purchase"
|
|
81
97
|
assert df.loc["2024-01-15", "amount"] == "$15,001 - $50,000"
|
|
82
98
|
assert df.loc["2024-01-15", "disclosureDate"] == "2024-02-05"
|
|
83
|
-
|
|
84
|
-
#
|
|
99
|
+
assert df.loc["2024-01-15", "owner"] == "SP"
|
|
100
|
+
# A filing with no usable amount stores the explicit "Unknown"
|
|
101
|
+
# placeholder and carries a review flag.
|
|
102
|
+
assert df.loc["2024-01-10", "amount"] == "Unknown"
|
|
103
|
+
assert df.loc["2024-01-10", "amountFlag"] == "review"
|
|
104
|
+
# Historical rows predate the disclosure-date and owner fields; JSON null
|
|
105
|
+
# becomes NaN once pandas builds the column.
|
|
85
106
|
assert pd.isna(df.loc["2024-01-10", "disclosureDate"])
|
|
107
|
+
assert pd.isna(df.loc["2024-01-10", "owner"])
|
|
108
|
+
assert pd.isna(df.loc["2024-01-15", "amountFlag"])
|
|
86
109
|
|
|
87
110
|
|
|
88
111
|
# ─────────── error mapping ──────────────────────────────────────────────
|
|
@@ -231,8 +231,14 @@ class TestHouseTrades:
|
|
|
231
231
|
assert "politician" in trades[0]
|
|
232
232
|
assert "transactionType" in trades[0]
|
|
233
233
|
# Present on every row; null on rows collected before the
|
|
234
|
-
#
|
|
234
|
+
# fields were added to the pipeline.
|
|
235
235
|
assert "disclosureDate" in trades[0]
|
|
236
|
+
assert "owner" in trades[0]
|
|
237
|
+
# Amount normalization metadata: null unless the filed amount
|
|
238
|
+
# was rewritten to a STOCK Act bracket (amountRaw) or could not
|
|
239
|
+
# be safely normalized (amountFlag).
|
|
240
|
+
assert "amountRaw" in trades[0]
|
|
241
|
+
assert "amountFlag" in trades[0]
|
|
236
242
|
|
|
237
243
|
def test_dataframe(self, fb):
|
|
238
244
|
df = fb.house_trades.ticker(TICKER, as_dataframe=True)
|
|
@@ -240,9 +246,12 @@ class TestHouseTrades:
|
|
|
240
246
|
if len(df) > 0:
|
|
241
247
|
assert df.index.name == "date"
|
|
242
248
|
assert "politician" in df.columns
|
|
243
|
-
#
|
|
244
|
-
# null on rows predating the upstream
|
|
249
|
+
# Survive the DataFrame conversion as columns (values may be
|
|
250
|
+
# null on rows predating the upstream fields).
|
|
245
251
|
assert "disclosureDate" in df.columns
|
|
252
|
+
assert "owner" in df.columns
|
|
253
|
+
assert "amountRaw" in df.columns
|
|
254
|
+
assert "amountFlag" in df.columns
|
|
246
255
|
|
|
247
256
|
|
|
248
257
|
# =====================================================================
|
|
@@ -259,8 +268,14 @@ class TestSenateTrades:
|
|
|
259
268
|
assert "date" in trades[0]
|
|
260
269
|
assert "politician" in trades[0]
|
|
261
270
|
# Present on every row; null on rows collected before the
|
|
262
|
-
#
|
|
271
|
+
# fields were added to the pipeline.
|
|
263
272
|
assert "disclosureDate" in trades[0]
|
|
273
|
+
assert "owner" in trades[0]
|
|
274
|
+
# Amount normalization metadata: null unless the filed amount
|
|
275
|
+
# was rewritten to a STOCK Act bracket (amountRaw) or could not
|
|
276
|
+
# be safely normalized (amountFlag).
|
|
277
|
+
assert "amountRaw" in trades[0]
|
|
278
|
+
assert "amountFlag" in trades[0]
|
|
264
279
|
|
|
265
280
|
def test_dataframe(self, fb):
|
|
266
281
|
df = fb.senate_trades.ticker(TICKER, as_dataframe=True)
|
|
@@ -268,9 +283,12 @@ class TestSenateTrades:
|
|
|
268
283
|
if len(df) > 0:
|
|
269
284
|
assert df.index.name == "date"
|
|
270
285
|
assert "politician" in df.columns
|
|
271
|
-
#
|
|
272
|
-
# null on rows predating the upstream
|
|
286
|
+
# Survive the DataFrame conversion as columns (values may be
|
|
287
|
+
# null on rows predating the upstream fields).
|
|
273
288
|
assert "disclosureDate" in df.columns
|
|
289
|
+
assert "owner" in df.columns
|
|
290
|
+
assert "amountRaw" in df.columns
|
|
291
|
+
assert "amountFlag" in df.columns
|
|
274
292
|
|
|
275
293
|
|
|
276
294
|
# =====================================================================
|
|
@@ -517,12 +535,14 @@ class TestScreener:
|
|
|
517
535
|
assert isinstance(data, list)
|
|
518
536
|
if data:
|
|
519
537
|
assert "disclosureDate" in data[0]
|
|
538
|
+
assert "owner" in data[0]
|
|
520
539
|
|
|
521
540
|
def test_congress_senate(self, fb):
|
|
522
541
|
data = fb.screener.congress_senate(limit=5)
|
|
523
542
|
assert isinstance(data, list)
|
|
524
543
|
if data:
|
|
525
544
|
assert "disclosureDate" in data[0]
|
|
545
|
+
assert "owner" in data[0]
|
|
526
546
|
|
|
527
547
|
def test_news(self, fb):
|
|
528
548
|
data = fb.screener.news(limit=5)
|
|
@@ -99,6 +99,7 @@ def test_screener_congress_house(client, _activate_responses):
|
|
|
99
99
|
"symbol": "AAPL",
|
|
100
100
|
"name": "Apple",
|
|
101
101
|
"politician": "Nancy Pelosi",
|
|
102
|
+
"owner": "SP",
|
|
102
103
|
"disclosureDate": "2026-02-05",
|
|
103
104
|
},
|
|
104
105
|
])
|
|
@@ -107,6 +108,7 @@ def test_screener_congress_house(client, _activate_responses):
|
|
|
107
108
|
assert isinstance(data, list)
|
|
108
109
|
assert len(data) == 1
|
|
109
110
|
assert data[0]["politician"] == "Nancy Pelosi"
|
|
111
|
+
assert data[0]["owner"] == "SP"
|
|
110
112
|
assert data[0]["disclosureDate"] == "2026-02-05"
|
|
111
113
|
|
|
112
114
|
|
|
@@ -116,12 +118,14 @@ def test_screener_congress_house_dataframe(client, _activate_responses):
|
|
|
116
118
|
"symbol": "AAPL",
|
|
117
119
|
"name": "Apple",
|
|
118
120
|
"politician": "Nancy Pelosi",
|
|
121
|
+
"owner": "SP",
|
|
119
122
|
"disclosureDate": "2026-02-05",
|
|
120
123
|
},
|
|
121
124
|
{
|
|
122
125
|
"symbol": "MSFT",
|
|
123
126
|
"name": "Microsoft",
|
|
124
127
|
"politician": "Dan Crenshaw",
|
|
128
|
+
"owner": None,
|
|
125
129
|
"disclosureDate": None,
|
|
126
130
|
},
|
|
127
131
|
])
|
|
@@ -130,12 +134,14 @@ def test_screener_congress_house_dataframe(client, _activate_responses):
|
|
|
130
134
|
assert isinstance(df, pd.DataFrame)
|
|
131
135
|
assert len(df) == 2
|
|
132
136
|
assert df.index.name == "symbol"
|
|
133
|
-
assert set(df.columns) == {"name", "politician", "disclosureDate"}
|
|
137
|
+
assert set(df.columns) == {"name", "politician", "owner", "disclosureDate"}
|
|
134
138
|
assert df.loc["AAPL", "politician"] == "Nancy Pelosi"
|
|
139
|
+
assert df.loc["AAPL", "owner"] == "SP"
|
|
135
140
|
assert df.loc["AAPL", "disclosureDate"] == "2026-02-05"
|
|
136
|
-
# Historical rows predate the disclosure-date
|
|
137
|
-
# NaN once pandas builds the column.
|
|
141
|
+
# Historical rows predate the disclosure-date and owner fields; JSON null
|
|
142
|
+
# becomes NaN once pandas builds the column.
|
|
138
143
|
assert pd.isna(df.loc["MSFT", "disclosureDate"])
|
|
144
|
+
assert pd.isna(df.loc["MSFT", "owner"])
|
|
139
145
|
|
|
140
146
|
|
|
141
147
|
# ── congress senate ────────────────────────────────────────────────────
|
|
@@ -145,6 +151,7 @@ def test_screener_congress_senate(client, _activate_responses):
|
|
|
145
151
|
"symbol": "AAPL",
|
|
146
152
|
"name": "Apple",
|
|
147
153
|
"politician": "John Boozman",
|
|
154
|
+
"owner": "UNKNOWN",
|
|
148
155
|
"disclosureDate": "2026-01-22",
|
|
149
156
|
},
|
|
150
157
|
])
|
|
@@ -153,6 +160,7 @@ def test_screener_congress_senate(client, _activate_responses):
|
|
|
153
160
|
assert isinstance(data, list)
|
|
154
161
|
assert len(data) == 1
|
|
155
162
|
assert data[0]["politician"] == "John Boozman"
|
|
163
|
+
assert data[0]["owner"] == "UNKNOWN"
|
|
156
164
|
assert data[0]["disclosureDate"] == "2026-01-22"
|
|
157
165
|
|
|
158
166
|
|
|
@@ -162,12 +170,14 @@ def test_screener_congress_senate_dataframe(client, _activate_responses):
|
|
|
162
170
|
"symbol": "AAPL",
|
|
163
171
|
"name": "Apple",
|
|
164
172
|
"politician": "John Boozman",
|
|
173
|
+
"owner": "SELF",
|
|
165
174
|
"disclosureDate": "2026-01-22",
|
|
166
175
|
},
|
|
167
176
|
{
|
|
168
177
|
"symbol": "NVDA",
|
|
169
178
|
"name": "NVIDIA",
|
|
170
179
|
"politician": "Tommy Tuberville",
|
|
180
|
+
"owner": None,
|
|
171
181
|
"disclosureDate": None,
|
|
172
182
|
},
|
|
173
183
|
])
|
|
@@ -176,12 +186,14 @@ def test_screener_congress_senate_dataframe(client, _activate_responses):
|
|
|
176
186
|
assert isinstance(df, pd.DataFrame)
|
|
177
187
|
assert len(df) == 2
|
|
178
188
|
assert df.index.name == "symbol"
|
|
179
|
-
assert set(df.columns) == {"name", "politician", "disclosureDate"}
|
|
189
|
+
assert set(df.columns) == {"name", "politician", "owner", "disclosureDate"}
|
|
180
190
|
assert df.loc["NVDA", "politician"] == "Tommy Tuberville"
|
|
191
|
+
assert df.loc["AAPL", "owner"] == "SELF"
|
|
181
192
|
assert df.loc["AAPL", "disclosureDate"] == "2026-01-22"
|
|
182
|
-
# Historical rows predate the disclosure-date
|
|
183
|
-
# NaN once pandas builds the column.
|
|
193
|
+
# Historical rows predate the disclosure-date and owner fields; JSON null
|
|
194
|
+
# becomes NaN once pandas builds the column.
|
|
184
195
|
assert pd.isna(df.loc["NVDA", "disclosureDate"])
|
|
196
|
+
assert pd.isna(df.loc["NVDA", "owner"])
|
|
185
197
|
|
|
186
198
|
|
|
187
199
|
# ── news ───────────────────────────────────────────────────────────────
|
|
@@ -21,6 +21,9 @@ def test_senate_trades_raw_ok(client, _activate_responses):
|
|
|
21
21
|
"politician": "Shelley Moore Capito",
|
|
22
22
|
"transactionType": "Purchase",
|
|
23
23
|
"amount": "$1,001 - $15,000",
|
|
24
|
+
"owner": "SP",
|
|
25
|
+
"amountRaw": "$1,001-$15,000",
|
|
26
|
+
"amountFlag": None,
|
|
24
27
|
"disclosureDate": "2024-01-30",
|
|
25
28
|
}
|
|
26
29
|
],
|
|
@@ -33,6 +36,10 @@ def test_senate_trades_raw_ok(client, _activate_responses):
|
|
|
33
36
|
assert isinstance(data["trades"], list)
|
|
34
37
|
assert data["trades"][0]["politician"] == "Shelley Moore Capito"
|
|
35
38
|
assert data["trades"][0]["disclosureDate"] == "2024-01-30"
|
|
39
|
+
assert data["trades"][0]["owner"] == "SP"
|
|
40
|
+
# The bracket was normalized, so the originally filed string survives.
|
|
41
|
+
assert data["trades"][0]["amountRaw"] == "$1,001-$15,000"
|
|
42
|
+
assert data["trades"][0]["amountFlag"] is None
|
|
36
43
|
|
|
37
44
|
|
|
38
45
|
# ─────────── DataFrame branch ───────────────────────────────────────────
|
|
@@ -48,13 +55,19 @@ def test_senate_trades_dataframe_ok(client, _activate_responses):
|
|
|
48
55
|
"politician": "Shelley Moore Capito",
|
|
49
56
|
"transactionType": "Purchase",
|
|
50
57
|
"amount": "$1,001 - $15,000",
|
|
58
|
+
"owner": "SELF",
|
|
59
|
+
"amountRaw": None,
|
|
60
|
+
"amountFlag": None,
|
|
51
61
|
"disclosureDate": "2024-01-30",
|
|
52
62
|
},
|
|
53
63
|
{
|
|
54
64
|
"date": "2024-01-08",
|
|
55
65
|
"politician": "John Boozman",
|
|
56
66
|
"transactionType": "Purchase",
|
|
57
|
-
"amount": "$1,001 - $
|
|
67
|
+
"amount": "$1,001 - $50,000",
|
|
68
|
+
"owner": None,
|
|
69
|
+
"amountRaw": None,
|
|
70
|
+
"amountFlag": "ambiguous",
|
|
58
71
|
"disclosureDate": None,
|
|
59
72
|
},
|
|
60
73
|
],
|
|
@@ -70,6 +83,9 @@ def test_senate_trades_dataframe_ok(client, _activate_responses):
|
|
|
70
83
|
"politician",
|
|
71
84
|
"transactionType",
|
|
72
85
|
"amount",
|
|
86
|
+
"owner",
|
|
87
|
+
"amountRaw",
|
|
88
|
+
"amountFlag",
|
|
73
89
|
"disclosureDate",
|
|
74
90
|
}
|
|
75
91
|
assert df.index.name == "date"
|
|
@@ -78,11 +94,16 @@ def test_senate_trades_dataframe_ok(client, _activate_responses):
|
|
|
78
94
|
assert pd.Timestamp("2024-01-08") in df.index
|
|
79
95
|
assert df.loc["2024-01-08", "politician"] == "John Boozman"
|
|
80
96
|
assert df.loc["2024-01-15", "transactionType"] == "Purchase"
|
|
81
|
-
assert df.loc["2024-01-08", "amount"] == "$1,001 - $
|
|
97
|
+
assert df.loc["2024-01-08", "amount"] == "$1,001 - $50,000"
|
|
82
98
|
assert df.loc["2024-01-15", "disclosureDate"] == "2024-01-30"
|
|
83
|
-
|
|
84
|
-
#
|
|
99
|
+
assert df.loc["2024-01-15", "owner"] == "SELF"
|
|
100
|
+
# A flagged amount keeps the raw filed string in `amount`.
|
|
101
|
+
assert df.loc["2024-01-08", "amountFlag"] == "ambiguous"
|
|
102
|
+
# Historical rows predate the disclosure-date and owner fields; JSON null
|
|
103
|
+
# becomes NaN once pandas builds the column.
|
|
85
104
|
assert pd.isna(df.loc["2024-01-08", "disclosureDate"])
|
|
105
|
+
assert pd.isna(df.loc["2024-01-08", "owner"])
|
|
106
|
+
assert pd.isna(df.loc["2024-01-15", "amountFlag"])
|
|
86
107
|
|
|
87
108
|
|
|
88
109
|
# ─────────── error mapping ──────────────────────────────────────────────
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/analyst_ratings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/corporate_lobbying.py
RENAMED
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/government_contracts.py
RENAMED
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/insider_transactions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/patent_filings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/aio/endpoints/reddit_mentions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/corporate_lobbying.py
RENAMED
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/government_contracts.py
RENAMED
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain/endpoints/insider_transactions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{finbrain_python-0.2.7 → finbrain_python-0.2.8}/src/finbrain_python.egg-info/scm_file_list.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|