finbrain-python 0.2.9__tar.gz → 0.3.1__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 (94) hide show
  1. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/CHANGELOG.md +30 -0
  2. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/PKG-INFO +69 -3
  3. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/README.md +68 -2
  4. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/app_ratings.py +37 -1
  5. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/screener.py +15 -6
  6. finbrain_python-0.3.1/src/finbrain/endpoints/app_ratings.py +201 -0
  7. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/screener.py +15 -6
  8. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/plotting.py +70 -21
  9. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain_python.egg-info/PKG-INFO +69 -3
  10. finbrain_python-0.3.1/src/finbrain_python.egg-info/scm_version.json +8 -0
  11. finbrain_python-0.3.1/tests/test_app_ratings.py +271 -0
  12. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_integration.py +4 -0
  13. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_plotting.py +48 -0
  14. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_screener.py +30 -2
  15. finbrain_python-0.2.9/src/finbrain/endpoints/app_ratings.py +0 -122
  16. finbrain_python-0.2.9/src/finbrain_python.egg-info/scm_version.json +0 -8
  17. finbrain_python-0.2.9/tests/test_app_ratings.py +0 -81
  18. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/.gitattributes +0 -0
  19. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/.github/workflows/ci.yml +0 -0
  20. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/.github/workflows/release.yml +0 -0
  21. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/.gitignore +0 -0
  22. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/LICENSE +0 -0
  23. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/RELEASE.md +0 -0
  24. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/examples/async_example.py +0 -0
  25. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/examples/transactions_plotting_example.py +0 -0
  26. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/pyproject.toml +0 -0
  27. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/setup.cfg +0 -0
  28. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/__init__.py +0 -0
  29. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/__init__.py +0 -0
  30. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/client.py +0 -0
  31. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/__init__.py +0 -0
  32. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/_utils.py +0 -0
  33. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/analyst_ratings.py +0 -0
  34. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/available.py +0 -0
  35. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/corporate_lobbying.py +0 -0
  36. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/government_contracts.py +0 -0
  37. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/house_trades.py +0 -0
  38. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/insider_transactions.py +0 -0
  39. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/linkedin_data.py +0 -0
  40. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/news.py +0 -0
  41. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/options.py +0 -0
  42. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/patent_filings.py +0 -0
  43. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/predictions.py +0 -0
  44. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/recent.py +0 -0
  45. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/reddit_mentions.py +0 -0
  46. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/senate_trades.py +0 -0
  47. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/aio/endpoints/sentiments.py +0 -0
  48. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/client.py +0 -0
  49. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/__init__.py +0 -0
  50. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/_utils.py +0 -0
  51. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/analyst_ratings.py +0 -0
  52. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/available.py +0 -0
  53. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/corporate_lobbying.py +0 -0
  54. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/government_contracts.py +0 -0
  55. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/house_trades.py +0 -0
  56. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/insider_transactions.py +0 -0
  57. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/linkedin_data.py +0 -0
  58. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/news.py +0 -0
  59. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/options.py +0 -0
  60. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/patent_filings.py +0 -0
  61. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/predictions.py +0 -0
  62. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/recent.py +0 -0
  63. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/reddit_mentions.py +0 -0
  64. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/senate_trades.py +0 -0
  65. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/endpoints/sentiments.py +0 -0
  66. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/exceptions.py +0 -0
  67. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain/py.typed +0 -0
  68. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain_python.egg-info/SOURCES.txt +0 -0
  69. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain_python.egg-info/dependency_links.txt +0 -0
  70. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain_python.egg-info/requires.txt +0 -0
  71. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain_python.egg-info/scm_file_list.json +0 -0
  72. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/src/finbrain_python.egg-info/top_level.txt +0 -0
  73. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/__init__.py +0 -0
  74. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/conftest.py +0 -0
  75. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_analyst_ratings.py +0 -0
  76. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_async_client.py +0 -0
  77. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_available.py +0 -0
  78. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_cik_passthrough.py +0 -0
  79. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_client.py +0 -0
  80. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_corporate_lobbying.py +0 -0
  81. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_envelope.py +0 -0
  82. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_government_contracts.py +0 -0
  83. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_house_trades.py +0 -0
  84. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_insider_transactions.py +0 -0
  85. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_linkedin_data.py +0 -0
  86. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_news.py +0 -0
  87. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_options.py +0 -0
  88. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_patent_filings.py +0 -0
  89. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_predictions.py +0 -0
  90. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_recent.py +0 -0
  91. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_reddit_mentions.py +0 -0
  92. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_senate_trades.py +0 -0
  93. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_sentiments.py +0 -0
  94. {finbrain_python-0.2.9 → finbrain_python-0.3.1}/tests/test_utils.py +0 -0
