finbrain-python 0.2.8__tar.gz → 0.3.0__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.
Files changed (93) hide show
  1. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/CHANGELOG.md +36 -1
  2. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/PKG-INFO +95 -9
  3. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/README.md +94 -8
  4. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/app_ratings.py +37 -1
  5. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/house_trades.py +3 -3
  6. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/screener.py +15 -5
  7. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/senate_trades.py +3 -3
  8. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/app_ratings.py +68 -3
  9. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/house_trades.py +6 -6
  10. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/screener.py +15 -5
  11. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/senate_trades.py +6 -6
  12. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/plotting.py +70 -21
  13. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain_python.egg-info/PKG-INFO +95 -9
  14. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain_python.egg-info/SOURCES.txt +1 -0
  15. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain_python.egg-info/scm_file_list.json +60 -59
  16. finbrain_python-0.3.0/src/finbrain_python.egg-info/scm_version.json +8 -0
  17. finbrain_python-0.3.0/tests/test_app_ratings.py +233 -0
  18. finbrain_python-0.3.0/tests/test_cik_passthrough.py +160 -0
  19. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_house_trades.py +1 -1
  20. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_integration.py +12 -8
  21. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_plotting.py +48 -0
  22. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_screener.py +32 -4
  23. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_senate_trades.py +1 -1
  24. finbrain_python-0.2.8/src/finbrain_python.egg-info/scm_version.json +0 -8
  25. finbrain_python-0.2.8/tests/test_app_ratings.py +0 -81
  26. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/.gitattributes +0 -0
  27. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/.github/workflows/ci.yml +0 -0
  28. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/.github/workflows/release.yml +0 -0
  29. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/.gitignore +0 -0
  30. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/LICENSE +0 -0
  31. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/RELEASE.md +0 -0
  32. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/examples/async_example.py +0 -0
  33. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/examples/transactions_plotting_example.py +0 -0
  34. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/pyproject.toml +0 -0
  35. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/setup.cfg +0 -0
  36. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/__init__.py +0 -0
  37. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/__init__.py +0 -0
  38. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/client.py +0 -0
  39. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/__init__.py +0 -0
  40. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/_utils.py +0 -0
  41. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/analyst_ratings.py +0 -0
  42. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/available.py +0 -0
  43. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/corporate_lobbying.py +0 -0
  44. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/government_contracts.py +0 -0
  45. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/insider_transactions.py +0 -0
  46. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/linkedin_data.py +0 -0
  47. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/news.py +0 -0
  48. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/options.py +0 -0
  49. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/patent_filings.py +0 -0
  50. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/predictions.py +0 -0
  51. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/recent.py +0 -0
  52. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/reddit_mentions.py +0 -0
  53. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/aio/endpoints/sentiments.py +0 -0
  54. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/client.py +0 -0
  55. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/__init__.py +0 -0
  56. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/_utils.py +0 -0
  57. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/analyst_ratings.py +0 -0
  58. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/available.py +0 -0
  59. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/corporate_lobbying.py +0 -0
  60. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/government_contracts.py +0 -0
  61. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/insider_transactions.py +0 -0
  62. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/linkedin_data.py +0 -0
  63. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/news.py +0 -0
  64. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/options.py +0 -0
  65. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/patent_filings.py +0 -0
  66. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/predictions.py +0 -0
  67. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/recent.py +0 -0
  68. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/reddit_mentions.py +0 -0
  69. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/endpoints/sentiments.py +0 -0
  70. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/exceptions.py +0 -0
  71. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain/py.typed +0 -0
  72. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain_python.egg-info/dependency_links.txt +0 -0
  73. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain_python.egg-info/requires.txt +0 -0
  74. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/src/finbrain_python.egg-info/top_level.txt +0 -0
  75. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/__init__.py +0 -0
  76. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/conftest.py +0 -0
  77. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_analyst_ratings.py +0 -0
  78. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_async_client.py +0 -0
  79. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_available.py +0 -0
  80. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_client.py +0 -0
  81. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_corporate_lobbying.py +0 -0
  82. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_envelope.py +0 -0
  83. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_government_contracts.py +0 -0
  84. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_insider_transactions.py +0 -0
  85. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_linkedin_data.py +0 -0
  86. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_news.py +0 -0
  87. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_options.py +0 -0
  88. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_patent_filings.py +0 -0
  89. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_predictions.py +0 -0
  90. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_recent.py +0 -0
  91. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_reddit_mentions.py +0 -0
  92. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_sentiments.py +0 -0
  93. {finbrain_python-0.2.8 → finbrain_python-0.3.0}/tests/test_utils.py +0 -0
