diff --git a/stockscope/src/main/java/com/sharecomparison/infrastructure/AlphaVantageService.java b/stockscope/src/main/java/com/sharecomparison/infrastructure/AlphaVantageService.java index c226b18..3a09484 100644 --- a/stockscope/src/main/java/com/sharecomparison/infrastructure/AlphaVantageService.java +++ b/stockscope/src/main/java/com/sharecomparison/infrastructure/AlphaVantageService.java @@ -55,6 +55,12 @@ public List fetchSharePrices(String symbol, LocalDate startDate, Loca return repository.loadPrices(symbol, startDate, endDate); } + List cached = repository.loadPrices(symbol, startDate, endDate); + if (!cached.isEmpty()) { + log.debug("Returning cached prices for symbol={} ({} to {})", symbol, startDate, endDate); + return cached; + } + String json = fetchTimeSeriesDailyJson(symbol, outputSize); if (json == null) { return repository.loadPrices(symbol, startDate, endDate);