@@ -5,6 +5,35 @@ 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.1] - 2026-09-07
9
+
10
+ ### Added
11
+
12
+ - **`cik` on app ratings**: the v2 API now carries the company's SEC Central Index Key on the app-ratings response, and both DataFrame branches expose it as a `cik` column (`per_app=True` and the blended view). It is one value per company, repeated down the frame, kept as a string because the leading zeros are part of the identifier, and `None` for an issuer with no SEC registration such as a non-US listing. The raw-dict branch carried it already, being a passthrough. A CIK survives what a symbol does not: renames (BK became BNY) and recycled symbols, so it is the key to join app ratings to the insider, lobbying, contracts and patents datasets
13
+
14
+ ## [0.3.0] - 2026-09-04
15
+
16
+ ### Added
17
+
18
+ - **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
19
+ - **`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
20
+ - **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
21
+ - **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
22
+
23
+ ### Changed
24
+
25
+ - **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
26
+
27
+ ### Fixed
28
+
29
+ - **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
30
+
31
+ ### Notes
32
+
33
+ - 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
34
+ - 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
35
+ - The raw-dict branch is purely additive — no call-site changes are required to receive the new fields
36
+
8
37
  ## [0.2.9] - 2026-08-14
9
38
 
10
39
  ### Added
@@ -244,6 +273,7 @@ Previous releases...
244
273
 
245
274
  Previous releases...
246
275
 
276
+ [0.3.0]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.2.9...v0.3.0
247
277
  [0.2.1]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.2.0...v0.2.1
248
278
  [0.2.0]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.1.8...v0.2.0
249
279
  [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.9
3
+ Version: 0.3.1
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",
@@ -199,8 +207,9 @@ and the other fields are columns whose missing values read as `None` or
199
207
  `NaN` depending on your pandas version — test them with `pandas.isna()`
200
208
  rather than `is None`. Note that `.dropna()` on such a frame will discard
201
209
  every row with any missing field — use `.dropna(subset=[...])`.
202
- `disclosureDate` and `owner` are also present on
203
- `fb.screener.congress_house()` and `fb.screener.congress_senate()` rows.
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.
204
213
 
205
214
  ### Company identifier (`cik`)
206
215
 
@@ -240,6 +249,55 @@ own = [
240
249
  ]
241
250
  ```
242
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
+
243
301
  ## ⚡ Async Usage
244
302
 
245
303
  For async/await support, install with the `async` extra:
@@ -296,6 +354,14 @@ fb.plot.app_ratings("AMZN",
296
354
  date_from="2025-01-01",
297
355
  date_to="2025-06-30")
298
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
+
299
365
  # ---------- LinkedIn Metrics Chart ----------
