jopedro-finances-data 0.1.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 (23) hide show
  1. jopedro_finances_data-0.1.0/PKG-INFO +247 -0
  2. jopedro_finances_data-0.1.0/README.md +226 -0
  3. jopedro_finances_data-0.1.0/data/__init__.py +0 -0
  4. jopedro_finances_data-0.1.0/data/common/constants.py +92 -0
  5. jopedro_finances_data-0.1.0/data/models.py +338 -0
  6. jopedro_finances_data-0.1.0/finances_data/__init__.py +0 -0
  7. jopedro_finances_data-0.1.0/finances_data/just_etf/__init__.py +7 -0
  8. jopedro_finances_data-0.1.0/finances_data/just_etf/just_etf_client.py +541 -0
  9. jopedro_finances_data-0.1.0/finances_data/yahoo_finance/__init__.py +7 -0
  10. jopedro_finances_data-0.1.0/finances_data/yahoo_finance/yahoo_finance_client.py +277 -0
  11. jopedro_finances_data-0.1.0/jopedro_finances_data.egg-info/PKG-INFO +247 -0
  12. jopedro_finances_data-0.1.0/jopedro_finances_data.egg-info/SOURCES.txt +21 -0
  13. jopedro_finances_data-0.1.0/jopedro_finances_data.egg-info/dependency_links.txt +1 -0
  14. jopedro_finances_data-0.1.0/jopedro_finances_data.egg-info/requires.txt +15 -0
  15. jopedro_finances_data-0.1.0/jopedro_finances_data.egg-info/top_level.txt +2 -0
  16. jopedro_finances_data-0.1.0/pyproject.toml +74 -0
  17. jopedro_finances_data-0.1.0/setup.cfg +4 -0
  18. jopedro_finances_data-0.1.0/tests/test_integration.py +388 -0
  19. jopedro_finances_data-0.1.0/tests/test_just_etf.py +836 -0
  20. jopedro_finances_data-0.1.0/tests/test_models.py +218 -0
  21. jopedro_finances_data-0.1.0/tests/test_scripts.py +595 -0
  22. jopedro_finances_data-0.1.0/tests/test_validate_audit_sync.py +229 -0
  23. jopedro_finances_data-0.1.0/tests/test_yahoo_finance.py +317 -0
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: jopedro-finances-data
3
+ Version: 0.1.0
4
+ Summary: Finance data infrastructure clients
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: requests>=2.31
8
+ Requires-Dist: beautifulsoup4>=4.12
9
+ Requires-Dist: yfinance>=0.2
10
+ Requires-Dist: urllib3>=2.0
11
+ Requires-Dist: jopedro-core-lib>=0.3.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=7; extra == "dev"
14
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
15
+ Requires-Dist: ruff>=0.4; extra == "dev"
16
+ Requires-Dist: mypy>=1.10; extra == "dev"
17
+ Requires-Dist: types-requests>=2.28; extra == "dev"
18
+ Requires-Dist: types-beautifulsoup4>=4.12; extra == "dev"
19
+ Requires-Dist: python-dotenv>=1.0; extra == "dev"
20
+ Requires-Dist: google-genai>=0.1.1; extra == "dev"
21
+
22
+ # finances-data
23
+
24
+ ![Python 3.11+](https://img.shields.io/badge/python-3.11+-3776AB?style=flat-square&logo=python&logoColor=white)
25
+ ![Version](https://img.shields.io/badge/version-0.1.0-58a6ff?style=flat-square)
26
+ ![Monitor JustETF Scraper](https://github.com/jopedro-labs/finances-data/actions/workflows/just_etf_bot.yml/badge.svg)
27
+ ![Monitor Yahoo Finance API](https://github.com/jopedro-labs/finances-data/actions/workflows/yahoo_bot.yml/badge.svg)
28
+ <br />
29
+ ![Linter](https://img.shields.io/badge/linter-Ruff-000000?style=flat-square&logo=python&logoColor=white)
30
+ ![Type Check](https://img.shields.io/badge/types-mypy%20strict-2A6DB2?style=flat-square&logo=python&logoColor=white)
31
+ ![Pytest](https://img.shields.io/badge/Pytest-0A9EDC?style=flat-square&logo=pytest&logoColor=white)
32
+ ![Gemini AI](https://img.shields.io/badge/Gemini_AI-8E75B2?style=flat-square&logo=googlegemini&logoColor=white)
33
+ ![GNU Make](https://img.shields.io/badge/env-GNU%20Make-active?style=flat-square&logo=gnu-make&logoColor=white)
34
+ ![MIT License](https://img.shields.io/badge/license-MIT-607D8B?style=flat-square)
35
+
36
+ Python client library for financial market data. Provides an ETF scraper for JustETF and a market data client for Yahoo Finance, with shared immutable domain models and autonomous code quality evaluation tools.
37
+
38
+ ---
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ # Editable install
44
+ pip install -e .
45
+
46
+ # With dev dependencies (pytest, pytest-cov, ruff, mypy, google-genai)
47
+ pip install -e ".[dev]"
48
+ ```
49
+
50
+ Or via GNU Make:
51
+
52
+ ```bash
53
+ make install
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Repository Structure
59
+
60
+ ```text
61
+ finances-data/
62
+ ├── .gemini/
63
+ │ └── QUALITY_AGENT.MD # Quality assurance spec and audit guidelines
64
+ ├── .github/
65
+ │ └── workflows/
66
+ │ ├── ci.yml # Matrix CI testing across Python 3.11-3.13, ruff, mypy, AUDIT sync
67
+ │ ├── just_etf_bot.yml # Scheduled canary monitor for JustETF scraper (Thursdays 20:00 UTC)
68
+ │ ├── yahoo_bot.yml # Scheduled canary monitor for Yahoo Finance API (Thursdays 20:00 UTC)
69
+ │ └── publish.yml # Automated PyPI publish workflow with version collision guards
70
+ ├── data/
71
+ │ ├── common/
72
+ │ │ └── constants.py # Country alias maps and shared normalization constants
73
+ │ └── models.py # Immutable domain models (Quotation, Holding, ETFMarketData, etc.)
74
+ ├── finances_data/
75
+ │ ├── just_etf/
76
+ │ │ ├── just_etf_client.py # Resilient JustETF scraper with 3-tier DOM fallback & rate-limit backoff
77
+ │ │ └── readme.md # JustETF module documentation
78
+ │ └── yahoo_finance/
79
+ │ ├── yahoo_finance_client.py# Typed wrapper over yfinance for quotes, fundamentals, and ETF stats
80
+ │ └── readme.md # Yahoo Finance module documentation
81
+ ├── logs/ # Runtime logs for canary health checks (gitignored)
82
+ ├── reports/ # Quality assessment and audit reports (gitignored)
83
+ ├── scripts/
84
+ │ ├── just_etf_health_check.py # Live canary health check for JustETF scraper
85
+ │ ├── notify_discord.py # Discord webhook notification helper
86
+ │ ├── quality_eval_agent.py # Autonomous AI code quality and gap analysis auditor
87
+ │ ├── validate_audit_sync.py # Structural validator and change-sync guard for AUDIT.md
88
+ │ └── yahoo_health_check.py # Live canary health check for Yahoo Finance API
89
+ ├── tests/ # Pytest test suite (100% statement coverage on core modules)
90
+ ├── .env.example # Environment configuration template
91
+ ├── AUDIT.md # Comprehensive codebase audit, technical debt, and backlog tracker
92
+ ├── Makefile # Development, linting, testing, and canary runner targets
93
+ └── pyproject.toml # Package configuration, dependencies, ruff, mypy, and pytest options
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Modules & Usage
99
+
100
+ ### `finances_data.just_etf`
101
+
102
+ HTTP scraper for [JustETF](https://www.justetf.com). Fetches full ETF profiles by ISIN using BeautifulSoup with a 3-level DOM fallback strategy per parser. Includes safe `Retry-After` parsing (supporting integers and HTTP-dates, capped to 10s) and bounded retries on HTTP 429 and transient errors (500, 502, 503, 504).
103
+
104
+ ```python
105
+ from finances_data.just_etf import JustETFClient
106
+
107
+ client = JustETFClient()
108
+ etf = client.get_etf_details("IE00B4L5Y983") # iShares Core MSCI World
109
+
110
+ print(etf.ter_pct) # 0.2
111
+ print(etf.fund_size_eur_m) # e.g. 80000.0
112
+ print(etf.holdings[0].name) # e.g. "Apple Inc."
113
+ print(etf.holdings[0].weight_pct)
114
+ ```
115
+
116
+ Returns `ETFDetails` with:
117
+ - `holdings` — top holdings with name, ISIN, weight % (bounded between 0.0 and 100.0)
118
+ - `sector_breakdown` — sector weights
119
+ - `country_breakdown` — country weights with canonical name mapping
120
+ - `ter_pct`, `fund_size_eur_m`, `inception_date`, `replication`, `distribution_policy`, `index_name`, `fund_currency`, `volatility_1y_pct`, `holdings_count`
121
+
122
+ ---
123
+
124
+ ### `finances_data.yahoo_finance`
125
+
126
+ Client over `yfinance` for fetching live quotes, stock fundamentals, and ETF market data, equipped with typed dictionary schemas (`YahooTickerInfo`, `YahooHistoryRow`), currency validation, and sanitized float conversions.
127
+
128
+ ```python
129
+ from finances_data.yahoo_finance import YahooFinanceClient
130
+
131
+ client = YahooFinanceClient()
132
+
133
+ # Live market quote
134
+ quote = client.get_quotation("IWDA.AS")
135
+ print(quote.price, quote.currency)
136
+
137
+ # Stock fundamentals (~34 fields)
138
+ stock = client.get_stock_details("AAPL")
139
+ print(stock.pe_ratio, stock.sector, stock.dividend_yield_pct)
140
+
141
+ # ETF market data — price, NAV, moving averages, volume
142
+ etf = client.get_etf_market_data("IWDA.AS")
143
+ print(etf.fifty_two_week_high, etf.two_hundred_day_average)
144
+ ```
145
+
146
+ ---
147
+
148
+ ### `data.models`
149
+
150
+ Immutable domain dataclasses (`frozen=True, slots=True`) shared across both clients, enforcing semantic domain invariants (e.g., non-negative prices and percentage bounds):
151
+
152
+ | Class | Purpose | Domain Invariants |
153
+ |---|---|---|
154
+ | `Quotation` | Price, currency, timestamp for a ticker | `price >= 0.0`, `native_price >= 0.0` |
155
+ | `Holding` | ETF holding — name, ISIN, weight % | `0.0 <= weight_pct <= 100.0` |
156
+ | `SectorExposure` | Sector name + weight % | `0.0 <= weight_pct <= 100.0` |
157
+ | `CountryExposure` | Country name + weight % | `0.0 <= weight_pct <= 100.0` |
158
+ | `ETFMarketData` | ETF price, NAV, moving averages, volume | `price >= 0.0`, `nav_price >= 0.0`, `average_volume >= 0` |
159
+ | `StockDetails` | ~34 fundamental metrics: P/E, margins, analyst targets, EPS | Type-safe conversions, null/nan sanitization |
160
+ | `ETFDetails` | Full ETF profile: holdings + breakdowns + metadata | Structured container with dict export |
161
+
162
+ ---
163
+
164
+ ## Health-Check Canary Scripts & Workflows
165
+
166
+ The repository maintains automated scheduled canaries to detect third-party API drift, JustETF DOM structure shifts, and anti-scraping challenges.
167
+
168
+ ### GitHub Actions Workflows
169
+
170
+ - **`ci.yml`**: Multi-Python matrix (3.11, 3.12, 3.13) verifying `ruff`, `mypy`, `pytest` with coverage, and enforcing `AUDIT.md` synchronization via `scripts/validate_audit_sync.py --enforce-sync`.
171
+ - **`just_etf_bot.yml`**: Scheduled health monitor running `scripts/just_etf_health_check.py` every Thursday at 20:00 UTC. Sends Discord alerts on failure and uploads error logs (`logs/just_etf_monitor.log`).
172
+ - **`yahoo_bot.yml`**: Scheduled health monitor running `scripts/yahoo_health_check.py` every Thursday at 20:00 UTC. Validates live quote resolution for `IWDA.AS`, posts alerts to Discord, and uploads error logs (`logs/yahoo_monitor.log`).
173
+ - **`publish.yml`**: Automated dispatch workflow publishing releases to PyPI with unbumped version and remote git tag collision guards.
174
+
175
+ ### Running Canaries Locally
176
+
177
+ ```bash
178
+ # Execute JustETF live canary check
179
+ make run-just-etf-health
180
+
181
+ # Execute Yahoo Finance live canary check
182
+ make run-yahoo-health
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Autonomous Quality Assurance & Test Gap Evaluation Agent
188
+
189
+ An internal developer utility (`scripts/quality_eval_agent.py`) powered by Google GenAI (`google-genai` SDK) that inspects the repository against `.gemini/QUALITY_AGENT.MD`.
190
+
191
+ ### Core Validation Pillars Evaluated:
192
+
193
+ 1. **Unit Tests:** Isolated verification and mocking via `pytest`.
194
+ 2. **Integration Tests:** Component and adapter interaction verification.
195
+ 3. **Static Code Analysis:** Type safety (`mypy` strict) and linting (`ruff` with `T20`, `B`, `UP`).
196
+ 4. **Mutation Testing Readiness:** Heuristic assessment of test sensitivity against subtle logic mutations.
197
+ 5. **Black-Box Verification:** Functional and behavioral validation.
198
+
199
+ ### Execution:
200
+
201
+ ```bash
202
+ make quality-eval-agent
203
+ ```
204
+
205
+ Requirements: Copy `.env.example` to `.env` and configure `GEMINI_API_KEY`. The agent executes the test suite, gathers repository context, analyzes gaps via `GEMINI_MODEL` (default: `gemini-3.8-flash`), and outputs a structured markdown report to `reports/quality_agent_report.md`.
206
+
207
+ ---
208
+
209
+ ## AUDIT.md & Repository Maintenance Conventions
210
+
211
+ The repository uses `AUDIT.md` to track technical debt, bugs, and backlog items. It is strictly enforced via `scripts/validate_audit_sync.py`:
212
+
213
+ - **Structural Integrity**: Enforces header formatting, checkbox syntax (`- [x]` or `- [ ]`), and mandatory sections.
214
+ - **Change Synchronization**: Changes to `finances_data/`, `data/`, `scripts/`, `tests/`, or `.github/workflows/` require an update to `AUDIT.md` (or explicit `BYPASS_AUDIT_SYNC=1`).
215
+ - **Verification Target**: Run `make validate-audit` to assert consistency.
216
+
217
+ ---
218
+
219
+ ## Development Commands
220
+
221
+ All standard development tasks are orchestrated through GNU Make:
222
+
223
+ ```bash
224
+ # Run lint, type checking, pytest with coverage, and audit sync validation
225
+ make check
226
+ ```
227
+
228
+ | Command | Description |
229
+ |---|---|
230
+ | `make install` | Create `.venv` and install package with dev dependencies |
231
+ | `make lint` | Check code with Ruff (`E`, `F`, `I`, `UP`, `B`, `T20`) |
232
+ | `make lint-fix` | Auto-fix Ruff lint issues |
233
+ | `make type` | Type check codebase with Mypy in strict mode |
234
+ | `make test` | Run pytest suite with terminal coverage report |
235
+ | `make validate-audit` | Verify `AUDIT.md` syntax and synchronization status |
236
+ | `make quality-eval-agent`| Run autonomous AI quality auditor |
237
+ | `make run-just-etf-health`| Run live JustETF canary check |
238
+ | `make run-yahoo-health` | Run live Yahoo Finance canary check |
239
+ | `make clean-venv` | Remove `.venv` and installed stamp |
240
+
241
+ ---
242
+
243
+ ## License
244
+
245
+ Distributed under the MIT License.
246
+
247
+ Developed and maintained by **João Pedro** ([@JoPedro15](https://github.com/JoPedro15)).
@@ -0,0 +1,226 @@
1
+ # finances-data
2
+
3
+ ![Python 3.11+](https://img.shields.io/badge/python-3.11+-3776AB?style=flat-square&logo=python&logoColor=white)
4
+ ![Version](https://img.shields.io/badge/version-0.1.0-58a6ff?style=flat-square)
5
+ ![Monitor JustETF Scraper](https://github.com/jopedro-labs/finances-data/actions/workflows/just_etf_bot.yml/badge.svg)
6
+ ![Monitor Yahoo Finance API](https://github.com/jopedro-labs/finances-data/actions/workflows/yahoo_bot.yml/badge.svg)
7
+ <br />
8
+ ![Linter](https://img.shields.io/badge/linter-Ruff-000000?style=flat-square&logo=python&logoColor=white)
9
+ ![Type Check](https://img.shields.io/badge/types-mypy%20strict-2A6DB2?style=flat-square&logo=python&logoColor=white)
10
+ ![Pytest](https://img.shields.io/badge/Pytest-0A9EDC?style=flat-square&logo=pytest&logoColor=white)
11
+ ![Gemini AI](https://img.shields.io/badge/Gemini_AI-8E75B2?style=flat-square&logo=googlegemini&logoColor=white)
12
+ ![GNU Make](https://img.shields.io/badge/env-GNU%20Make-active?style=flat-square&logo=gnu-make&logoColor=white)
13
+ ![MIT License](https://img.shields.io/badge/license-MIT-607D8B?style=flat-square)
14
+
15
+ Python client library for financial market data. Provides an ETF scraper for JustETF and a market data client for Yahoo Finance, with shared immutable domain models and autonomous code quality evaluation tools.
16
+
17
+ ---
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ # Editable install
23
+ pip install -e .
24
+
25
+ # With dev dependencies (pytest, pytest-cov, ruff, mypy, google-genai)
26
+ pip install -e ".[dev]"
27
+ ```
28
+
29
+ Or via GNU Make:
30
+
31
+ ```bash
32
+ make install
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Repository Structure
38
+
39
+ ```text
40
+ finances-data/
41
+ ├── .gemini/
42
+ │ └── QUALITY_AGENT.MD # Quality assurance spec and audit guidelines
43
+ ├── .github/
44
+ │ └── workflows/
45
+ │ ├── ci.yml # Matrix CI testing across Python 3.11-3.13, ruff, mypy, AUDIT sync
46
+ │ ├── just_etf_bot.yml # Scheduled canary monitor for JustETF scraper (Thursdays 20:00 UTC)
47
+ │ ├── yahoo_bot.yml # Scheduled canary monitor for Yahoo Finance API (Thursdays 20:00 UTC)
48
+ │ └── publish.yml # Automated PyPI publish workflow with version collision guards
49
+ ├── data/
50
+ │ ├── common/
51
+ │ │ └── constants.py # Country alias maps and shared normalization constants
52
+ │ └── models.py # Immutable domain models (Quotation, Holding, ETFMarketData, etc.)
53
+ ├── finances_data/
54
+ │ ├── just_etf/
55
+ │ │ ├── just_etf_client.py # Resilient JustETF scraper with 3-tier DOM fallback & rate-limit backoff
56
+ │ │ └── readme.md # JustETF module documentation
57
+ │ └── yahoo_finance/
58
+ │ ├── yahoo_finance_client.py# Typed wrapper over yfinance for quotes, fundamentals, and ETF stats
59
+ │ └── readme.md # Yahoo Finance module documentation
60
+ ├── logs/ # Runtime logs for canary health checks (gitignored)
61
+ ├── reports/ # Quality assessment and audit reports (gitignored)
62
+ ├── scripts/
63
+ │ ├── just_etf_health_check.py # Live canary health check for JustETF scraper
64
+ │ ├── notify_discord.py # Discord webhook notification helper
65
+ │ ├── quality_eval_agent.py # Autonomous AI code quality and gap analysis auditor
66
+ │ ├── validate_audit_sync.py # Structural validator and change-sync guard for AUDIT.md
67
+ │ └── yahoo_health_check.py # Live canary health check for Yahoo Finance API
68
+ ├── tests/ # Pytest test suite (100% statement coverage on core modules)
69
+ ├── .env.example # Environment configuration template
70
+ ├── AUDIT.md # Comprehensive codebase audit, technical debt, and backlog tracker
71
+ ├── Makefile # Development, linting, testing, and canary runner targets
72
+ └── pyproject.toml # Package configuration, dependencies, ruff, mypy, and pytest options
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Modules & Usage
78
+
79
+ ### `finances_data.just_etf`
80
+
81
+ HTTP scraper for [JustETF](https://www.justetf.com). Fetches full ETF profiles by ISIN using BeautifulSoup with a 3-level DOM fallback strategy per parser. Includes safe `Retry-After` parsing (supporting integers and HTTP-dates, capped to 10s) and bounded retries on HTTP 429 and transient errors (500, 502, 503, 504).
82
+
83
+ ```python
84
+ from finances_data.just_etf import JustETFClient
85
+
86
+ client = JustETFClient()
87
+ etf = client.get_etf_details("IE00B4L5Y983") # iShares Core MSCI World
88
+
89
+ print(etf.ter_pct) # 0.2
90
+ print(etf.fund_size_eur_m) # e.g. 80000.0
91
+ print(etf.holdings[0].name) # e.g. "Apple Inc."
92
+ print(etf.holdings[0].weight_pct)
93
+ ```
94
+
95
+ Returns `ETFDetails` with:
96
+ - `holdings` — top holdings with name, ISIN, weight % (bounded between 0.0 and 100.0)
97
+ - `sector_breakdown` — sector weights
98
+ - `country_breakdown` — country weights with canonical name mapping
99
+ - `ter_pct`, `fund_size_eur_m`, `inception_date`, `replication`, `distribution_policy`, `index_name`, `fund_currency`, `volatility_1y_pct`, `holdings_count`
100
+
101
+ ---
102
+
103
+ ### `finances_data.yahoo_finance`
104
+
105
+ Client over `yfinance` for fetching live quotes, stock fundamentals, and ETF market data, equipped with typed dictionary schemas (`YahooTickerInfo`, `YahooHistoryRow`), currency validation, and sanitized float conversions.
106
+
107
+ ```python
108
+ from finances_data.yahoo_finance import YahooFinanceClient
109
+
110
+ client = YahooFinanceClient()
111
+
112
+ # Live market quote
113
+ quote = client.get_quotation("IWDA.AS")
114
+ print(quote.price, quote.currency)
115
+
116
+ # Stock fundamentals (~34 fields)
117
+ stock = client.get_stock_details("AAPL")
118
+ print(stock.pe_ratio, stock.sector, stock.dividend_yield_pct)
119
+
120
+ # ETF market data — price, NAV, moving averages, volume
121
+ etf = client.get_etf_market_data("IWDA.AS")
122
+ print(etf.fifty_two_week_high, etf.two_hundred_day_average)
123
+ ```
124
+
125
+ ---
126
+
127
+ ### `data.models`
128
+
129
+ Immutable domain dataclasses (`frozen=True, slots=True`) shared across both clients, enforcing semantic domain invariants (e.g., non-negative prices and percentage bounds):
130
+
131
+ | Class | Purpose | Domain Invariants |
132
+ |---|---|---|
133
+ | `Quotation` | Price, currency, timestamp for a ticker | `price >= 0.0`, `native_price >= 0.0` |
134
+ | `Holding` | ETF holding — name, ISIN, weight % | `0.0 <= weight_pct <= 100.0` |
135
+ | `SectorExposure` | Sector name + weight % | `0.0 <= weight_pct <= 100.0` |
136
+ | `CountryExposure` | Country name + weight % | `0.0 <= weight_pct <= 100.0` |
137
+ | `ETFMarketData` | ETF price, NAV, moving averages, volume | `price >= 0.0`, `nav_price >= 0.0`, `average_volume >= 0` |
138
+ | `StockDetails` | ~34 fundamental metrics: P/E, margins, analyst targets, EPS | Type-safe conversions, null/nan sanitization |
139
+ | `ETFDetails` | Full ETF profile: holdings + breakdowns + metadata | Structured container with dict export |
140
+
141
+ ---
142
+
143
+ ## Health-Check Canary Scripts & Workflows
144
+
145
+ The repository maintains automated scheduled canaries to detect third-party API drift, JustETF DOM structure shifts, and anti-scraping challenges.
146
+
147
+ ### GitHub Actions Workflows
148
+
149
+ - **`ci.yml`**: Multi-Python matrix (3.11, 3.12, 3.13) verifying `ruff`, `mypy`, `pytest` with coverage, and enforcing `AUDIT.md` synchronization via `scripts/validate_audit_sync.py --enforce-sync`.
150
+ - **`just_etf_bot.yml`**: Scheduled health monitor running `scripts/just_etf_health_check.py` every Thursday at 20:00 UTC. Sends Discord alerts on failure and uploads error logs (`logs/just_etf_monitor.log`).
151
+ - **`yahoo_bot.yml`**: Scheduled health monitor running `scripts/yahoo_health_check.py` every Thursday at 20:00 UTC. Validates live quote resolution for `IWDA.AS`, posts alerts to Discord, and uploads error logs (`logs/yahoo_monitor.log`).
152
+ - **`publish.yml`**: Automated dispatch workflow publishing releases to PyPI with unbumped version and remote git tag collision guards.
153
+
154
+ ### Running Canaries Locally
155
+
156
+ ```bash
157
+ # Execute JustETF live canary check
158
+ make run-just-etf-health
159
+
160
+ # Execute Yahoo Finance live canary check
161
+ make run-yahoo-health
162
+ ```
163
+
164
+ ---
165
+
166
+ ## Autonomous Quality Assurance & Test Gap Evaluation Agent
167
+
168
+ An internal developer utility (`scripts/quality_eval_agent.py`) powered by Google GenAI (`google-genai` SDK) that inspects the repository against `.gemini/QUALITY_AGENT.MD`.
169
+
170
+ ### Core Validation Pillars Evaluated:
171
+
172
+ 1. **Unit Tests:** Isolated verification and mocking via `pytest`.
173
+ 2. **Integration Tests:** Component and adapter interaction verification.
174
+ 3. **Static Code Analysis:** Type safety (`mypy` strict) and linting (`ruff` with `T20`, `B`, `UP`).
175
+ 4. **Mutation Testing Readiness:** Heuristic assessment of test sensitivity against subtle logic mutations.
176
+ 5. **Black-Box Verification:** Functional and behavioral validation.
177
+
178
+ ### Execution:
179
+
180
+ ```bash
181
+ make quality-eval-agent
182
+ ```
183
+
184
+ Requirements: Copy `.env.example` to `.env` and configure `GEMINI_API_KEY`. The agent executes the test suite, gathers repository context, analyzes gaps via `GEMINI_MODEL` (default: `gemini-3.8-flash`), and outputs a structured markdown report to `reports/quality_agent_report.md`.
185
+
186
+ ---
187
+
188
+ ## AUDIT.md & Repository Maintenance Conventions
189
+
190
+ The repository uses `AUDIT.md` to track technical debt, bugs, and backlog items. It is strictly enforced via `scripts/validate_audit_sync.py`:
191
+
192
+ - **Structural Integrity**: Enforces header formatting, checkbox syntax (`- [x]` or `- [ ]`), and mandatory sections.
193
+ - **Change Synchronization**: Changes to `finances_data/`, `data/`, `scripts/`, `tests/`, or `.github/workflows/` require an update to `AUDIT.md` (or explicit `BYPASS_AUDIT_SYNC=1`).
194
+ - **Verification Target**: Run `make validate-audit` to assert consistency.
195
+
196
+ ---
197
+
198
+ ## Development Commands
199
+
200
+ All standard development tasks are orchestrated through GNU Make:
201
+
202
+ ```bash
203
+ # Run lint, type checking, pytest with coverage, and audit sync validation
204
+ make check
205
+ ```
206
+
207
+ | Command | Description |
208
+ |---|---|
209
+ | `make install` | Create `.venv` and install package with dev dependencies |
210
+ | `make lint` | Check code with Ruff (`E`, `F`, `I`, `UP`, `B`, `T20`) |
211
+ | `make lint-fix` | Auto-fix Ruff lint issues |
212
+ | `make type` | Type check codebase with Mypy in strict mode |
213
+ | `make test` | Run pytest suite with terminal coverage report |
214
+ | `make validate-audit` | Verify `AUDIT.md` syntax and synchronization status |
215
+ | `make quality-eval-agent`| Run autonomous AI quality auditor |
216
+ | `make run-just-etf-health`| Run live JustETF canary check |
217
+ | `make run-yahoo-health` | Run live Yahoo Finance canary check |
218
+ | `make clean-venv` | Remove `.venv` and installed stamp |
219
+
220
+ ---
221
+
222
+ ## License
223
+
224
+ Distributed under the MIT License.
225
+
226
+ Developed and maintained by **João Pedro** ([@JoPedro15](https://github.com/JoPedro15)).
File without changes
@@ -0,0 +1,92 @@
1
+ """Constants and mapping dictionaries for country aliases and data normalization."""
2
+
3
+ from __future__ import annotations
4
+
5
+ COUNTRY_ALIASES: dict[str, str] = {
6
+ # United States
7
+ "EUA": "United States",
8
+ "USA": "United States",
9
+ "US": "United States",
10
+ "U.S.": "United States",
11
+ "UNITED STATES": "United States",
12
+ "UNITED STATES OF AMERICA": "United States",
13
+ # United Kingdom / Great Britain
14
+ "UK": "United Kingdom",
15
+ "U.K.": "United Kingdom",
16
+ "UNITED KINGDOM": "United Kingdom",
17
+ "GREAT BRITAIN": "United Kingdom",
18
+ "BRITAIN": "United Kingdom",
19
+ "ENGLAND": "United Kingdom",
20
+ "GB": "United Kingdom",
21
+ # Netherlands / Holland
22
+ "NETHERLANDS": "Netherlands",
23
+ "THE NETHERLANDS": "Netherlands",
24
+ "HOLLAND": "Netherlands",
25
+ "NL": "Netherlands",
26
+ # Switzerland
27
+ "SWITZERLAND": "Switzerland",
28
+ "SWISS CONFEDERATION": "Switzerland",
29
+ "CH": "Switzerland",
30
+ # Germany
31
+ "GERMANY": "Germany",
32
+ "DEUTSCHLAND": "Germany",
33
+ "FEDERAL REPUBLIC OF GERMANY": "Germany",
34
+ "DE": "Germany",
35
+ # France
36
+ "FRANCE": "France",
37
+ "FR": "France",
38
+ # Ireland
39
+ "IRELAND": "Ireland",
40
+ "REPUBLIC OF IRELAND": "Ireland",
41
+ "IE": "Ireland",
42
+ # Canada
43
+ "CANADA": "Canada",
44
+ "CA": "Canada",
45
+ # Australia
46
+ "AUSTRALIA": "Australia",
47
+ "COMMONWEALTH OF AUSTRALIA": "Australia",
48
+ "AU": "Australia",
49
+ # Japan
50
+ "JAPAN": "Japan",
51
+ "JP": "Japan",
52
+ # China
53
+ "CHINA": "China",
54
+ "PEOPLE'S REPUBLIC OF CHINA": "China",
55
+ "PRC": "China",
56
+ "CN": "China",
57
+ # Taiwan
58
+ "TAIWAN": "Taiwan",
59
+ "TAIWAN, PROVINCE OF CHINA": "Taiwan",
60
+ "REPUBLIC OF CHINA": "Taiwan",
61
+ "TW": "Taiwan",
62
+ # South Korea
63
+ "SOUTH KOREA": "South Korea",
64
+ "KOREA, REPUBLIC OF": "South Korea",
65
+ "KOREA": "South Korea",
66
+ "KR": "South Korea",
67
+ # Singapore
68
+ "SINGAPORE": "Singapore",
69
+ "SG": "Singapore",
70
+ # Hong Kong
71
+ "HONG KONG": "Hong Kong",
72
+ "HONG KONG SAR": "Hong Kong",
73
+ "HK": "Hong Kong",
74
+ # Sweden
75
+ "SWEDEN": "Sweden",
76
+ "SE": "Sweden",
77
+ # Norway
78
+ "NORWAY": "Norway",
79
+ "NO": "Norway",
80
+ # Denmark
81
+ "DENMARK": "Denmark",
82
+ "DK": "Denmark",
83
+ # Finland
84
+ "FINLAND": "Finland",
85
+ "FI": "Finland",
86
+ # Spain
87
+ "SPAIN": "Spain",
88
+ "ES": "Spain",
89
+ # Italy
90
+ "ITALY": "Italy",
91
+ "IT": "Italy",
92
+ }