fin-infra 0.7.0__py3-none-any.whl → 0.9.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.
- fin_infra/banking/__init__.py +4 -0
- fin_infra/providers/banking/plaid_client.py +11 -9
- fin_infra/providers/banking/teller_client.py +43 -8
- fin_infra/recurring/insights.py +1 -1
- fin_infra/recurring/normalizers.py +1 -1
- fin_infra/settings.py +8 -0
- {fin_infra-0.7.0.dist-info → fin_infra-0.9.0.dist-info}/METADATA +1 -1
- {fin_infra-0.7.0.dist-info → fin_infra-0.9.0.dist-info}/RECORD +11 -11
- {fin_infra-0.7.0.dist-info → fin_infra-0.9.0.dist-info}/LICENSE +0 -0
- {fin_infra-0.7.0.dist-info → fin_infra-0.9.0.dist-info}/WHEEL +0 -0
- {fin_infra-0.7.0.dist-info → fin_infra-0.9.0.dist-info}/entry_points.txt +0 -0
fin_infra/banking/__init__.py
CHANGED
|
@@ -28,6 +28,8 @@ Environment Variables:
|
|
|
28
28
|
Teller:
|
|
29
29
|
TELLER_CERTIFICATE_PATH: Path to certificate.pem file
|
|
30
30
|
TELLER_PRIVATE_KEY_PATH: Path to private_key.pem file
|
|
31
|
+
TELLER_CERTIFICATE: Inline certificate PEM content (alternative to path)
|
|
32
|
+
TELLER_PRIVATE_KEY: Inline private key PEM content (alternative to path)
|
|
31
33
|
TELLER_ENVIRONMENT: "sandbox" or "production" (default: sandbox)
|
|
32
34
|
|
|
33
35
|
Plaid:
|
|
@@ -191,6 +193,8 @@ def easy_banking(provider: str = "teller", **config) -> BankingProvider:
|
|
|
191
193
|
config = {
|
|
192
194
|
"cert_path": os.getenv("TELLER_CERTIFICATE_PATH"),
|
|
193
195
|
"key_path": os.getenv("TELLER_PRIVATE_KEY_PATH"),
|
|
196
|
+
"cert_content": os.getenv("TELLER_CERTIFICATE"),
|
|
197
|
+
"key_content": os.getenv("TELLER_PRIVATE_KEY"),
|
|
194
198
|
"environment": os.getenv("TELLER_ENVIRONMENT", "sandbox"),
|
|
195
199
|
}
|
|
196
200
|
elif provider == "plaid":
|
|
@@ -52,6 +52,12 @@ class PlaidClient(BankingProvider):
|
|
|
52
52
|
client_id = client_id or settings.plaid_client_id
|
|
53
53
|
secret = secret or settings.plaid_secret
|
|
54
54
|
environment = environment or settings.plaid_env
|
|
55
|
+
self._products = settings.plaid_products
|
|
56
|
+
else:
|
|
57
|
+
# Use default products when no settings object provided
|
|
58
|
+
from ...settings import DEFAULT_PLAID_PRODUCTS
|
|
59
|
+
|
|
60
|
+
self._products = DEFAULT_PLAID_PRODUCTS
|
|
55
61
|
|
|
56
62
|
# Map environment string to Plaid Environment enum
|
|
57
63
|
# Note: Plaid only has Sandbox and Production (no Development in SDK)
|
|
@@ -105,15 +111,11 @@ class PlaidClient(BankingProvider):
|
|
|
105
111
|
# Don't include products - Plaid uses existing item's products
|
|
106
112
|
request_params["access_token"] = access_token
|
|
107
113
|
else:
|
|
108
|
-
# New connection: specify products
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Products("investments"), # Brokerage, retirement accounts
|
|
114
|
-
Products("assets"), # Asset reports for lending/verification
|
|
115
|
-
Products("identity"), # Account holder info (name, email, phone)
|
|
116
|
-
]
|
|
114
|
+
# New connection: specify products from settings
|
|
115
|
+
# Configurable via PLAID_PRODUCTS env var (comma-separated)
|
|
116
|
+
# Default: auth,transactions,investments (excludes costly unused products)
|
|
117
|
+
product_list = [Products(p.strip()) for p in self._products.split(",") if p.strip()]
|
|
118
|
+
request_params["products"] = product_list
|
|
117
119
|
|
|
118
120
|
request = LinkTokenCreateRequest(**request_params)
|
|
119
121
|
response = self.client.link_token_create(request)
|
|
@@ -52,25 +52,42 @@ class TellerClient(BankingProvider):
|
|
|
52
52
|
self,
|
|
53
53
|
cert_path: str | None = None,
|
|
54
54
|
key_path: str | None = None,
|
|
55
|
+
cert_content: str | None = None,
|
|
56
|
+
key_content: str | None = None,
|
|
55
57
|
environment: str = "sandbox",
|
|
56
58
|
timeout: float = 30.0,
|
|
57
59
|
) -> None:
|
|
58
60
|
"""Initialize TellerClient banking provider.
|
|
59
61
|
|
|
60
62
|
Args:
|
|
61
|
-
cert_path: Path to certificate.pem file
|
|
62
|
-
key_path: Path to private_key.pem file
|
|
63
|
+
cert_path: Path to certificate.pem file
|
|
64
|
+
key_path: Path to private_key.pem file
|
|
65
|
+
cert_content: Inline certificate PEM content (alternative to cert_path)
|
|
66
|
+
key_content: Inline private key PEM content (alternative to key_path)
|
|
63
67
|
environment: "sandbox" or "production" (default: sandbox)
|
|
64
68
|
timeout: HTTP request timeout in seconds (default: 30.0)
|
|
65
69
|
|
|
70
|
+
Note:
|
|
71
|
+
Either (cert_path, key_path) or (cert_content, key_content) must be provided
|
|
72
|
+
for production. The inline content options are useful for Railway/Vercel
|
|
73
|
+
where env vars are preferred over mounted files.
|
|
74
|
+
|
|
66
75
|
Raises:
|
|
67
|
-
ValueError: If cert/key
|
|
76
|
+
ValueError: If cert/key are missing in production environment
|
|
68
77
|
"""
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
has_file_creds = cert_path and key_path
|
|
79
|
+
has_inline_creds = cert_content and key_content
|
|
80
|
+
|
|
81
|
+
if environment == "production" and not (has_file_creds or has_inline_creds):
|
|
82
|
+
raise ValueError(
|
|
83
|
+
"Either (cert_path, key_path) or (cert_content, key_content) "
|
|
84
|
+
"are required for production environment"
|
|
85
|
+
)
|
|
71
86
|
|
|
72
87
|
self.cert_path = cert_path
|
|
73
88
|
self.key_path = key_path
|
|
89
|
+
self.cert_content = cert_content
|
|
90
|
+
self.key_content = key_content
|
|
74
91
|
self.environment = environment
|
|
75
92
|
self.timeout = timeout
|
|
76
93
|
|
|
@@ -81,18 +98,36 @@ class TellerClient(BankingProvider):
|
|
|
81
98
|
self.base_url = "https://api.teller.io"
|
|
82
99
|
|
|
83
100
|
# Create HTTP client with mTLS certificate authentication
|
|
84
|
-
client_kwargs = {
|
|
101
|
+
client_kwargs: dict = {
|
|
85
102
|
"base_url": self.base_url,
|
|
86
103
|
"timeout": timeout,
|
|
87
104
|
"headers": {"User-Agent": "fin-infra/1.0"},
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
# Add certificate using SSL context (recommended approach, not deprecated)
|
|
91
|
-
if
|
|
92
|
-
#
|
|
108
|
+
if has_file_creds:
|
|
109
|
+
# Use file paths directly (assertions for type narrowing)
|
|
110
|
+
assert cert_path is not None
|
|
111
|
+
assert key_path is not None
|
|
93
112
|
ssl_context = ssl.create_default_context()
|
|
94
113
|
ssl_context.load_cert_chain(certfile=cert_path, keyfile=key_path)
|
|
95
114
|
client_kwargs["verify"] = ssl_context
|
|
115
|
+
elif has_inline_creds:
|
|
116
|
+
# Write inline content to temp files for SSL context (assertions for type narrowing)
|
|
117
|
+
assert cert_content is not None
|
|
118
|
+
assert key_content is not None
|
|
119
|
+
import tempfile
|
|
120
|
+
|
|
121
|
+
self._cert_file = tempfile.NamedTemporaryFile(mode="w", suffix=".pem", delete=False)
|
|
122
|
+
self._key_file = tempfile.NamedTemporaryFile(mode="w", suffix=".pem", delete=False)
|
|
123
|
+
self._cert_file.write(cert_content)
|
|
124
|
+
self._key_file.write(key_content)
|
|
125
|
+
self._cert_file.close()
|
|
126
|
+
self._key_file.close()
|
|
127
|
+
|
|
128
|
+
ssl_context = ssl.create_default_context()
|
|
129
|
+
ssl_context.load_cert_chain(certfile=self._cert_file.name, keyfile=self._key_file.name)
|
|
130
|
+
client_kwargs["verify"] = ssl_context
|
|
96
131
|
|
|
97
132
|
# Create client with explicit parameters to satisfy type checker
|
|
98
133
|
self.client = httpx.Client(
|
fin_infra/recurring/insights.py
CHANGED
|
@@ -331,7 +331,7 @@ class SubscriptionInsightsGenerator:
|
|
|
331
331
|
cache_key = self._make_cache_key(subscriptions, user_id)
|
|
332
332
|
|
|
333
333
|
try:
|
|
334
|
-
await self.cache.set(cache_key, result.model_dump(),
|
|
334
|
+
await self.cache.set(cache_key, result.model_dump(), expire=self.cache_ttl)
|
|
335
335
|
except Exception as e:
|
|
336
336
|
logger.warning(f"Cache set failed for insights: {e}")
|
|
337
337
|
|
|
@@ -318,7 +318,7 @@ class MerchantNormalizer:
|
|
|
318
318
|
cache_key = self._make_cache_key(merchant_name)
|
|
319
319
|
|
|
320
320
|
try:
|
|
321
|
-
await self.cache.set(cache_key, result.model_dump(),
|
|
321
|
+
await self.cache.set(cache_key, result.model_dump(), expire=self.cache_ttl)
|
|
322
322
|
except Exception as e:
|
|
323
323
|
logger.warning(f"Cache set failed for '{merchant_name}': {e}")
|
|
324
324
|
|
fin_infra/settings.py
CHANGED
|
@@ -5,6 +5,13 @@ from functools import lru_cache
|
|
|
5
5
|
from pydantic import Field
|
|
6
6
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
7
7
|
|
|
8
|
+
# Default products: only the ones we actually use
|
|
9
|
+
# auth: Account/routing numbers for ACH
|
|
10
|
+
# transactions: Transaction history
|
|
11
|
+
# investments: Brokerage, retirement accounts
|
|
12
|
+
# Excluded: identity, liabilities, assets (not used, cost extra per API call)
|
|
13
|
+
DEFAULT_PLAID_PRODUCTS = "auth,transactions,investments"
|
|
14
|
+
|
|
8
15
|
|
|
9
16
|
class Settings(BaseSettings):
|
|
10
17
|
# Cache / infra
|
|
@@ -14,6 +21,7 @@ class Settings(BaseSettings):
|
|
|
14
21
|
plaid_client_id: str | None = Field(default=None, alias="PLAID_CLIENT_ID")
|
|
15
22
|
plaid_secret: str | None = Field(default=None, alias="PLAID_SECRET")
|
|
16
23
|
plaid_env: str = Field(default="sandbox", alias="PLAID_ENVIRONMENT")
|
|
24
|
+
plaid_products: str = Field(default=DEFAULT_PLAID_PRODUCTS, alias="PLAID_PRODUCTS")
|
|
17
25
|
|
|
18
26
|
# Alpaca
|
|
19
27
|
alpaca_api_key: str | None = Field(default=None, alias="ALPACA_API_KEY")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: fin-infra
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: Financial infrastructure toolkit: banking connections, market data, credit, cashflows, and brokerage integrations
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: finance,banking,plaid,brokerage,markets,credit,tax,cashflow,fintech,infra
|
|
@@ -13,7 +13,7 @@ fin_infra/analytics/rebalancing_llm.py,sha256=gniB_tIahrYNZEodIZ02uXo6VLJQgq_sGz
|
|
|
13
13
|
fin_infra/analytics/savings.py,sha256=n3rGNFP8TU5mW-uz9kOuqX_mDiVnDyAeDN06Q7Abotw,7570
|
|
14
14
|
fin_infra/analytics/scenarios.py,sha256=LE_dZVkbxxAx5sxitGhiOhZfWTlYtVbIvS9pEXkijLc,12246
|
|
15
15
|
fin_infra/analytics/spending.py,sha256=ogLcfF5ZOLMkBIj02RISnA3hiY_PsLWZ2_AAzA7FenY,26209
|
|
16
|
-
fin_infra/banking/__init__.py,sha256=
|
|
16
|
+
fin_infra/banking/__init__.py,sha256=ZkWhm9QsKyYYKZ4VJ6sw0HjFdUkO9-mTYtPpUXsJjuQ,24828
|
|
17
17
|
fin_infra/banking/history.py,sha256=YB-v9A03IZ_qki6A6mA-RO5Y4imlqk1CyP0W482ufdQ,10563
|
|
18
18
|
fin_infra/banking/utils.py,sha256=HhxZbeaA8zqVttgMiJGnShTo_r_0DaD7T3IMq8n8340,15252
|
|
19
19
|
fin_infra/brokerage/__init__.py,sha256=IXm5ko5T607LodexYSbKNZc6I_2CQGaOwQUlb-w9-ks,17137
|
|
@@ -128,8 +128,8 @@ fin_infra/obs/__init__.py,sha256=kMMVl0fdwtJtZeKiusTuw0iO61Jo9-HNXsLmn3ffLRE,631
|
|
|
128
128
|
fin_infra/obs/classifier.py,sha256=S7kSphgHN1O4GiMUdr3IjuXpoXU0XgGq132_U-njXX4,5153
|
|
129
129
|
fin_infra/providers/__init__.py,sha256=jxhQm79T6DVXf7Wpy7luL-p50cE_IMUbjt4o3apzJQU,768
|
|
130
130
|
fin_infra/providers/banking/base.py,sha256=KeNU4ur3zLKHVsBF1LQifcs2AKX06IEE-Rx_SetFeAs,102
|
|
131
|
-
fin_infra/providers/banking/plaid_client.py,sha256=
|
|
132
|
-
fin_infra/providers/banking/teller_client.py,sha256=
|
|
131
|
+
fin_infra/providers/banking/plaid_client.py,sha256=7g6G427Czwwl3cN_Mdk_7DwEoVTKO7ShyDr-gle6dNM,7430
|
|
132
|
+
fin_infra/providers/banking/teller_client.py,sha256=c8wT0M0jLHdgxCxeNnJ7X9S8-qITUHEdd3oTWe_6z1U,12371
|
|
133
133
|
fin_infra/providers/base.py,sha256=T8XoHTc3SY30XibfrS4eAMXTujgY8s2mJjBeKzscgDo,9037
|
|
134
134
|
fin_infra/providers/brokerage/alpaca.py,sha256=BObiI_dFQZ3fOpTfmZMkri8sVrsz5uW6i5ZVUb0etCU,9923
|
|
135
135
|
fin_infra/providers/brokerage/base.py,sha256=JJFH0Cqca4Rg4rmxfiwcQt-peRoBf4JpG3g6jx8DVks,106
|
|
@@ -151,10 +151,10 @@ fin_infra/recurring/add.py,sha256=l_VsqJNAs-s5VZ7WFA3wfXJtjib2eqBhMJofTYgDR2w,19
|
|
|
151
151
|
fin_infra/recurring/detector.py,sha256=MCq_48V6o9Ig9lTTHM054KNh2I_udEjWBmV_iF361ac,20131
|
|
152
152
|
fin_infra/recurring/detectors_llm.py,sha256=2EMBQTIHvmxJR6gqvhlg6VNj2-eDTJiJULMxTCZMnJw,11481
|
|
153
153
|
fin_infra/recurring/ease.py,sha256=jaBFMul1LxjY2TAkSsmyaK6Kkflj8EfxwWPbyRGA8mw,11151
|
|
154
|
-
fin_infra/recurring/insights.py,sha256
|
|
154
|
+
fin_infra/recurring/insights.py,sha256=y12bCqzjSXNljMmegrrWDUhBBakB_kPsM2JrcjxczlY,15924
|
|
155
155
|
fin_infra/recurring/models.py,sha256=o0N8G-QhVb4zILEyry6M1VZ7liFJIOHwlejvn6p4K8M,8894
|
|
156
156
|
fin_infra/recurring/normalizer.py,sha256=sU4qCJ7_wVDugY0R0Td63Ol8asJNpMOHAPX92J9XJhY,9754
|
|
157
|
-
fin_infra/recurring/normalizers.py,sha256=
|
|
157
|
+
fin_infra/recurring/normalizers.py,sha256=ZCpk0KCaCvoy1jxydAb8WEULBBLFMmZKNZydz0znsks,15973
|
|
158
158
|
fin_infra/recurring/summary.py,sha256=wQshznaswIbGUPIMyayubRcRfUvVNBtyzmYx50-nqs0,14621
|
|
159
159
|
fin_infra/scaffold/__init__.py,sha256=IfL_CHHMpQB1efqY37BlIu07356tLaeVI2Mv3C0qYDs,827
|
|
160
160
|
fin_infra/scaffold/budgets.py,sha256=qLnyPh-a-ZrslstaxRtR__Bpwlz0EncSdVnCM7fDBI4,9481
|
|
@@ -167,7 +167,7 @@ fin_infra/security/models.py,sha256=s8dsvpxP-7DThUZl3Fvr3S6KVAfL5r3TKcd4uj_hCTE,
|
|
|
167
167
|
fin_infra/security/pii_filter.py,sha256=DF95mSMkk8CTGAEYtEnR-CCoOIUwE7D-9voQ-Koa3j4,8297
|
|
168
168
|
fin_infra/security/pii_patterns.py,sha256=SM-o7cL6NdgkOmtBedsN2nJZ5QPbeYehZdYmAujk8Y8,3070
|
|
169
169
|
fin_infra/security/token_store.py,sha256=FsfoAkIMQ2NRfkBuyG1eH30nnfO3w_V5tDPAZwUj9Os,6041
|
|
170
|
-
fin_infra/settings.py,sha256=
|
|
170
|
+
fin_infra/settings.py,sha256=bSRb8U1gRyHiG36lxnzeETDI8soTDeJZlG-h6mUKJKM,1783
|
|
171
171
|
fin_infra/tax/__init__.py,sha256=U0EUKQwbDqnAYwU8WRx6AD07TaB-ELdKGISOQ-904lw,6103
|
|
172
172
|
fin_infra/tax/add.py,sha256=d17Zuoi-xMjuJNykDHzQXnAUVzd_41BUMHQdqm23jJ8,14547
|
|
173
173
|
fin_infra/tax/tlh.py,sha256=rUglLeq09XxEbC2W7aJ9G0E8kj9g5QdG4ymSL4z8RK0,21477
|
|
@@ -176,8 +176,8 @@ fin_infra/utils/deprecation.py,sha256=DTcqv7ECnrWOOwoA07JOnRci4Hqqo9YtKSSmoS-DVP
|
|
|
176
176
|
fin_infra/utils/http.py,sha256=rDEgYsEBrEe75ml5RA-iSs3xeU5W-3j-czJlT7WbrM4,632
|
|
177
177
|
fin_infra/utils/retry.py,sha256=YiyTgy26eJ1ah7fE2_-ZPa4hv4bIT4OzjYolkNWb5j0,1057
|
|
178
178
|
fin_infra/version.py,sha256=4t_crzhrLum--oyowUMxtjBTzUtWp7oRTF22ewEvJG4,49
|
|
179
|
-
fin_infra-0.
|
|
180
|
-
fin_infra-0.
|
|
181
|
-
fin_infra-0.
|
|
182
|
-
fin_infra-0.
|
|
183
|
-
fin_infra-0.
|
|
179
|
+
fin_infra-0.9.0.dist-info/LICENSE,sha256=wK-Ya7Ylxa38dSIZRhvNj1ZVLIrHC-BAI8v38PNADiA,1061
|
|
180
|
+
fin_infra-0.9.0.dist-info/METADATA,sha256=Eqq4udbYHk5y0SkRm0wa_AK44_HpAbh2oGaymDV0UY8,11050
|
|
181
|
+
fin_infra-0.9.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
182
|
+
fin_infra-0.9.0.dist-info/entry_points.txt,sha256=Sr1uikvALZMeKm-DIkeKG4L9c4SNqysXGO_IRF8_9eU,53
|
|
183
|
+
fin_infra-0.9.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|