@@ -5,6 +5,40 @@ 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.3.0] - 2026-09-04
9
+
10
+ ### Added
11
+
12
+ - **Per-app app ratings**: `fb.app_ratings.ticker(..., as_dataframe=True, per_app=True)` (sync and async) returns the granular frame the v2 API's new `apps[]` carries — one row per app per observation with `platform`, `app_id`, `app_name`, `score`, `ratings_count` and `install_count`. A company can publish many apps (Apple has 140 on iOS), and the blended per-date view necessarily reports only its biggest on each store; the per-app frame does no blending and derives no company score, leaving the weighting to the caller. Deliberately **not** indexed by `date`, since a date carries one row per app
13
+ - **`app_id` on the app-ratings chart**: `fb.plot.app_ratings(..., app_id=...)` charts one specific app rather than the company's largest on that store, and raises listing the available ids when the requested one is absent
14
+ - **Documentation**: README "App ratings: the per-app view (`per_app=True`)" section covering the columns, the unindexed frame, the null `app_id` case and the plotting parameter
15
+ - **Congressional amount metadata on the screener**: `fb.screener.congress_house()` and `fb.screener.congress_senate()` rows (sync and async) now carry `amountRaw` and `amountFlag`, matching the ticker-level endpoints since 0.2.8. On rows whose `amount` was normalized to its STOCK Act bracket, `amountRaw` preserves the string as originally filed; `amountFlag` is `review` or `ambiguous` when the filed amount could not be safely normalized; both are `null` on clean rows. The fields are emitted by the v2 API and pass through both the raw-dict and DataFrame branches with no SDK code changes; docstrings, README, unit tests and integration tests now cover them
16
+
17
+ ### Changed
18
+
19
+ - **DataFrame shape**: the congress screener frames gain `amountRaw` and `amountFlag` columns. Code that asserts an exact column set (`set(df.columns) == {...}`) or compares frames for equality needs updating
20
+
21
+ ### Fixed
22
+
23
+ - **App-ratings chart with a mismatched store**: passing an iOS `app_id` with `store="play"` (or the reverse) relabelled that app's series as the other platform's and plotted it. It now raises, naming the store the app actually lives on
24
+
25
+ ### Notes
26
+
27
+ - Also carries the congressional screener changes written up as 0.2.10 on 2026-08-26, which were never tagged or published: PyPI goes from 0.2.9 straight to this release
28
+ - Purely additive: `per_app=False` remains the default and the blended frame is byte-for-byte unchanged. An API deployment predating `apps[]` yields an empty per-app frame rather than an error, so the SDK can ship before or after the API
29
+ - The raw-dict branch is purely additive — no call-site changes are required to receive the new fields
30
+
31
+ ## [0.2.9] - 2026-08-14
32
+
33
+ ### Added
34
+
35
+ - **`cik` field on four datasets**: rows from `fb.insider_transactions.ticker()`, `fb.government_contracts.ticker()`, `fb.corporate_lobbying.ticker()`, and `fb.patent_filings.ticker()` (and their async equivalents) now carry `cik` — the SEC Central Index Key of the company as of that record, as a 10-digit zero-padded **string** (`"0000320193"`); `null` where the record has no entity resolution. The field is emitted by the v2 API and passes through both the raw-dict and DataFrame branches with no SDK code changes; tests pin the passthrough (including that the DataFrame column stays string-typed — leading zeros are data)
36
+ - **Documentation**: README "Company identifier (`cik`)" section covering the field, its string typing, the null case, and its use for joining to SEC-keyed datasets
37
+
38
+ ### Changed
39
+
40
+ - **DataFrame shape**: `as_dataframe=True` frames for the four datasets above gain a `cik` column. Code that asserts an exact column set needs updating
41
+
8
42
  ## [0.2.8] - 2026-07-28
9
43
 
10
44
  ### Added
@@ -20,7 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
20
54
 
21
55
  ### Notes
22
56
 
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
57
+ - `owner` and `disclosureDate` are nullable, but nulls are rare in practice: the pipeline's key-hygiene reconcile upload backfilled both fields onto historical rows in place. Code should still handle missing values with `pandas.isna()` — the `.dropna()` caveat from 0.2.6 applies to any row a reconcile could not fill
24
58
  - The raw-dict branch is purely additive — no call-site changes are required to receive the new fields