300
366
  fb.plot.linkedin("AMZN",
301
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",
@@ -171,8 +179,9 @@ and the other fields are columns whose missing values read as `None` or
171
179
  `NaN` depending on your pandas version — test them with `pandas.isna()`
172
180
  rather than `is None`. Note that `.dropna()` on such a frame will discard
173
181
  every row with any missing field — use `.dropna(subset=[...])`.
174
- `disclosureDate` and `owner` are also present on
175
- `fb.screener.congress_house()` and `fb.screener.congress_senate()` rows.
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.
176
185
 
177
186
  ### Company identifier (`cik`)
178
187
 
@@ -212,6 +221,55 @@ own = [
212
221
  ]
213
222
  ```
214
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
+
215
273
  ## ⚡ Async Usage
216
274
 
217
275
  For async/await support, install with the `async` extra:
@@ -268,6 +326,14 @@ fb.plot.app_ratings("AMZN",
268
326
  date_from="2025-01-01",
269
327
  date_to="2025-06-30")
270
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
+
271
337
  # ---------- LinkedIn Metrics Chart ----------
272
338
  fb.plot.linkedin("AMZN",
273
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)
@@ -113,9 +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 nullable, though rare — historical rows
118
- were backfilled upstream.
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.
119
123
  """
120
124
  params = self._build_params(limit=limit)
121
125
  return await self._get("screener/congress/house", params, as_dataframe)
@@ -134,9 +138,14 @@ class AsyncScreenerAPI:
134
138
  Rows carry ``symbol``, ``name``, ``date``, ``politician``,
135
139
  ``transactionType``, ``amount``, ``owner`` (beneficial owner of the
136
140
  account: ``"SELF"``, ``"SP"``, ``"DC"``, ``"JT"``, an account code,
137
- or ``"UNKNOWN"`` for blank Senate filings) and ``disclosureDate``
138
- (the public disclosure date). ``owner`` and ``disclosureDate`` are
139
- nullable, though rare — historical rows were backfilled upstream.
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.
140
149
  """
141
150
  params = self._build_params(limit=limit)
142
151
  return await self._get("screener/congress/senate", params, as_dataframe)
@@ -0,0 +1,201 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime as _dt
4
+ import pandas as pd
5
+ from typing import TYPE_CHECKING, Dict, Any, List
6
+
7
+ from ._utils import to_datestr
8
+
9
+ if TYPE_CHECKING: # imported only by static-type tools
10
+ from ..client import FinBrainClient
11
+
12
+
13
+ def _flatten_app_ratings(rows: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
14
+ """
15
+ Flatten nested app-rating records.
16
+
17
+ Input format per record::
18
+
19
+ {
20
+ "date": "2024-02-02",
21
+ "ios": {"score": 4.07, "ratingsCount": 88533},
22
+ "android": {"score": 3.75, "ratingsCount": 567996, "installCount": 1000000}
23
+ }
24
+
25
+ Output format per record::
26
+
27
+ {
28
+ "date": "2024-02-02",
29
+ "ios_score": 4.07,
30
+ "ios_ratingsCount": 88533,
31
+ "android_score": 3.75,
32
+ "android_ratingsCount": 567996,
33
+ "android_installCount": 1000000,
34
+ }
35
+ """
36
+ flat: List[Dict[str, Any]] = []
37
+ for row in rows:
38
+ rec: Dict[str, Any] = {"date": row.get("date")}
39
+ for platform in ("ios", "android"):
40
+ sub = row.get(platform, {}) or {}
41
+ for key, value in sub.items():
42
+ rec[f"{platform}_{key}"] = value
43
+ flat.append(rec)
44
+ return flat
45
+
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
+
89
+ class AppRatingsAPI:
90
+ """
91
+ Mobile-app rating analytics for a single ticker.
92
+
93
+ Example
94
+ -------
95
+ >>> fb.app_ratings.ticker(
96
+ ... symbol="AMZN",
97
+ ... date_from="2024-01-01",
98
+ ... date_to="2024-02-02",
99
+ ... )["data"][:1]
100
+ [
101
+ {
102
+ "date": "2024-02-02",
103
+ "ios": {"score": 4.07, "ratingsCount": 88533},
104
+ "android": {"score": 3.75, "ratingsCount": 567996, "installCount": null}
105
+ }
106
+ ]
107
+ """
108
+
109
+ # ------------------------------------------------------------------ #
110
+ def __init__(self, client: "FinBrainClient") -> None:
111
+ self._c = client
112
+
113
+ # ------------------------------------------------------------------ #
114
+ def ticker(
115
+ self,
116
+ symbol: str,
117
+ *,
118
+ date_from: _dt.date | str | None = None,
119
+ date_to: _dt.date | str | None = None,
120
+ limit: int | None = None,
121
+ as_dataframe: bool = False,
122
+ per_app: bool = False,
123
+ ) -> Dict[str, Any] | pd.DataFrame:
124
+ """
125
+ Fetch mobile-app ratings for *symbol*.
126
+
127
+ Parameters
128
+ ----------
129
+ symbol :
130
+ Ticker symbol, upper-cased before the request.
131
+ date_from, date_to :
132
+ Optional ISO dates (``YYYY-MM-DD``) to bound the range.
133
+ limit :
134
+ Maximum number of records to return.
135
+ as_dataframe :
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.
150
+
151
+ Either frame carries a ``cik`` column: the company's SEC Central
152
+ Index Key, a 10-digit zero-padded string (leading zeros are data),
153
+ ``None`` for an issuer with no SEC registration. It is one value
154
+ per company, repeated down the frame, so a frame can be joined to
155
+ the other FinBrain datasets on the entity rather than the symbol.
156
+
157
+ Returns
158
+ -------
159
+ dict | pandas.DataFrame
160
+ """
161
+ params: Dict[str, str] = {}
162
+
163
+ if date_from:
164
+ params["startDate"] = to_datestr(date_from)
165
+ if date_to:
166
+ params["endDate"] = to_datestr(date_to)
167
+ if limit is not None:
168
+ params["limit"] = str(limit)
169
+
170
+ path = f"app-ratings/{symbol.upper()}"
171
+ data = self._c._request("GET", path, params=params)
172
+
173
+ if as_dataframe:
174
+ # One value per company, so it is a constant column rather than a
175
+ # per-row field. Assigned after the flatten so the flatten stays a
176
+ # pure function of the rows it is given. Kept as an object column:
177
+ # a numeric dtype would eat the leading zeros.
178
+ cik = data.get("cik")
179
+
180
+ if per_app:
181
+ flat = _flatten_apps(data.get("apps") or [])
182
+ df = pd.DataFrame(flat)
183
+ if not df.empty and "date" in df.columns:
184
+ df["date"] = pd.to_datetime(df["date"])
185
+ # Deliberately NOT indexed by date: one date carries one
186
+ # row per app, so a date index would not be unique.
187
+ df.sort_values(["app_id", "date"], inplace=True)
188
+ df.reset_index(drop=True, inplace=True)
189
+ df["cik"] = cik
190
+ return df
191
+
192
+ rows: List[Dict[str, Any]] = data.get("data", [])
193
+ flat = _flatten_app_ratings(rows)
194
+ df = pd.DataFrame(flat)
195
+ if not df.empty and "date" in df.columns:
196
+ df["date"] = pd.to_datetime(df["date"])
197
+ df.set_index("date", inplace=True)
198
+ df["cik"] = cik
199
+ return df
200
+
201
+ return data
@@ -118,9 +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 nullable, though rare — historical rows
123
- were backfilled upstream.
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.
124
128
  """
125
129
  params = self._build_params(limit=limit)
126
130
  return self._get("screener/congress/house", params, as_dataframe)
@@ -139,9 +143,14 @@ class ScreenerAPI:
139
143
  Rows carry ``symbol``, ``name``, ``date``, ``politician``,
140
144
  ``transactionType``, ``amount``, ``owner`` (beneficial owner of the
141
145
  account: ``"SELF"``, ``"SP"``, ``"DC"``, ``"JT"``, an account code,
142
- or ``"UNKNOWN"`` for blank Senate filings) and ``disclosureDate``
143
- (the public disclosure date). ``owner`` and ``disclosureDate`` are
144
- nullable, though rare — historical rows were backfilled upstream.
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.
145
154
  """
146
155
  params = self._build_params(limit=limit)
147
156
  return self._get("screener/congress/senate", params, as_dataframe)