finbrain-python 0.2.8__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.
@@ -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
  -----
finbrain/plotting.py CHANGED
@@ -26,6 +26,7 @@ class _PlotNamespace:
26
26
  ticker: str,
27
27
  *,
28
28
  store: str = "play",
29
+ app_id: str | None = None,
29
30
  date_from: str | None = None,
30
31
  date_to: str | None = None,
31
32
  as_json: bool = False,
@@ -43,29 +44,76 @@ class _PlotNamespace:
43
44
  ----------
44
45
  store : {'play', 'app'}, default 'play'
45
46
  Which store to visualise.
47
+ app_id :
48
+ Plot one specific app rather than the company's biggest on that
49
+ store. A company can publish many apps — Apple has 140 on iOS —
50
+ and the default picks only the largest, so pass this when you care
51
+ about a particular one. Ids come from
52
+ ``fb.app_ratings.ticker(sym, as_dataframe=True, per_app=True)``.
46
53
  Other args/kwargs identical to the other plotting wrappers.
47
54
  """
55
+ s = store.lower()
56
+ if s in ("play", "playstore", "google", "android"):
57
+ platform = "android"
58
+ elif s in ("app", "appstore", "apple", "ios"):
59
+ platform = "ios"
60
+ else:
61
+ raise ValueError("store must be 'play' or 'app'")
62
+
48
63
  # 1) pull data
49
- df: pd.DataFrame = self._fb.app_ratings.ticker(
50
- ticker,
51
- date_from=date_from,
52
- date_to=date_to,
53
- as_dataframe=True,
54
- **kwargs,
55
- )
64
+ df: pd.DataFrame
65
+ if app_id is not None:
66
+ per_app: pd.DataFrame = self._fb.app_ratings.ticker(
67
+ ticker,
68
+ date_from=date_from,
69
+ date_to=date_to,
70
+ as_dataframe=True,
71
+ per_app=True,
72
+ **kwargs,
73
+ )
74
+ if per_app.empty or "app_id" not in per_app.columns:
75
+ raise ValueError(f"no per-app data available for {ticker}")
76
+ subset = per_app[per_app["app_id"] == app_id]
77
+ if subset.empty:
78
+ available = sorted({a for a in per_app["app_id"].dropna().unique()})
79
+ raise ValueError(
80
+ f"app_id {app_id!r} not found for {ticker}; available: {available}"
81
+ )
82
+ # An app lives on one store. Without this check, asking for an
83
+ # iOS app with store="play" would relabel its series as Android
84
+ # and plot it, which is worse than refusing.
85
+ app_platforms = set(subset["platform"].dropna().unique())
86
+ if app_platforms and platform not in app_platforms:
87
+ raise ValueError(
88
+ f"app_id {app_id!r} is on {'/'.join(sorted(app_platforms))}, "
89
+ f"but store={store!r} plots {platform}"
90
+ )
91
+
92
+ # Reshape to the column names the plotting code below expects.
93
+ df = subset.set_index("date").rename(
94
+ columns={
95
+ "score": f"{platform}_score",
96
+ "ratings_count": f"{platform}_ratingsCount",
97
+ "install_count": f"{platform}_installCount",
98
+ }
99
+ )
100
+ else:
101
+ df = self._fb.app_ratings.ticker(
102
+ ticker,
103
+ date_from=date_from,
104
+ date_to=date_to,
105
+ as_dataframe=True,
106
+ **kwargs,
107
+ )
56
108
 
57
109
  # 2) pick columns & colours
58
- s = store.lower()
59
- if s in ("play", "playstore", "google", "android"):
110
+ if platform == "android":
60
111
  count_col, score_col = "android_ratingsCount", "android_score"
61
112
  count_name, score_name = "Android Ratings Count", "Android Score"
62
- count_color, score_color = "rgba(0,190,0,0.65)", "#02d2ff"
63
- elif s in ("app", "appstore", "apple", "ios"):
113
+ else:
64
114
  count_col, score_col = "ios_ratingsCount", "ios_score"
65
115
  count_name, score_name = "iOS Ratings Count", "iOS Score"
66
- count_color, score_color = "rgba(0,190,0,0.65)", "#02d2ff"
67
- else:
68
- raise ValueError("store must be 'play' or 'app'")
116
+ count_color, score_color = "rgba(0,190,0,0.65)", "#02d2ff"
69
117
 
70
118
  # 3) dynamic axis ranges
71
119
  max_cnt = float(df[count_col].max())
@@ -912,9 +960,7 @@ class _PlotNamespace:
912
960
  mentions_normalized = self._to_naive_index(mentions_df)
913
961
 
914
962
  # Exclude _all (aggregate) — use individual subreddits for stacked bars
915
- per_sub = mentions_normalized[
916
- mentions_normalized["subreddit"] != "_all"
917
- ]
963
+ per_sub = mentions_normalized[mentions_normalized["subreddit"] != "_all"]
918
964
 
919
965
  if not per_sub.empty:
920
966
  for subreddit in sorted(per_sub["subreddit"].unique()):
@@ -1010,7 +1056,9 @@ class _PlotNamespace:
1010
1056
  latest[sym] = row
1011
1057
 
1012
1058
  # Sort by totalMentions descending, take top N
1013
- ranked = sorted(latest.values(), key=lambda r: r.get("totalMentions", 0), reverse=True)
1059
+ ranked = sorted(
1060
+ latest.values(), key=lambda r: r.get("totalMentions", 0), reverse=True
1061
+ )
1014
1062
  top = ranked[:top_n]
1015
1063
 
1016
1064
  # Reverse so the highest-mentioned ticker is at the top of the chart
@@ -1406,7 +1454,9 @@ class _PlotNamespace:
1406
1454
  """Nearest available price for a rating date."""
1407
1455
  if when in price_data_normalized.index:
1408
1456
  return price_data_normalized.loc[when, price_col]
1409
- idx = price_data_normalized.index.get_indexer([when], method="nearest")[0]
1457
+ idx = price_data_normalized.index.get_indexer([when], method="nearest")[
1458
+ 0
1459
+ ]
1410
1460
  if 0 <= idx < len(price_data_normalized):
1411
1461
  return price_data_normalized.iloc[idx][price_col]
1412
1462
  return None
@@ -1434,8 +1484,7 @@ class _PlotNamespace:
1434
1484
 
1435
1485
  # Bucket each rating row by action category
1436
1486
  buckets: dict[str, dict[str, list]] = {
1437
- key: {"x": [], "y": [], "symbol": [], "hover": []}
1438
- for key in categories
1487
+ key: {"x": [], "y": [], "symbol": [], "hover": []} for key in categories
1439
1488
  }
1440
1489
 
1441
1490
  for pos, (when, row) in enumerate(ratings_normalized.iterrows()):
@@ -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",
@@ -1,18 +1,18 @@
1
1
  finbrain/__init__.py,sha256=ULIgwHkWbj5sT0udC3SlTROhZCgm2y9BtPox-4joNn4,416
2
2
  finbrain/client.py,sha256=iu39iTUSPmiBcB-7gEJMvxHtkHXDSRVfq03Grw9UOVY,5850
3
3
  finbrain/exceptions.py,sha256=xgn1UMirprJDhBNUVjxJUMfqKxHdFoBmkvCw3Hb5CH0,7019
4
- finbrain/plotting.py,sha256=gvw2PuFwOy0vg3GRSfaQb5sSl6SdKH1zhY5USPShtn4,60606
4
+ finbrain/plotting.py,sha256=DPYVDAjox7-JdoHri_jxkdvmbIPWXJ8Apiuxn3pzktg,62772
5
5
  finbrain/py.typed,sha256=INFR1qO3jdMrtVPs0N0SAVKVbjKV80HQPoPshwGEpGo,27
6
6
  finbrain/aio/__init__.py,sha256=eJra9SqvLMkq5zoZfG6WFw7kd1jGpf9l-ovuPMeWvdw,125
7
7
  finbrain/aio/client.py,sha256=I5oMft5T-ttBRw31-qFItlYPdIzj0qG30pNx0_SHXNA,7367
8
8
  finbrain/aio/endpoints/__init__.py,sha256=zdNSU1jzvnK6JnHxrvb3ye9KFCkA86xDTu9bBzmwrEQ,48
9
9
  finbrain/aio/endpoints/_utils.py,sha256=yyritVvWL_boiHzgomY0_J3OHSr9CRr6Ihna-Chihfw,317
10
10
  finbrain/aio/endpoints/analyst_ratings.py,sha256=IYG-PU8HDOZoyyMcb_2KRxhiMVicYyaU_TOCVZPWroo,1451
11
- finbrain/aio/endpoints/app_ratings.py,sha256=QrJoLc7roTPRfInAEMwlr9vtxzruFJulGdB6msz7Eg0,2177
11
+ finbrain/aio/endpoints/app_ratings.py,sha256=wPiUwvaJWwi9ytvGQNDyYSi8kI1X7_qOnJH8DRs12yY,3683
12
12
  finbrain/aio/endpoints/available.py,sha256=rQuffHowNF7FrVV5Ds-KE5iFjdz0I_vD7Qk2_zY2WLo,2315
13
13
  finbrain/aio/endpoints/corporate_lobbying.py,sha256=4rILB9-W91n6v2UwOnlVeH-ulk4D8onamzdEJf--wko,1429
14
14
  finbrain/aio/endpoints/government_contracts.py,sha256=-jKXMHWrdG-4PszBSTQpK-i4SHpVZufPDBABMDB56Gk,1540
15
- finbrain/aio/endpoints/house_trades.py,sha256=AfGV-tAJ4pSf8aARlD9PyeT6r0_KVgqMxFlX1BRnUnE,2581
15
+ finbrain/aio/endpoints/house_trades.py,sha256=0z9F2KvG2Virbz0bDugxKYyh56NcG2EH0qqr3dO0Op4,2602
16
16
  finbrain/aio/endpoints/insider_transactions.py,sha256=EBqHdvapYWvI53PM_sQy0caN2rbl7Qul4OmqzItMUR0,1437
17
17
  finbrain/aio/endpoints/linkedin_data.py,sha256=ucnkyNc1waiFHLxas1onPhxh9Y7ekcI_gOfUJ5gu1hI,1469
18
18
  finbrain/aio/endpoints/news.py,sha256=NJkcpoP8ngNsJdCzQab8yaXJzNe5ypYstzq3-mEHfqU,1446
@@ -21,17 +21,17 @@ finbrain/aio/endpoints/patent_filings.py,sha256=Wumihz2X7knKZNF36X9t0UJ8mk0ydg6H
21
21
  finbrain/aio/endpoints/predictions.py,sha256=BrUSmqy0v7ngXyoE_UHgqdght8qtJ8IRxAhk_s9UeR0,1285
22
22
  finbrain/aio/endpoints/recent.py,sha256=TSaAwf5w86O1plSmm4eg_gKSjSap2Z8rd2i7FAvgm90,2302
23
23
  finbrain/aio/endpoints/reddit_mentions.py,sha256=P9ToZRaRN521RJ9W2J8cBCySUsNT47ROe-8TTdVtlqA,1508
24
- finbrain/aio/endpoints/screener.py,sha256=Ngel0LWUrVH1liBn2QkxvBjQeUV7jake3LZYD4AQ2CE,11072
25
- finbrain/aio/endpoints/senate_trades.py,sha256=1SHgUzvVDhb7uh7xqUnDrTis5F-v6bBPNeW-hmJbfhI,2581
24
+ finbrain/aio/endpoints/screener.py,sha256=VdpS7wWApZpzjAdg3IfUb1k2RgsAF2d5-wups_Q_KaY,11810
25
+ finbrain/aio/endpoints/senate_trades.py,sha256=PVdp08M82fInANyUrLqrxvM8qY5QPisnN-THnORaexY,2602
26
26
  finbrain/aio/endpoints/sentiments.py,sha256=BXFT0jr5j0MnB65MXGxZK36BJLXMTuggkFF9A9eenEQ,1532
27
27
  finbrain/endpoints/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  finbrain/endpoints/_utils.py,sha256=wY8SKthpVernWlKwZfWoM8zZtQ3GS_hBQioH1Fk7RK4,1190
29
29
  finbrain/endpoints/analyst_ratings.py,sha256=6q_tecgnbzXn2wLSWqHNUa9MbLcybTD7xEBAkUyGPR0,2218
30
- finbrain/endpoints/app_ratings.py,sha256=mbeKiJ87nNibnz9AT2kmH4fVFA4goEcld910abm3tFs,3597
30
+ finbrain/endpoints/app_ratings.py,sha256=LQwikRaiJH85MzfAEOtFSgnLKsjzIVtHRyuwHWCqX3w,6287
31
31
  finbrain/endpoints/available.py,sha256=3cXjDK1qE38RHAfQ2C14oD7l7dR8mhDtUcva3LzlK5s,3911
32
32
  finbrain/endpoints/corporate_lobbying.py,sha256=K4jFcgx2_PqxFSlSm2E0rxuunl7FjWEwk_S4nfjsMuw,2213
33
33
  finbrain/endpoints/government_contracts.py,sha256=jb96byPNK32AsEQWgCHMU7kAue9BFC539TH10JGfY7I,2343
34
- finbrain/endpoints/house_trades.py,sha256=clXBd4OLu0xztlMTSpKbPk4PSs2kX0BEVu2OHXredf8,4521
34
+ finbrain/endpoints/house_trades.py,sha256=AeNeA37xV0juZUZn95-Qr9fa0N0aNLDZuTtlR8fJQgc,4558
35
35
  finbrain/endpoints/insider_transactions.py,sha256=TU6EsSHIeams4OLJ9s8BpNuXeBnWPHghlp4enqkEFe8,2244
36
36
  finbrain/endpoints/linkedin_data.py,sha256=zcNboQ-Ejt_7Ncu3p9WCd-PsjEBFbojVaJZdkbaGT8Q,2215
37
37
  finbrain/endpoints/news.py,sha256=q4aaEiunrUbl1FF0JZuX9__cZWxm2r1-B9x-c8g4Ia8,1913
@@ -40,11 +40,11 @@ finbrain/endpoints/patent_filings.py,sha256=496m-3lnGc3twMAdcIDOyMWs3KwHD2W8c_vz
40
40
  finbrain/endpoints/predictions.py,sha256=og1RY68p4O71smogrx-M5FyGk8FVclBGP18BvttzbZk,2026
41
41
  finbrain/endpoints/recent.py,sha256=7D36oVRJKF5hkR42y6M6CiEMYksuFleZou1v86SbEfA,3004
42
42
  finbrain/endpoints/reddit_mentions.py,sha256=WiePVAyUbA0VpWOd22M2YTlDWOQITp8qUBraI29y6d4,2305
43
- finbrain/endpoints/screener.py,sha256=Wn0uwR65PqUMwpNwhfmlgSMmgmdMUs5O9Y_Qyxv4ses,10966
44
- finbrain/endpoints/senate_trades.py,sha256=FBCu5LO7grjW74bS4p1ZnVORiIxpWN1pymHXmsIksmQ,4447
43
+ finbrain/endpoints/screener.py,sha256=vyay_g0OMfndmJc8UWBmxaHafp6grl7UqVdbMNTqJTc,11704
44
+ finbrain/endpoints/senate_trades.py,sha256=qtpuGe_M3dE2vVsol9R6bw1Xqt7XY2rHVrf6ElTc4wE,4484
45
45
  finbrain/endpoints/sentiments.py,sha256=sGGPaxzGGFvMOaYv3VSCmnG7H9v7OVlX7Vsndct8jhA,2606
46
- finbrain_python-0.2.8.dist-info/licenses/LICENSE,sha256=x71LjIUPbK7Y8YBulH_AXzEIX7BK90dgFL2zA6LBT-A,1069
47
- finbrain_python-0.2.8.dist-info/METADATA,sha256=96j6hjEnXA6KziFyO8F6_bpAa5QqP_zBU44Brw8VtiQ,20035
48
- finbrain_python-0.2.8.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
49
- finbrain_python-0.2.8.dist-info/top_level.txt,sha256=dCiQtTx3z2TtO_yQI6q3yODcdb-pABB-iEReJegVAv0,9
50
- finbrain_python-0.2.8.dist-info/RECORD,,
46
+ finbrain_python-0.3.0.dist-info/licenses/LICENSE,sha256=x71LjIUPbK7Y8YBulH_AXzEIX7BK90dgFL2zA6LBT-A,1069
47
+ finbrain_python-0.3.0.dist-info/METADATA,sha256=uyM_2pKGhMBmrdrvyVfk5vubu2G3_hhwtIBBY0mIdjY,24211
48
+ finbrain_python-0.3.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
49
+ finbrain_python-0.3.0.dist-info/top_level.txt,sha256=dCiQtTx3z2TtO_yQI6q3yODcdb-pABB-iEReJegVAv0,9
50
+ finbrain_python-0.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (83.0.0)
2
+ Generator: setuptools (84.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5