dromerosm commited on
Commit
59a134d
·
1 Parent(s): 9ec3d9d

Improve logging for Yahoo Finance errors and add debug script

Browse files
Files changed (2) hide show
  1. lib/munger-engine.ts +1 -1
  2. scripts/debug_summary.ts +21 -0
lib/munger-engine.ts CHANGED
@@ -74,7 +74,7 @@ export class MungerEngine {
74
  try {
75
  summary = await yahooFinance.quoteSummary(symbol, { modules: ['financialData', 'summaryDetail', 'price'] });
76
  } catch (e) {
77
- console.warn(`Failed to fetch summary for ${symbol}`);
78
  return null;
79
  }
80
 
 
74
  try {
75
  summary = await yahooFinance.quoteSummary(symbol, { modules: ['financialData', 'summaryDetail', 'price'] });
76
  } catch (e) {
77
+ console.warn(`Failed to fetch summary for ${symbol}: ${(e as Error).message}`);
78
  return null;
79
  }
80
 
scripts/debug_summary.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import YahooFinance from 'yahoo-finance2';
2
+ const yahooFinance = new (YahooFinance as any)({});
3
+
4
+ async function test() {
5
+ console.log("Testing yahooFinance.quoteSummary for 'AAPL'...");
6
+ try {
7
+ const result = await yahooFinance.quoteSummary('AAPL', { modules: ['financialData', 'summaryDetail', 'price'] });
8
+ console.log("Success!");
9
+ console.log("FinancialData:", result.financialData ? "Found" : "Missing");
10
+ console.log("SummaryDetail:", result.summaryDetail ? "Found" : "Missing");
11
+ console.log("Price:", result.price ? "Found" : "Missing");
12
+ } catch (e: any) {
13
+ console.error("FAILED:");
14
+ console.error(e.message);
15
+ if (e.errors) {
16
+ console.error(JSON.stringify(e.errors, null, 2));
17
+ }
18
+ }
19
+ }
20
+
21
+ test();