Skip to content

Implement Yahoo Finance API for monthly closing prices and exchange rates#205

Merged
mbianchidev merged 9 commits into
mainfrom
copilot/implement-reliable-api-monthly-prices
May 27, 2026
Merged

Implement Yahoo Finance API for monthly closing prices and exchange rates#205
mbianchidev merged 9 commits into
mainfrom
copilot/implement-reliable-api-monthly-prices

Conversation

Copilot AI commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Adds client-side API layer for fetching monthly closing asset prices and live exchange rates via Yahoo Finance (free, no API key required).

New modules

  • src/types/priceApi.ts — Types for price data, exchange rates, cache entries, and rate limit tracking
  • src/utils/priceApi.ts — Monthly closing prices via Yahoo Finance chart API (/v8/finance/chart, interval=1mo)
  • src/utils/exchangeRateApi.ts — Live FX rates via Yahoo Finance quote API (/v7/finance/quote) using EUR-based currency pairs (EURUSD=X, etc.)

Design

  • Caching: In-memory — 24h for monthly prices, 6h for exchange rates
  • Rate limiting: 500 req/day with daily reset
  • FX fallback: Degrades to existing DEFAULT_FALLBACK_RATES when Yahoo is unavailable
  • Error handling: Graceful degradation for missing data, network failures, invalid tickers

Usage

import { fetchMonthlyClosingPrices, fetchMultipleMonthlyPrices } from './utils/priceApi';
import { fetchExchangeRatesAsMap } from './utils/exchangeRateApi';

// Monthly closing prices for a single ticker
const result = await fetchMonthlyClosingPrices('MSFT', 12);
// result.prices: [{ ticker, date, open, high, low, close, volume }, ...]

// Batch fetch
const prices = await fetchMultipleMonthlyPrices(['VTI', 'BND', 'AAPL']);

// Live exchange rates, compatible with existing ExchangeRates type
const { rates, isUsingFallback } = await fetchExchangeRatesAsMap();
// rates: { EUR: 1.0, USD: 0.926, GBP: 1.163, ... }

Tests

34 new tests covering fetch logic, caching, rate limiting, error paths, and type validation.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 3 commits March 23, 2026 11:21
…orage

- Add priceApi types with provider configs, monthly closing prices, rate limits
- Add priceApi service with Yahoo Finance, Alpha Vantage, financialdata.net
  support, fallback chain, caching, and rate limiting
- Add exchangeRateApi service for live exchange rates with fallback to defaults
- Add apiKeyStorage for encrypted storage of user API keys
- Add comprehensive tests: 58 new tests (all passing)
- Full test suite: 951 tests pass, build succeeds

Co-authored-by: mbianchidev <37507190+mbianchidev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/mbianchidev/fire-tools/sessions/3b3ad307-f427-4dfd-b09d-83c29295c929
…ta.net

Remove multi-provider support per user requirement. Yahoo Finance is the
sole data source for both asset prices and exchange rates. No API key
is required. Removes apiKeyStorage utility entirely.

All 927 tests pass (893 original + 34 new), build succeeds.

Co-authored-by: mbianchidev <37507190+mbianchidev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/mbianchidev/fire-tools/sessions/3b3ad307-f427-4dfd-b09d-83c29295c929
- Use proper Date.setMonth() for accurate month subtraction
- Use vi.stubGlobal/vi.unstubAllGlobals for proper fetch mock cleanup

Co-authored-by: mbianchidev <37507190+mbianchidev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/mbianchidev/fire-tools/sessions/3b3ad307-f427-4dfd-b09d-83c29295c929
Copilot AI changed the title [WIP] Implement reliable API for monthly closing prices Implement Yahoo Finance API for monthly closing prices and exchange rates Mar 23, 2026
Copilot AI requested a review from mbianchidev March 23, 2026 11:33
mbianchidev and others added 5 commits March 23, 2026 19:56
Resolved conflict in package-lock.json by regenerating via npm install.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Restrict the build and deploy jobs to runs triggered by a tag matching
'v*' instead of every push to main. Tests still run on all branches.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mbianchidev mbianchidev marked this pull request as ready for review May 27, 2026 10:16
@mbianchidev mbianchidev merged commit e9ee7e0 into main May 27, 2026
6 checks passed
@mbianchidev mbianchidev deleted the copilot/implement-reliable-api-monthly-prices branch May 27, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement reliable API for monthly closing prices of assets and exchange rates

2 participants