You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Docs/code_flow.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ flowchart TD
45
45
46
46
## 2. Background Full-Market Scan
47
47
48
-
`_run_background_scan` delegates entirely to `app.scan.run_scan()`. News is fetched once and reused across all 24 assets processed sequentially. Per-asset snapshots are saved via `analyse_asset(save=True)`.
48
+
`_run_background_scan` delegates entirely to `app.scan.run_scan()`. News is fetched once and reused across all 24 assets. A `price_cache` (`{ticker: change_1d}`) is pre-built via `fetch_all_metrics_parallel` before the loop, eliminating redundant yfinance calls during context analysis. Each asset is analysed with `with_market_ctx=True` and `save=True`.
|`articles`|`list[dict]`| — | Pre-fetched article pool |
312
312
|`with_market_ctx`|`bool`|`False`| Whether to run `analyse_market_context`|
313
313
|`save`|`bool`|`False`| Whether to persist a snapshot via `save_snapshot`. Only the batch scan pipeline passes `True`. |
314
+
|`price_cache`|`Optional[dict[str, float]]`|`None`| Pre-built `{ticker: change_1d}` map. Passed to `analyse_market_context` so peer/benchmark lookups are served from memory instead of making extra yfinance calls. Has no effect when `with_market_ctx=False`. |
314
315
315
316
Returns `dict`:
316
317
@@ -326,6 +327,7 @@ Returns `dict`:
326
327
|`signal`|`dict`| Output of `compute_signal_score`|
327
328
|`explanation`|`dict`| Output of `build_explanation`|
328
329
|`historical_features`|`dict`| Output of `storage.get_historical_features`|
Available for external use but not called by the dashboard directly. The dashboard heatmap and category overview use `cached_scan_summary()` in `dashboard/data.py`instead.
346
+
Called by `app/scan.py` during the batch pipeline to pre-build the `price_cache` before the per-asset loop (eliminating ~50–80 redundant yfinance calls). Also available for external use. The dashboard heatmap and category overview use `cached_scan_summary()` in `dashboard/data.py`rather than calling this directly.
345
347
346
348
---
347
349
@@ -509,8 +511,11 @@ These functions live in `dashboard/components.py`.
509
511
|`scan_time`|`str`| ISO datetime string of scan start |
510
512
|`total`|`int`| Total number of assets processed |
511
513
|`succeeded`|`int`| Number of assets that completed without error |
512
-
|`errors`|`list[dict]`| List of error dicts each with `asset`, `category`, `error` keys |
514
+
|`errors`|`list[dict]`| List of error dicts each with `asset`, `category`, `type`, `stage`, `message` keys |
0 commit comments