fmp-ai-tools 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 FMP Node Wrapper
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,217 @@
1
+ # FMP Tools
2
+
3
+ AI tools for Financial Modeling Prep (FMP) Node API - compatible with Vercel AI SDK, Langchain, OpenAI, and more.
4
+
5
+ This package provides pre-built AI tools that can be used with various AI frameworks. For direct API access, use the `fmp-node-api` package.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install fmp-tools
11
+ # or
12
+ pnpm add fmp-tools
13
+ # or
14
+ yarn add fmp-tools
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ### Vercel AI SDK (Recommended)
20
+
21
+ ```typescript
22
+ import { openai } from '@ai-sdk/openai';
23
+ import { streamText, convertToModelMessages, stepCountIs } from 'ai';
24
+ import { fmpTools } from 'fmp-tools/vercel-ai';
25
+
26
+ export async function POST(req: Request) {
27
+ const { messages } = await req.json();
28
+
29
+ const result = streamText({
30
+ model: openai('gpt-4o-mini'),
31
+ messages: convertToModelMessages(messages),
32
+ tools: fmpTools,
33
+ stopWhen: stepCountIs(5),
34
+ });
35
+
36
+ return result.toUIMessageStreamResponse();
37
+ }
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ **Important**: You must set your FMP API key as an environment variable for the tools to work:
43
+
44
+ ```bash
45
+ FMP_API_KEY=your_api_key_here
46
+ ```
47
+
48
+ The tools internally use the `fmp-node-api` library, which reads this environment variable to authenticate with the Financial Modeling Prep API.
49
+
50
+ ## Available Tools
51
+
52
+ ### Quote Tools
53
+
54
+ - `getStockQuote` - Get real-time stock quote for a company
55
+
56
+ ### Company Tools
57
+
58
+ - `getCompanyProfile` - Get comprehensive company profile and information
59
+
60
+ ### Financial Tools
61
+
62
+ - `getBalanceSheet` - Get balance sheet statements (annual/quarterly)
63
+ - `getIncomeStatement` - Get income statements (annual/quarterly)
64
+ - `getCashFlowStatement` - Get cash flow statements (annual/quarterly)
65
+ - `getFinancialRatios` - Get financial ratios and metrics (annual/quarterly)
66
+
67
+ ### Stock Tools
68
+
69
+ - `getMarketCap` - Get market capitalization for a company
70
+ - `getStockSplits` - Get historical stock splits for a company
71
+ - `getDividendHistory` - Get dividend history and payments for a company
72
+
73
+ ### Market Tools
74
+
75
+ - `getMarketPerformance` - Get overall market performance data
76
+ - `getSectorPerformance` - Get sector performance data
77
+ - `getGainers` - Get top gaining stocks
78
+ - `getLosers` - Get top losing stocks
79
+ - `getMostActive` - Get most actively traded stocks
80
+
81
+ ### Economic Tools
82
+
83
+ - `getTreasuryRates` - Get treasury rates and yields
84
+ - `getEconomicIndicators` - Get economic indicators (GDP, CPI, unemployment, etc.)
85
+
86
+ ### ETF Tools
87
+
88
+ - `getETFHoldings` - Get holdings for a specific ETF
89
+ - `getETFProfile` - Get ETF profile and information
90
+
91
+ ### Calendar Tools
92
+
93
+ - `getEarningsCalendar` - Get upcoming earnings calendar
94
+ - `getEconomicCalendar` - Get economic calendar events
95
+
96
+ ### Senate & House Trading Tools
97
+
98
+ - `getSenateTrading` - Get recent Senate trading activity
99
+ - `getHouseTrading` - Get recent House trading activity
100
+ - `getSenateTradingByName` - Get Senate trading by politician name
101
+ - `getHouseTradingByName` - Get House trading by politician name
102
+ - `getSenateTradingRSSFeed` - Get Senate trading RSS feed
103
+ - `getHouseTradingRSSFeed` - Get House trading RSS feed
104
+
105
+ ### Institutional Tools
106
+
107
+ - `getInstitutionalHolders` - Get institutional holders for a company
108
+
109
+ ### Insider Trading Tools
110
+
111
+ - `getInsiderTrading` - Get insider trading data for a company
112
+
113
+ ## Using Individual Tools
114
+
115
+ You can import and use specific tool categories or individual tools:
116
+
117
+ ### Import Specific Categories
118
+
119
+ ```typescript
120
+ import { quoteTools, financialTools, marketTools } from 'fmp-tools/vercel-ai';
121
+
122
+ // Use only quote and financial tools
123
+ const selectedTools = {
124
+ ...quoteTools,
125
+ ...financialTools,
126
+ };
127
+
128
+ // Use with Vercel AI SDK
129
+ const result = streamText({
130
+ model: openai('gpt-4o-mini'),
131
+ messages: convertToModelMessages(messages),
132
+ tools: selectedTools,
133
+ });
134
+ ```
135
+
136
+ ### Example Tool Usage
137
+
138
+ Here are some example prompts you can use with the tools:
139
+
140
+ **Stock Analysis:**
141
+
142
+ ```
143
+ "Get the current stock quote for Apple (AAPL) and show me their latest balance sheet"
144
+ ```
145
+
146
+ **Market Research:**
147
+
148
+ ```
149
+ "What are the top gaining stocks today and show me the overall market performance?"
150
+ ```
151
+
152
+ **Economic Analysis:**
153
+
154
+ ```
155
+ "Get the current treasury rates and show me the latest GDP data"
156
+ ```
157
+
158
+ **ETF Research:**
159
+
160
+ ```
161
+ "Show me the holdings of SPY ETF and get its profile information"
162
+ ```
163
+
164
+ **Financial Analysis:**
165
+
166
+ ```
167
+ "Get Apple's income statement, cash flow statement, and financial ratios for the last year"
168
+ ```
169
+
170
+ ## Tool Parameters
171
+
172
+ Each tool accepts specific parameters. Here are some common ones:
173
+
174
+ - `symbol` - Stock/ETF symbol (e.g., "AAPL", "SPY")
175
+ - `period` - For financial statements: "annual" or "quarter"
176
+ - `from` - Start date in YYYY-MM-DD format
177
+ - `to` - End date in YYYY-MM-DD format
178
+ - `name` - For economic indicators: specific indicator name
179
+
180
+ ## Error Handling
181
+
182
+ The tools handle API errors gracefully and will return informative error messages if:
183
+
184
+ - The API key is invalid or missing
185
+ - The requested data is not available
186
+ - Rate limits are exceeded
187
+ - Invalid parameters are provided
188
+
189
+ ## Testing Tools
190
+
191
+ Test individual tools:
192
+
193
+ ```bash
194
+ # Test specific tools
195
+ pnpm test:tool getStockQuote
196
+ pnpm test:tool getCompanyProfile
197
+ pnpm test:tool getBalanceSheet
198
+ pnpm test:tool getMarketPerformance
199
+ ```
200
+
201
+ ## For Direct API Access
202
+
203
+ If you need direct access to the FMP API without AI tools, use the `fmp-node-api` package:
204
+
205
+ ```typescript
206
+ import { FMP } from 'fmp-node-api';
207
+
208
+ const fmp = new FMP({ apiKey: 'your_api_key_here' });
209
+
210
+ // Direct API calls
211
+ const quote = await fmp.quote.getQuote('AAPL');
212
+ const profile = await fmp.company.getCompanyProfile('AAPL');
213
+ ```
214
+
215
+ ## License
216
+
217
+ MIT
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Tool interface that matches the ai library's expected format
3
+ * This is what the ai library produces when using their tool() function
4
+ */
5
+ interface Tool {
6
+ type: 'function';
7
+ function: {
8
+ name: string;
9
+ description: string;
10
+ parameters: {
11
+ type: 'object';
12
+ properties: Record<string, any>;
13
+ required: string[];
14
+ };
15
+ };
16
+ execute: (args: any) => Promise<string>;
17
+ }
18
+
19
+ export type { Tool };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Tool interface that matches the ai library's expected format
3
+ * This is what the ai library produces when using their tool() function
4
+ */
5
+ interface Tool {
6
+ type: 'function';
7
+ function: {
8
+ name: string;
9
+ description: string;
10
+ parameters: {
11
+ type: 'object';
12
+ properties: Record<string, any>;
13
+ required: string[];
14
+ };
15
+ };
16
+ execute: (args: any) => Promise<string>;
17
+ }
18
+
19
+ export type { Tool };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.mjs.map
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -0,0 +1,96 @@
1
+ import * as ai from 'ai';
2
+ export { ToolSet } from 'ai';
3
+
4
+ declare const quoteTools: {
5
+ getStockQuote: ai.Tool<unknown, unknown>;
6
+ };
7
+
8
+ declare const companyTools: {
9
+ getCompanyProfile: ai.Tool<unknown, unknown>;
10
+ };
11
+
12
+ declare const financialTools: {
13
+ getBalanceSheet: ai.Tool<unknown, unknown>;
14
+ getIncomeStatement: ai.Tool<unknown, unknown>;
15
+ getCashFlowStatement: ai.Tool<unknown, unknown>;
16
+ getFinancialRatios: ai.Tool<unknown, unknown>;
17
+ };
18
+
19
+ declare const calendarTools: {
20
+ getEarningsCalendar: ai.Tool<unknown, unknown>;
21
+ getEconomicCalendar: ai.Tool<unknown, unknown>;
22
+ };
23
+
24
+ declare const economicTools: {
25
+ getTreasuryRates: ai.Tool<unknown, unknown>;
26
+ getEconomicIndicators: ai.Tool<unknown, unknown>;
27
+ };
28
+
29
+ declare const etfTools: {
30
+ getETFHoldings: ai.Tool<unknown, unknown>;
31
+ getETFProfile: ai.Tool<unknown, unknown>;
32
+ };
33
+
34
+ declare const insiderTools: {
35
+ getInsiderTrading: ai.Tool<unknown, unknown>;
36
+ };
37
+
38
+ declare const institutionalTools: {
39
+ getInstitutionalHolders: ai.Tool<unknown, unknown>;
40
+ };
41
+
42
+ declare const marketTools: {
43
+ getMarketPerformance: ai.Tool<unknown, unknown>;
44
+ getSectorPerformance: ai.Tool<unknown, unknown>;
45
+ getGainers: ai.Tool<unknown, unknown>;
46
+ getLosers: ai.Tool<unknown, unknown>;
47
+ getMostActive: ai.Tool<unknown, unknown>;
48
+ };
49
+
50
+ declare const senateHouseTools: {
51
+ getSenateTrading: ai.Tool<unknown, unknown>;
52
+ getHouseTrading: ai.Tool<unknown, unknown>;
53
+ getSenateTradingByName: ai.Tool<unknown, unknown>;
54
+ getHouseTradingByName: ai.Tool<unknown, unknown>;
55
+ getSenateTradingRSSFeed: ai.Tool<unknown, unknown>;
56
+ getHouseTradingRSSFeed: ai.Tool<unknown, unknown>;
57
+ };
58
+
59
+ declare const stockTools: {
60
+ getMarketCap: ai.Tool<unknown, unknown>;
61
+ getStockSplits: ai.Tool<unknown, unknown>;
62
+ getDividendHistory: ai.Tool<unknown, unknown>;
63
+ };
64
+
65
+ declare const fmpTools: {
66
+ readonly getMarketCap: ai.Tool<unknown, unknown>;
67
+ readonly getStockSplits: ai.Tool<unknown, unknown>;
68
+ readonly getDividendHistory: ai.Tool<unknown, unknown>;
69
+ readonly getSenateTrading: ai.Tool<unknown, unknown>;
70
+ readonly getHouseTrading: ai.Tool<unknown, unknown>;
71
+ readonly getSenateTradingByName: ai.Tool<unknown, unknown>;
72
+ readonly getHouseTradingByName: ai.Tool<unknown, unknown>;
73
+ readonly getSenateTradingRSSFeed: ai.Tool<unknown, unknown>;
74
+ readonly getHouseTradingRSSFeed: ai.Tool<unknown, unknown>;
75
+ readonly getMarketPerformance: ai.Tool<unknown, unknown>;
76
+ readonly getSectorPerformance: ai.Tool<unknown, unknown>;
77
+ readonly getGainers: ai.Tool<unknown, unknown>;
78
+ readonly getLosers: ai.Tool<unknown, unknown>;
79
+ readonly getMostActive: ai.Tool<unknown, unknown>;
80
+ readonly getInstitutionalHolders: ai.Tool<unknown, unknown>;
81
+ readonly getInsiderTrading: ai.Tool<unknown, unknown>;
82
+ readonly getETFHoldings: ai.Tool<unknown, unknown>;
83
+ readonly getETFProfile: ai.Tool<unknown, unknown>;
84
+ readonly getTreasuryRates: ai.Tool<unknown, unknown>;
85
+ readonly getEconomicIndicators: ai.Tool<unknown, unknown>;
86
+ readonly getEarningsCalendar: ai.Tool<unknown, unknown>;
87
+ readonly getEconomicCalendar: ai.Tool<unknown, unknown>;
88
+ readonly getBalanceSheet: ai.Tool<unknown, unknown>;
89
+ readonly getIncomeStatement: ai.Tool<unknown, unknown>;
90
+ readonly getCashFlowStatement: ai.Tool<unknown, unknown>;
91
+ readonly getFinancialRatios: ai.Tool<unknown, unknown>;
92
+ readonly getCompanyProfile: ai.Tool<unknown, unknown>;
93
+ readonly getStockQuote: ai.Tool<unknown, unknown>;
94
+ };
95
+
96
+ export { calendarTools, companyTools, economicTools, etfTools, financialTools, fmpTools, insiderTools, institutionalTools, marketTools, quoteTools, senateHouseTools, stockTools };
@@ -0,0 +1,96 @@
1
+ import * as ai from 'ai';
2
+ export { ToolSet } from 'ai';
3
+
4
+ declare const quoteTools: {
5
+ getStockQuote: ai.Tool<unknown, unknown>;
6
+ };
7
+
8
+ declare const companyTools: {
9
+ getCompanyProfile: ai.Tool<unknown, unknown>;
10
+ };
11
+
12
+ declare const financialTools: {
13
+ getBalanceSheet: ai.Tool<unknown, unknown>;
14
+ getIncomeStatement: ai.Tool<unknown, unknown>;
15
+ getCashFlowStatement: ai.Tool<unknown, unknown>;
16
+ getFinancialRatios: ai.Tool<unknown, unknown>;
17
+ };
18
+
19
+ declare const calendarTools: {
20
+ getEarningsCalendar: ai.Tool<unknown, unknown>;
21
+ getEconomicCalendar: ai.Tool<unknown, unknown>;
22
+ };
23
+
24
+ declare const economicTools: {
25
+ getTreasuryRates: ai.Tool<unknown, unknown>;
26
+ getEconomicIndicators: ai.Tool<unknown, unknown>;
27
+ };
28
+
29
+ declare const etfTools: {
30
+ getETFHoldings: ai.Tool<unknown, unknown>;
31
+ getETFProfile: ai.Tool<unknown, unknown>;
32
+ };
33
+
34
+ declare const insiderTools: {
35
+ getInsiderTrading: ai.Tool<unknown, unknown>;
36
+ };
37
+
38
+ declare const institutionalTools: {
39
+ getInstitutionalHolders: ai.Tool<unknown, unknown>;
40
+ };
41
+
42
+ declare const marketTools: {
43
+ getMarketPerformance: ai.Tool<unknown, unknown>;
44
+ getSectorPerformance: ai.Tool<unknown, unknown>;
45
+ getGainers: ai.Tool<unknown, unknown>;
46
+ getLosers: ai.Tool<unknown, unknown>;
47
+ getMostActive: ai.Tool<unknown, unknown>;
48
+ };
49
+
50
+ declare const senateHouseTools: {
51
+ getSenateTrading: ai.Tool<unknown, unknown>;
52
+ getHouseTrading: ai.Tool<unknown, unknown>;
53
+ getSenateTradingByName: ai.Tool<unknown, unknown>;
54
+ getHouseTradingByName: ai.Tool<unknown, unknown>;
55
+ getSenateTradingRSSFeed: ai.Tool<unknown, unknown>;
56
+ getHouseTradingRSSFeed: ai.Tool<unknown, unknown>;
57
+ };
58
+
59
+ declare const stockTools: {
60
+ getMarketCap: ai.Tool<unknown, unknown>;
61
+ getStockSplits: ai.Tool<unknown, unknown>;
62
+ getDividendHistory: ai.Tool<unknown, unknown>;
63
+ };
64
+
65
+ declare const fmpTools: {
66
+ readonly getMarketCap: ai.Tool<unknown, unknown>;
67
+ readonly getStockSplits: ai.Tool<unknown, unknown>;
68
+ readonly getDividendHistory: ai.Tool<unknown, unknown>;
69
+ readonly getSenateTrading: ai.Tool<unknown, unknown>;
70
+ readonly getHouseTrading: ai.Tool<unknown, unknown>;
71
+ readonly getSenateTradingByName: ai.Tool<unknown, unknown>;
72
+ readonly getHouseTradingByName: ai.Tool<unknown, unknown>;
73
+ readonly getSenateTradingRSSFeed: ai.Tool<unknown, unknown>;
74
+ readonly getHouseTradingRSSFeed: ai.Tool<unknown, unknown>;
75
+ readonly getMarketPerformance: ai.Tool<unknown, unknown>;
76
+ readonly getSectorPerformance: ai.Tool<unknown, unknown>;
77
+ readonly getGainers: ai.Tool<unknown, unknown>;
78
+ readonly getLosers: ai.Tool<unknown, unknown>;
79
+ readonly getMostActive: ai.Tool<unknown, unknown>;
80
+ readonly getInstitutionalHolders: ai.Tool<unknown, unknown>;
81
+ readonly getInsiderTrading: ai.Tool<unknown, unknown>;
82
+ readonly getETFHoldings: ai.Tool<unknown, unknown>;
83
+ readonly getETFProfile: ai.Tool<unknown, unknown>;
84
+ readonly getTreasuryRates: ai.Tool<unknown, unknown>;
85
+ readonly getEconomicIndicators: ai.Tool<unknown, unknown>;
86
+ readonly getEarningsCalendar: ai.Tool<unknown, unknown>;
87
+ readonly getEconomicCalendar: ai.Tool<unknown, unknown>;
88
+ readonly getBalanceSheet: ai.Tool<unknown, unknown>;
89
+ readonly getIncomeStatement: ai.Tool<unknown, unknown>;
90
+ readonly getCashFlowStatement: ai.Tool<unknown, unknown>;
91
+ readonly getFinancialRatios: ai.Tool<unknown, unknown>;
92
+ readonly getCompanyProfile: ai.Tool<unknown, unknown>;
93
+ readonly getStockQuote: ai.Tool<unknown, unknown>;
94
+ };
95
+
96
+ export { calendarTools, companyTools, economicTools, etfTools, financialTools, fmpTools, insiderTools, institutionalTools, marketTools, quoteTools, senateHouseTools, stockTools };