@fre4x/yahoo-finance 1.0.42 → 1.0.45
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.
- package/README.md +1 -0
- package/dist/index.js +23 -49
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Price history, balance sheets, insider moves, analyst upgrades, options flow —
|
|
|
12
12
|
|
|
13
13
|
| Tool | What it tracks |
|
|
14
14
|
|------|---------------|
|
|
15
|
+
| `yfin_get_quotes` | Batch real-time quotes for multiple tickers |
|
|
15
16
|
| `yfin_get_historical_prices` | OHLCV bars — any ticker, any period, any interval |
|
|
16
17
|
| `yfin_get_stock_info` | Price, company profile, key statistics, financial health |
|
|
17
18
|
| `yfin_get_news` | Latest news articles for a ticker |
|
package/dist/index.js
CHANGED
|
@@ -68293,7 +68293,6 @@ async function waitIfNeeded() {
|
|
|
68293
68293
|
}
|
|
68294
68294
|
lastCallTimestamp = Date.now();
|
|
68295
68295
|
}
|
|
68296
|
-
var _YahooFinance = src_default.YahooFinance || src_default;
|
|
68297
68296
|
var config2 = {
|
|
68298
68297
|
validation: { logErrors: false },
|
|
68299
68298
|
// Use a realistic User-Agent to avoid being flagged as a bot
|
|
@@ -68308,8 +68307,8 @@ var config2 = {
|
|
|
68308
68307
|
},
|
|
68309
68308
|
// Internal queue management
|
|
68310
68309
|
queue: {
|
|
68311
|
-
concurrency: 1
|
|
68312
|
-
timeout:
|
|
68310
|
+
concurrency: 1
|
|
68311
|
+
// timeout: 60000, // v3 uses timeout in seconds or has different structure
|
|
68313
68312
|
},
|
|
68314
68313
|
logger: {
|
|
68315
68314
|
info: (...args) => console.error(...args),
|
|
@@ -68319,30 +68318,7 @@ var config2 = {
|
|
|
68319
68318
|
dir: (...args) => console.error(...args)
|
|
68320
68319
|
}
|
|
68321
68320
|
};
|
|
68322
|
-
var
|
|
68323
|
-
if (internalYf._opts) {
|
|
68324
|
-
if (!internalYf._opts.fetchOptions) {
|
|
68325
|
-
internalYf._opts.fetchOptions = {};
|
|
68326
|
-
}
|
|
68327
|
-
if (!internalYf._opts.fetchOptions.headers) {
|
|
68328
|
-
internalYf._opts.fetchOptions.headers = {};
|
|
68329
|
-
}
|
|
68330
|
-
if (!internalYf._opts.validation) {
|
|
68331
|
-
internalYf._opts.validation = {};
|
|
68332
|
-
}
|
|
68333
|
-
}
|
|
68334
|
-
if (typeof src_default.setGlobalConfig === "function") {
|
|
68335
|
-
src_default.setGlobalConfig(config2);
|
|
68336
|
-
} else if (
|
|
68337
|
-
// biome-ignore lint/suspicious/noExplicitAny: module interop
|
|
68338
|
-
typeof src_default.default?.setGlobalConfig === "function"
|
|
68339
|
-
) {
|
|
68340
|
-
src_default.default.setGlobalConfig(config2);
|
|
68341
|
-
}
|
|
68342
|
-
var yahooFinanceClient = src_default;
|
|
68343
|
-
if (typeof yahooFinanceClient.suppressNotices === "function") {
|
|
68344
|
-
yahooFinanceClient.suppressNotices(["yahooSurvey"]);
|
|
68345
|
-
}
|
|
68321
|
+
var yahooFinanceClient = new src_default(config2);
|
|
68346
68322
|
var MAX_CACHE_SIZE = 1e3;
|
|
68347
68323
|
var cache = /* @__PURE__ */ new Map();
|
|
68348
68324
|
var CACHE_TTL_MS = 60 * 1e3;
|
|
@@ -68363,24 +68339,18 @@ async function withCache(key, fetchFn) {
|
|
|
68363
68339
|
}
|
|
68364
68340
|
cache.delete(key);
|
|
68365
68341
|
}
|
|
68366
|
-
|
|
68367
|
-
const data = await fetchFn();
|
|
68342
|
+
cache.delete(key);
|
|
68368
68343
|
if (cache.size >= MAX_CACHE_SIZE) {
|
|
68369
68344
|
sweepExpiredFromCache();
|
|
68370
68345
|
}
|
|
68371
68346
|
if (cache.size >= MAX_CACHE_SIZE) {
|
|
68372
|
-
|
|
68373
|
-
let oldestTimestamp = Number.POSITIVE_INFINITY;
|
|
68374
|
-
for (const [entryKey, value] of cache) {
|
|
68375
|
-
if (value.timestamp < oldestTimestamp) {
|
|
68376
|
-
oldestTimestamp = value.timestamp;
|
|
68377
|
-
oldestKey = entryKey;
|
|
68378
|
-
}
|
|
68379
|
-
}
|
|
68347
|
+
const oldestKey = cache.keys().next().value;
|
|
68380
68348
|
if (oldestKey !== void 0) {
|
|
68381
68349
|
cache.delete(oldestKey);
|
|
68382
68350
|
}
|
|
68383
68351
|
}
|
|
68352
|
+
await waitIfNeeded();
|
|
68353
|
+
const data = await fetchFn();
|
|
68384
68354
|
cache.set(key, { data, timestamp: Date.now() });
|
|
68385
68355
|
return data;
|
|
68386
68356
|
}
|
|
@@ -68684,12 +68654,16 @@ server.registerTool(
|
|
|
68684
68654
|
tickers: external_exports3.array(external_exports3.string()).describe(
|
|
68685
68655
|
"List of ticker symbols e.g. ['AAPL', 'MSFT', 'GOOGL']"
|
|
68686
68656
|
)
|
|
68687
|
-
}),
|
|
68657
|
+
}).strict(),
|
|
68688
68658
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
68689
68659
|
},
|
|
68690
68660
|
async ({ tickers }) => {
|
|
68691
68661
|
try {
|
|
68692
|
-
const results = IS_MOCK ? MOCK_FIXTURES.getQuotes
|
|
68662
|
+
const results = IS_MOCK ? MOCK_FIXTURES.getQuotes.filter(
|
|
68663
|
+
(quote2) => tickers.some(
|
|
68664
|
+
(ticker) => String(quote2.symbol ?? "").toUpperCase() === ticker.toUpperCase()
|
|
68665
|
+
)
|
|
68666
|
+
) : await getQuotes(tickers);
|
|
68693
68667
|
if (!results || results.length === 0) {
|
|
68694
68668
|
return createNotFoundError(
|
|
68695
68669
|
"No quotes found for provided tickers."
|
|
@@ -68700,7 +68674,7 @@ server.registerTool(
|
|
|
68700
68674
|
name: q.shortName ?? q.longName ?? "",
|
|
68701
68675
|
price: q.regularMarketPrice ?? "",
|
|
68702
68676
|
change: q.regularMarketChange?.toFixed(2) ?? "",
|
|
68703
|
-
changePct: `${q.regularMarketChangePercent
|
|
68677
|
+
changePct: q.regularMarketChangePercent !== void 0 ? `${q.regularMarketChangePercent.toFixed(2)}%` : "",
|
|
68704
68678
|
currency: q.currency ?? "",
|
|
68705
68679
|
market: q.market ?? ""
|
|
68706
68680
|
}));
|
|
@@ -68747,7 +68721,7 @@ server.registerTool(
|
|
|
68747
68721
|
"3mo"
|
|
68748
68722
|
]).default("1d").describe("Bar interval"),
|
|
68749
68723
|
...paginationSchema.shape
|
|
68750
|
-
}),
|
|
68724
|
+
}).strict(),
|
|
68751
68725
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
68752
68726
|
},
|
|
68753
68727
|
async ({ ticker, period, interval, limit, offset }) => {
|
|
@@ -68795,7 +68769,7 @@ server.registerTool(
|
|
|
68795
68769
|
description: "Get comprehensive stock info including price, profile, and financials.",
|
|
68796
68770
|
inputSchema: external_exports3.object({
|
|
68797
68771
|
ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'")
|
|
68798
|
-
}),
|
|
68772
|
+
}).strict(),
|
|
68799
68773
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
68800
68774
|
},
|
|
68801
68775
|
async ({ ticker }) => {
|
|
@@ -68866,7 +68840,7 @@ server.registerTool(
|
|
|
68866
68840
|
inputSchema: external_exports3.object({
|
|
68867
68841
|
ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
|
|
68868
68842
|
...paginationSchema.shape
|
|
68869
|
-
}),
|
|
68843
|
+
}).strict(),
|
|
68870
68844
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
68871
68845
|
},
|
|
68872
68846
|
async ({ ticker, limit, offset }) => {
|
|
@@ -68906,7 +68880,7 @@ server.registerTool(
|
|
|
68906
68880
|
description: "Get stock dividend and split history.",
|
|
68907
68881
|
inputSchema: external_exports3.object({
|
|
68908
68882
|
ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'")
|
|
68909
|
-
}),
|
|
68883
|
+
}).strict(),
|
|
68910
68884
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
68911
68885
|
},
|
|
68912
68886
|
async ({ ticker }) => {
|
|
@@ -68965,7 +68939,7 @@ server.registerTool(
|
|
|
68965
68939
|
"cashflow",
|
|
68966
68940
|
"quarterly_cashflow"
|
|
68967
68941
|
]).describe("Type of financial statement")
|
|
68968
|
-
}),
|
|
68942
|
+
}).strict(),
|
|
68969
68943
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
68970
68944
|
},
|
|
68971
68945
|
async ({ ticker, financial_type }) => {
|
|
@@ -69014,7 +68988,7 @@ server.registerTool(
|
|
|
69014
68988
|
"insider_purchases",
|
|
69015
68989
|
"insider_roster_holders"
|
|
69016
68990
|
]).describe("Type of holder information")
|
|
69017
|
-
}),
|
|
68991
|
+
}).strict(),
|
|
69018
68992
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
69019
68993
|
},
|
|
69020
68994
|
async ({ ticker, holder_type }) => {
|
|
@@ -69059,7 +69033,7 @@ server.registerTool(
|
|
|
69059
69033
|
description: "Get available option expiration dates for a ticker.",
|
|
69060
69034
|
inputSchema: external_exports3.object({
|
|
69061
69035
|
ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'")
|
|
69062
|
-
}),
|
|
69036
|
+
}).strict(),
|
|
69063
69037
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
69064
69038
|
},
|
|
69065
69039
|
async ({ ticker }) => {
|
|
@@ -69087,7 +69061,7 @@ server.registerTool(
|
|
|
69087
69061
|
expiration_date: external_exports3.string().describe("Expiration date YYYY-MM-DD"),
|
|
69088
69062
|
option_type: external_exports3.enum(["calls", "puts"]).describe("Option type"),
|
|
69089
69063
|
...paginationSchema.shape
|
|
69090
|
-
}),
|
|
69064
|
+
}).strict(),
|
|
69091
69065
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
69092
69066
|
},
|
|
69093
69067
|
async ({ ticker, expiration_date, option_type, limit, offset }) => {
|
|
@@ -69135,7 +69109,7 @@ server.registerTool(
|
|
|
69135
69109
|
recommendation_type: external_exports3.enum(["recommendations", "upgrades_downgrades"]).default("recommendations").describe("Type of recommendation data"),
|
|
69136
69110
|
months_back: external_exports3.number().int().min(1).max(120).default(12).describe("Months back for upgrades/downgrades"),
|
|
69137
69111
|
...paginationSchema.shape
|
|
69138
|
-
}),
|
|
69112
|
+
}).strict(),
|
|
69139
69113
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
69140
69114
|
},
|
|
69141
69115
|
async ({ ticker, recommendation_type, months_back, limit, offset }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fre4x/yahoo-finance",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
4
4
|
"description": "A Yahoo Finance MCP server for LLMs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"start": "node dist/index.js",
|
|
17
17
|
"dev": "tsx src/index.ts",
|
|
18
18
|
"watch": "tsc -w",
|
|
19
|
+
"inspector": "cross-env MOCK=true npx @modelcontextprotocol/inspector node dist/index.js",
|
|
19
20
|
"test": "vitest run --passWithNoTests --exclude dist"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|