25
59
 
26
60
  ## [0.2.7] - 2026-07-24
@@ -233,6 +267,7 @@ Previous releases...
233
267
 
234
268
  Previous releases...
235
269
 
270
+ [0.3.0]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.2.9...v0.3.0
236
271
  [0.2.1]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.2.0...v0.2.1
237
272
  [0.2.0]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.1.8...v0.2.0
238
273
  [0.1.8]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.1.7...v0.1.8
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: finbrain-python
3
- Version: 0.2.8
3
+ Version: 0.3.0
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
@@ -77,6 +77,14 @@ fb.app_ratings.ticker("AMZN",
77
77
  date_to="2025-06-30",
78
78
  as_dataframe=True)
79
79
 
80
+ # One row per app per date instead of one blended row per date
81
+ # — see "App ratings: the per-app view" below.
82
+ fb.app_ratings.ticker("AMZN",
83
+ date_from="2025-01-01",
84
+ date_to="2025-06-30",
85
+ as_dataframe=True,
86
+ per_app=True)
87
+
80
88
  # ---------- analyst ratings ----------
81
89
  fb.analyst_ratings.ticker("AMZN",
82
90
  date_from="2025-01-01",
@@ -192,14 +200,35 @@ kept as filed. A filing with no usable amount at all reports `amount` as
192
200
  column blank report `owner` as `UNKNOWN`; House filings that leave it blank
193
201
  report `SELF`, per the House PTR-form instructions.
194
202
 
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.
203
+ `disclosureDate` and `owner` are nullable. Historical rows were backfilled
204
+ in place by the pipeline's reconcile upload, so nulls are rare — but code
205
+ should still handle them. With `as_dataframe=True`, `date` is the **index**
206
+ and the other fields are columns whose missing values read as `None` or
207
+ `NaN` depending on your pandas version — test them with `pandas.isna()`
208
+ rather than `is None`. Note that `.dropna()` on such a frame will discard
209
+ every row with any missing field — use `.dropna(subset=[...])`.
210
+ All four fields — `owner`, `amountRaw`, `amountFlag` and `disclosureDate` —
211
+ are also present on `fb.screener.congress_house()` and
212
+ `fb.screener.congress_senate()` rows.
213
+
214
+ ### Company identifier (`cik`)
215
+
216
+ Rows from the four SEC/government datasets — `fb.insider_transactions`,
217
+ `fb.government_contracts`, `fb.corporate_lobbying`, and `fb.patent_filings`
218
+ (ticker endpoints and their async equivalents) — carry `cik`, the SEC
219
+ **Central Index Key** of the company as of that record:
220
+
221
+ | Field | Meaning |
222
+ | ----- | ------------------------------------------------------------------------------------------- |
223
+ | `cik` | SEC Central Index Key of the company, as a 10-digit zero-padded string (`"0000320193"`) |
224
+
225
+ `cik` is a **string, not a number** — the leading zeros are part of the
226
+ identifier, so keep the column as text when loading into other tools. Rows
227
+ without an entity resolution (for example, records of companies absent from
228
+ the SEC's public company file) carry `null`; with `as_dataframe=True` the
229
+ column stays object-typed and missing values read as `None`. Use it to join
230
+ FinBrain rows to SEC-keyed datasets (EDGAR filings, financial statements,
231
+ 13F holdings) or to your own security master.
203
232
 
204
233
  `date_from` / `date_to` bound the **transaction** date, not the disclosure
205
234
  date — a trade executed inside the window is returned even if it was disclosed
@@ -220,6 +249,55 @@ own = [
220
249
  ]
221
250
  ```
222
251
 
252
+ ### App ratings: the per-app view (`per_app=True`)
253
+
254
+ A company can publish many apps — Apple has 140 on iOS. The default frame
255
+ reports **one row per date**, carrying the company's biggest app on each
256
+ store, so a portfolio collapses to two numbers. `per_app=True` returns the
257
+ granular alternative: one row per app per observation, with no blending and no
258
+ derived company score, so you decide which apps matter and how to weight them.
259
+
260
+ ```python
261
+ apps = fb.app_ratings.ticker(
262
+ "AMZN",
263
+ date_from="2025-01-01",
264
+ date_to="2025-06-30",
265
+ as_dataframe=True,
266
+ per_app=True,
267
+ )
268
+
269
+ apps.columns
270
+ # ['date', 'platform', 'app_id', 'app_name',
271
+ # 'score', 'ratings_count', 'install_count']
272
+
273
+ # Which apps exist, and how big each is
274
+ apps.groupby(["platform", "app_id", "app_name"])["ratings_count"].max()
275
+
276
+ # One app's own series
277
+ apps[apps["app_id"] == "com.amazon.mShop.android.shopping"]
278
+ ```
279
+
280
+ | Column | Meaning |
281
+ | --------------- | ---------------------------------------------------------------- |
282
+ | `platform` | `ios` or `android` |
283
+ | `app_id` | App Store numeric id or Play package name; `null` — see below |
284
+ | `app_name` | App title as published on the store |
285
+ | `score` | Average rating, 0–5 |
286
+ | `ratings_count` | Number of ratings |
287
+ | `install_count` | Play Store only — Apple publishes no install count, so `null` on `ios` |
288
+
289
+ Three things to know:
290
+
291
+ - **Not indexed by date.** A single date carries one row per app, so a date
292
+ index would not be unique. The blended frame (`per_app=False`, the default)
293
+ is still indexed by `date` and is unchanged.
294
+ - **`app_id` is `null` on older observations**, collected before the API keyed
295
+ rows per app. Those rows carry the platform but not the app identity — we
296
+ know the store, not which app produced the number. Filter them with
297
+ `apps["app_id"].notna()` if you need identified apps only.
298
+ - **Purely additive.** `per_app=False` behaviour is untouched, and an API that
299
+ predates the per-app view returns an empty frame rather than an error.
300
+
223
301
  ## ⚡ Async Usage
224
302
 
225
303
  For async/await support, install with the `async` extra:
@@ -276,6 +354,14 @@ fb.plot.app_ratings("AMZN",
276
354
  date_from="2025-01-01",
277
355
  date_to="2025-06-30")
278
356
 
357
+ # Chart one specific app rather than the company's biggest on that store.
358
+ # Ids come from the per_app frame; the app must live on the store you pass.
359
+ fb.plot.app_ratings("AMZN",
360
+ store="play",
361
+ app_id="com.amazon.mShop.android.shopping",
362
+ date_from="2025-01-01",
363
+ date_to="2025-06-30")
364
+
279
365
  # ---------- LinkedIn Metrics Chart ----------
280
366
  fb.plot.linkedin("AMZN",
281
367
  date_from="2025-01-01",
@@ -49,6 +49,14 @@ fb.app_ratings.ticker("AMZN",
49
49
  date_to="2025-06-30",
50
50
  as_dataframe=True)
51
51
 
52
+ # One row per app per date instead of one blended row per date
53
+ # — see "App ratings: the per-app view" below.
54
+ fb.app_ratings.ticker("AMZN",
55
+ date_from="2025-01-01",
56
+ date_to="2025-06-30",
57
+ as_dataframe=True,
58
+ per_app=True)
59
+
52
60
  # ---------- analyst ratings ----------
53
61
  fb.analyst_ratings.ticker("AMZN",
54
62
  date_from="2025-01-01",
@@ -164,14 +172,35 @@ kept as filed. A filing with no usable amount at all reports `amount` as
164
172
  column blank report `owner` as `UNKNOWN`; House filings that leave it blank
165
173
  report `SELF`, per the House PTR-form instructions.
166
174
 
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.
175
+ `disclosureDate` and `owner` are nullable. Historical rows were backfilled
176
+ in place by the pipeline's reconcile upload, so nulls are rare — but code
177
+ should still handle them. With `as_dataframe=True`, `date` is the **index**
178
+ and the other fields are columns whose missing values read as `None` or
179
+ `NaN` depending on your pandas version — test them with `pandas.isna()`
180
+ rather than `is None`. Note that `.dropna()` on such a frame will discard
181
+ every row with any missing field — use `.dropna(subset=[...])`.
182
+ All four fields — `owner`, `amountRaw`, `amountFlag` and `disclosureDate` —
183
+ are also present on `fb.screener.congress_house()` and
184
+ `fb.screener.congress_senate()` rows.
185
+
186
+ ### Company identifier (`cik`)
187
+
188
+ Rows from the four SEC/government datasets — `fb.insider_transactions`,
189
+ `fb.government_contracts`, `fb.corporate_lobbying`, and `fb.patent_filings`
190
+ (ticker endpoints and their async equivalents) — carry `cik`, the SEC
191
+ **Central Index Key** of the company as of that record:
192
+
193
+ | Field | Meaning |
194
+ | ----- | ------------------------------------------------------------------------------------------- |
195
+ | `cik` | SEC Central Index Key of the company, as a 10-digit zero-padded string (`"0000320193"`) |
196
+
197
+ `cik` is a **string, not a number** — the leading zeros are part of the
198
+ identifier, so keep the column as text when loading into other tools. Rows
199
+ without an entity resolution (for example, records of companies absent from
200
+ the SEC's public company file) carry `null`; with `as_dataframe=True` the
201
+ column stays object-typed and missing values read as `None`. Use it to join
202
+ FinBrain rows to SEC-keyed datasets (EDGAR filings, financial statements,
203
+ 13F holdings) or to your own security master.
175
204
 
176
205
  `date_from` / `date_to` bound the **transaction** date, not the disclosure
177
206
  date — a trade executed inside the window is returned even if it was disclosed
@@ -192,6 +221,55 @@ own = [
192
221
  ]
193
222
  ```
194
223
 
224
+ ### App ratings: the per-app view (`per_app=True`)
225
+
226
+ A company can publish many apps — Apple has 140 on iOS. The default frame
227
+ reports **one row per date**, carrying the company's biggest app on each
228
+ store, so a portfolio collapses to two numbers. `per_app=True` returns the
229
+ granular alternative: one row per app per observation, with no blending and no
230
+ derived company score, so you decide which apps matter and how to weight them.
231
+
232
+ ```python
233
+ apps = fb.app_ratings.ticker(
234
+ "AMZN",
235
+ date_from="2025-01-01",
236
+ date_to="2025-06-30",
237
+ as_dataframe=True,
238
+ per_app=True,
239
+ )
240
+
241
+ apps.columns
242
+ # ['date', 'platform', 'app_id', 'app_name',
243
+ # 'score', 'ratings_count', 'install_count']
244
+
245
+ # Which apps exist, and how big each is
246
+ apps.groupby(["platform", "app_id", "app_name"])["ratings_count"].max()
247
+
248
+ # One app's own series
249
+ apps[apps["app_id"] == "com.amazon.mShop.android.shopping"]
250
+ ```
251
+
252
+ | Column | Meaning |
253
+ | --------------- | ---------------------------------------------------------------- |
254
+ | `platform` | `ios` or `android` |
255
+ | `app_id` | App Store numeric id or Play package name; `null` — see below |
256
+ | `app_name` | App title as published on the store |
257
+ | `score` | Average rating, 0–5 |
258
+ | `ratings_count` | Number of ratings |
259
+ | `install_count` | Play Store only — Apple publishes no install count, so `null` on `ios` |
260
+
261
+ Three things to know:
262
+
263
+ - **Not indexed by date.** A single date carries one row per app, so a date
264
+ index would not be unique. The blended frame (`per_app=False`, the default)
265
+ is still indexed by `date` and is unchanged.
266
+ - **`app_id` is `null` on older observations**, collected before the API keyed
267
+ rows per app. Those rows carry the platform but not the app identity — we
268
+ know the store, not which app produced the number. Filter them with
269
+ `apps["app_id"].notna()` if you need identified apps only.
270
+ - **Purely additive.** `per_app=False` behaviour is untouched, and an API that
271
+ predates the per-app view returns an empty frame rather than an error.
272
+
195
273
  ## ⚡ Async Usage
196
274
 
197
275
  For async/await support, install with the `async` extra:
@@ -248,6 +326,14 @@ fb.plot.app_ratings("AMZN",
248
326
  date_from="2025-01-01",
249
327
  date_to="2025-06-30")
250
328
 
329
+ # Chart one specific app rather than the company's biggest on that store.
330
+ # Ids come from the per_app frame; the app must live on the store you pass.
331
+ fb.plot.app_ratings("AMZN",
332
+ store="play",
333
+ app_id="com.amazon.mShop.android.shopping",
334
+ date_from="2025-01-01",
335
+ date_to="2025-06-30")
336
+
251
337
  # ---------- LinkedIn Metrics Chart ----------
252
338
  fb.plot.linkedin("AMZN",
253
339
  date_from="2025-01-01",
@@ -26,6 +26,25 @@ def _flatten_app_ratings(rows: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
26
26
  return flat
27
27
 
28
28
 
29
+ def _flatten_apps(apps: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
30
+ """One row per app per observation — see the sync endpoint for the rationale."""
31
+ flat: List[Dict[str, Any]] = []
32
+ for app in apps or []:
33
+ for obs in app.get("observations") or []:
34
+ flat.append(
35
+ {
36
+ "date": obs.get("date"),
37
+ "platform": app.get("platform"),
38
+ "app_id": app.get("appId"),
39
+ "app_name": app.get("appName"),
40
+ "score": obs.get("score"),
41
+ "ratings_count": obs.get("ratingsCount"),
42
+ "install_count": obs.get("installCount"),
43
+ }
44
+ )
45
+ return flat
46
+
47
+
29
48
  class AsyncAppRatingsAPI:
30
49
  """Async wrapper for mobile-app rating analytics."""
31
50
 
@@ -40,8 +59,15 @@ class AsyncAppRatingsAPI:
40
59
  date_to: _dt.date | str | None = None,
41
60
  limit: int | None = None,
42
61
  as_dataframe: bool = False,
62
+ per_app: bool = False,
43
63
  ) -> Dict[str, Any] | pd.DataFrame:
44
- """Fetch mobile-app ratings for a symbol (async)."""
64
+ """Fetch mobile-app ratings for a symbol (async).
65
+
66
+ ``per_app=True`` returns the granular frame — one row per app per
67
+ observation — instead of the blended per-date view. A company can
68
+ publish many apps, so the blended view necessarily reports only its
69
+ biggest on each platform.
70
+ """
45
71
  params: Dict[str, str] = {}
46
72
 
47
73
  if date_from:
@@ -55,6 +81,16 @@ class AsyncAppRatingsAPI:
55
81
  data = await self._c._request("GET", path, params=params)
56
82
 
57
83
  if as_dataframe:
84
+ if per_app:
85
+ flat = _flatten_apps(data.get("apps") or [])
86
+ df = pd.DataFrame(flat)
87
+ if not df.empty and "date" in df.columns:
88
+ df["date"] = pd.to_datetime(df["date"])
89
+ # Not indexed by date: a date repeats across apps.
90
+ df.sort_values(["app_id", "date"], inplace=True)
91
+ df.reset_index(drop=True, inplace=True)
92
+ return df
93
+
58
94
  rows: List[Dict[str, Any]] = data.get("data", [])
59
95
  flat = _flatten_app_ratings(rows)
60
96
  df = pd.DataFrame(flat)
@@ -41,9 +41,9 @@ class AsyncHouseTradesAPI:
41
41
  bracket; ``amountFlag`` is ``"review"`` or ``"ambiguous"`` when the
42
42
  amount could not be safely normalized (``None`` otherwise).
43
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``).
44
+ ``disclosureDate`` and ``owner`` are nullable; historical rows were
45
+ backfilled upstream, so missing values are rare but possible (``NaN``
46
+ in the DataFrame branch on newer pandas — use ``pandas.isna``).
47
47
 
48
48
  ``date_from``/``date_to`` bound the transaction date, not the
49
49
  disclosure date.
@@ -113,8 +113,13 @@ class AsyncScreenerAPI:
113
113
  Rows carry ``symbol``, ``name``, ``date``, ``politician``,
114
114
  ``transactionType``, ``amount``, ``owner`` (beneficial owner of the
115
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
+ code), ``amountRaw``, ``amountFlag`` and ``disclosureDate`` (the
117
+ public disclosure date). On rows whose ``amount`` was normalized to
118
+ its STOCK Act bracket, ``amountRaw`` preserves the string as
119
+ originally filed; ``amountFlag`` is ``"review"`` or ``"ambiguous"``
120
+ when the filed amount could not be safely normalized. Both are
121
+ ``None`` on clean rows. ``owner`` and ``disclosureDate`` are
122
+ nullable, though rare — historical rows were backfilled upstream.
118
123
  """
119
124
  params = self._build_params(limit=limit)
120
125
  return await self._get("screener/congress/house", params, as_dataframe)
@@ -133,9 +138,14 @@ class AsyncScreenerAPI:
133
138
  Rows carry ``symbol``, ``name``, ``date``, ``politician``,
134
139
  ``transactionType``, ``amount``, ``owner`` (beneficial owner of the
135
140
  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.
141
+ or ``"UNKNOWN"`` for blank Senate filings), ``amountRaw``,
142
+ ``amountFlag`` and ``disclosureDate`` (the public disclosure date).
143
+ On rows whose ``amount`` was normalized to its STOCK Act bracket,
144
+ ``amountRaw`` preserves the string as originally filed;
145
+ ``amountFlag`` is ``"review"`` or ``"ambiguous"`` when the filed
146
+ amount could not be safely normalized. Both are ``None`` on clean
147
+ rows. ``owner`` and ``disclosureDate`` are nullable, though rare —
148
+ historical rows were backfilled upstream.
139
149
  """
140
150
  params = self._build_params(limit=limit)
141
151
  return await self._get("screener/congress/senate", params, as_dataframe)
@@ -41,9 +41,9 @@ class AsyncSenateTradesAPI:
41
41
  bracket; ``amountFlag`` is ``"review"`` or ``"ambiguous"`` when the
42
42
  amount could not be safely normalized (``None`` otherwise).
43
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``).
44
+ ``disclosureDate`` and ``owner`` are nullable; historical rows were
45
+ backfilled upstream, so missing values are rare but possible (``NaN``
46
+ in the DataFrame branch on newer pandas — use ``pandas.isna``).
47
47
 
48
48
  ``date_from``/``date_to`` bound the transaction date, not the
49
49
  disclosure date.
@@ -44,6 +44,48 @@ def _flatten_app_ratings(rows: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
44
44
  return flat
45
45
 
46
46
 
47
+ def _flatten_apps(apps: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
48
+ """
49
+ Flatten the per-app series into one row per app per observation.
50
+
51
+ A company can publish many apps — Apple has 140 on iOS — so the blended
52
+ ``data`` view necessarily reports one per platform. This is the granular
53
+ alternative: no blending and no derived company score, one row per
54
+ (app, date), so callers weight or filter for themselves.
55
+
56
+ ``app_id`` is ``None`` for observations predating the API keying rows per
57
+ app: the platform is known, the app is not.
58
+
59
+ Input format per app::
60
+
61
+ {
62
+ "platform": "ios",
63
+ "appId": "1108187390",
64
+ "appName": "Apple Music",
65
+ "observations": [
66
+ {"date": "2026-09-01", "score": 4.86,
67
+ "ratingsCount": 3074796, "installCount": None},
68
+ ...
69
+ ],
70
+ }
71
+ """
72
+ flat: List[Dict[str, Any]] = []
73
+ for app in apps or []:
74
+ for obs in app.get("observations") or []:
75
+ flat.append(
76
+ {
77
+ "date": obs.get("date"),
78
+ "platform": app.get("platform"),
79
+ "app_id": app.get("appId"),
80
+ "app_name": app.get("appName"),
81
+ "score": obs.get("score"),
82
+ "ratings_count": obs.get("ratingsCount"),
83
+ "install_count": obs.get("installCount"),
84
+ }
85
+ )
86
+ return flat
87
+
88
+
47
89
  class AppRatingsAPI:
48
90
  """
49
91
  Mobile-app rating analytics for a single ticker.
@@ -77,6 +119,7 @@ class AppRatingsAPI:
77
119
  date_to: _dt.date | str | None = None,
78
120
  limit: int | None = None,
79
121
  as_dataframe: bool = False,
122
+ per_app: bool = False,
80
123
  ) -> Dict[str, Any] | pd.DataFrame:
81
124
  """
82
125
  Fetch mobile-app ratings for *symbol*.
@@ -90,9 +133,20 @@ class AppRatingsAPI:
90
133
  limit :
91
134
  Maximum number of records to return.
92
135
  as_dataframe :
93
- If *True*, return a **pandas.DataFrame** indexed by ``date``
94
- with flattened columns (``ios_score``, ``android_score``, etc.);
95
- otherwise return the raw JSON dict.
136
+ If *True*, return a **pandas.DataFrame**; otherwise the raw JSON
137
+ dict, which carries both views.
138
+ per_app :
139
+ Only meaningful with ``as_dataframe``. If *True*, return the
140
+ granular frame — one row per app per observation, with
141
+ ``platform``, ``app_id``, ``app_name``, ``score``,
142
+ ``ratings_count`` and ``install_count``, **not** indexed by date
143
+ since a date repeats across apps. If *False* (default), return the
144
+ blended per-date frame indexed by ``date``, which reports the
145
+ company's biggest app on each platform.
146
+
147
+ Prefer ``per_app=True`` for anything quantitative: a company can
148
+ publish many apps (Apple has 140 on iOS) and which of them matters
149
+ is your judgement, not ours.
96
150
 
97
151
  Returns
98
152
  -------
@@ -111,6 +165,17 @@ class AppRatingsAPI:
111
165
  data = self._c._request("GET", path, params=params)
112
166
 
113
167
  if as_dataframe:
168
+ if per_app:
169
+ flat = _flatten_apps(data.get("apps") or [])
170
+ df = pd.DataFrame(flat)
171
+ if not df.empty and "date" in df.columns:
172
+ df["date"] = pd.to_datetime(df["date"])
173
+ # Deliberately NOT indexed by date: one date carries one
174
+ # row per app, so a date index would not be unique.
175
+ df.sort_values(["app_id", "date"], inplace=True)
176
+ df.reset_index(drop=True, inplace=True)
177
+ return df
178
+
114
179
  rows: List[Dict[str, Any]] = data.get("data", [])
115
180
  flat = _flatten_app_ratings(rows)
116
181
  df = pd.DataFrame(flat)
@@ -72,12 +72,12 @@ class HouseTradesAPI:
72
72
  or ``"ambiguous"``; on all other rows ``amountRaw`` and
73
73
  ``amountFlag`` are ``None``.
74
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`.
75
+ ``disclosureDate`` and ``owner`` are nullable; historical rows
76
+ were backfilled in place by the upstream pipeline, so missing
77
+ values are rare but possible. In the DataFrame branch ``date``
78
+ becomes the index and the remaining fields are columns whose
79
+ missing values read as ``None`` or ``NaN`` depending on the
80
+ pandas version — test them with :func:`pandas.isna`.
81
81
 
82
82
  Notes
83
83
  -----
@@ -118,8 +118,13 @@ class ScreenerAPI:
118
118
  Rows carry ``symbol``, ``name``, ``date``, ``politician``,
119
119
  ``transactionType``, ``amount``, ``owner`` (beneficial owner of the
120
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
+ code), ``amountRaw``, ``amountFlag`` and ``disclosureDate`` (the
122
+ public disclosure date). On rows whose ``amount`` was normalized to
123
+ its STOCK Act bracket, ``amountRaw`` preserves the string as
124
+ originally filed; ``amountFlag`` is ``"review"`` or ``"ambiguous"``
125
+ when the filed amount could not be safely normalized. Both are
126
+ ``None`` on clean rows. ``owner`` and ``disclosureDate`` are
127
+ nullable, though rare — historical rows were backfilled upstream.
123
128
  """
124
129
  params = self._build_params(limit=limit)
125
130
  return self._get("screener/congress/house", params, as_dataframe)
@@ -138,9 +143,14 @@ class ScreenerAPI:
138
143
  Rows carry ``symbol``, ``name``, ``date``, ``politician``,
139
144
  ``transactionType``, ``amount``, ``owner`` (beneficial owner of the
140
145
  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.
146
+ or ``"UNKNOWN"`` for blank Senate filings), ``amountRaw``,
147
+ ``amountFlag`` and ``disclosureDate`` (the public disclosure date).
148
+ On rows whose ``amount`` was normalized to its STOCK Act bracket,
149
+ ``amountRaw`` preserves the string as originally filed;
150
+ ``amountFlag`` is ``"review"`` or ``"ambiguous"`` when the filed
151
+ amount could not be safely normalized. Both are ``None`` on clean
152
+ rows. ``owner`` and ``disclosureDate`` are nullable, though rare —
153
+ historical rows were backfilled upstream.
144
154
  """
145
155
  params = self._build_params(limit=limit)
146
156
  return self._get("screener/congress/senate", params, as_dataframe)
@@ -71,12 +71,12 @@ class SenateTradesAPI:
71
71
  or ``"ambiguous"``; on all other rows ``amountRaw`` and
72
72
  ``amountFlag`` are ``None``.
73
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`.
74
+ ``disclosureDate`` and ``owner`` are nullable; historical rows
75
+ were backfilled in place by the upstream pipeline, so missing
76
+ values are rare but possible. In the DataFrame branch ``date``
77
+ becomes the index and the remaining fields are columns whose
78
+ missing values read as ``None`` or ``NaN`` depending on the
79
+ pandas version — test them with :func:`pandas.isna`.
80
80
 
81
81
  Notes
82
82
  -----