Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Immo·Ka9# File : immoka/mortgage/providers/tangerine.py10# Module : immoka11# Repository : https://git.spboucher.ai/immo-ka12# Created : 2026-08-2413# Last Modified : 2026-08-2414#15# =============================================================================16# AUTHOR & PROFESSIONAL AFFILIATION17# =============================================================================18#19# Author : Simon-Pierre Boucher20# Position : Professor of Finance21# Institution : Université du Québec en Outaouais (UQO)22# Department : Département des sciences administratives23# Organization : SP Boucher24#25# Website : https://spboucher.ai26# Git : https://git.spboucher.ai27#28# =============================================================================29# OFFICIAL CONTACT DIRECTORY30# =============================================================================31#32# General : info@spboucher.ai33# Professional : contact@spboucher.ai34# Direct : simon@spboucher.ai35# Research : research@spboucher.ai36# Development : dev@spboucher.ai37# Support : support@spboucher.ai38# Security/Admin : admin@spboucher.ai39# Notifications : notifications@spboucher.ai40#41# Preferred Contact: contact@spboucher.ai42#43# =============================================================================44# COPYRIGHT & INTELLECTUAL PROPERTY45# =============================================================================46#47# Copyright (c) 202648# Simon-Pierre Boucher49#50# All rights reserved where applicable.51#52# This file is governed by the applicable project license,53# copyright notices, institutional agreements and relevant law.54#55# Unless expressly authorized by the applicable license or56# rights holder, copying, redistribution, sublicensing,57# publication and commercial exploitation are not permitted.58#59# Existing third-party rights and notices remain unaffected.60#61# =============================================================================62# CONFIDENTIALITY & SECURITY63# =============================================================================64#65# Classification : Public66# Distribution : Public repository; use is governed by the project license67# Security Contact : admin@spboucher.ai68#69# Access to this source does not independently grant permission70# to redistribute or disclose confidential materials.71#72# Do not embed credentials, private keys, access tokens,73# certificates or confidential personal information.74#75# =============================================================================76# LICENSE & MAINTENANCE77# =============================================================================78#79# License : None specified (no license file in this repository)80# Maintainer : Simon-Pierre Boucher81# Technical Contact: dev@spboucher.ai82#83# =============================================================================84# END OF SP BOUCHER SOURCE HEADER85# =============================================================================8687# -----------------------------------------------------------------------------88# Immo-Ka — Agrégateur de maisons à vendre (province de Québec)89# Auteur : Simon-Pierre Boucher — contact@spboucher.ai90# mortgage/providers/tangerine.py : Tangerine — JSON statique publié91# (currentRates.json, le fichier que charge leur page /rates). Un seul taux92# par terme (pas de distinction affiché/spécial chez Tangerine) : kind93# "special" car c'est leur taux client réel.94# -----------------------------------------------------------------------------95from __future__ import annotations9697import json9899from .base import RateProvider, parse_rate100101RATES_URL = ("https://www.tangerine.ca/content/dam/tangerine-shared/"102 "product-rates/currentRates.json")103104105class TangerineProvider(RateProvider):106 provider_id = "tangerine"107 institution = "Tangerine"108 source_url = "https://www.tangerine.ca/en/rates"109 request_delay = 1.0110111 def fetch(self) -> list[dict]:112 return self.parse(self.get(RATES_URL).text)113114 def parse(self, payload: str) -> list[dict]:115 data = json.loads(payload)116 out: list[dict] = []117 for r in data.get("rates") or []:118 if r.get("group") != "mortgage":119 continue120 code = r.get("max_product_code")121 rate = r.get("interest_rate")122 term_years = r.get("term")123 if not isinstance(rate, (int, float)) or rate <= 0:124 continue125 if not isinstance(term_years, (int, float)) or term_years <= 0:126 continue127 if code == "Mortgage":128 rtype, label = "fixed", f"Fixe {int(term_years)} an(s)"129 elif code == "VarMortgage":130 rtype, label = "variable", f"Variable {int(term_years)} an(s)"131 else:132 continue # preferred_* et autres : clients connectés, ignorés133 apr = parse_rate(r.get("apr_value_en") or "")134 out.append(self.make_product(135 rate=float(rate), rate_type=rtype,136 term_months=int(term_years * 12), kind="special",137 product_name=label, apr=apr,138 conditions=f"Taux unique Tangerine (en date du {r.get('date')})",139 raw={"account_term": r.get("account_term"),140 "date": r.get("date"), "interest_rate": rate}))141 return out142