watch_update
Update stock watchlist entries by modifying codes, markets, names, or reasons for tracking specific securities in real-time market monitoring.
Instructions
更新观察股票(名称或观察理由)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | 股票代码 | |
| market | Yes | 市场 | |
| name | No | 股票名称 | |
| reason | No | 观察理由或目标 |
Implementation Reference
- src/index.ts:410-431 (handler)Handler function for watch_update tool that parses arguments and calls watch.updateWatch implementationif (name === 'watch_update') { const params = UpdateWatchSchema.parse(args); const result = watch.updateWatch( params.code, params.market as Market, { name: params.name, reason: params.reason, } ); if (!result) { throw new Error('Watch item not found'); } return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/watch.ts:55-74 (handler)Core implementation of updateWatch function that loads watch list, finds and updates the specified stock item, then saves the listexport function updateWatch( code: string, market: Market, updates: Partial<Pick<WatchItem, 'name' | 'reason'>> ): WatchItem | null { const watchList = loadWatchList(); const index = watchList.findIndex(item => item.code === code && item.market === market); if (index === -1) { return null; } watchList[index] = { ...watchList[index], ...updates, }; saveWatchList(watchList); return watchList[index]; }
- src/index.ts:60-65 (schema)Zod schema definition for UpdateWatchSchema that validates watch_update tool parametersconst UpdateWatchSchema = z.object({ code: z.string().describe('股票代码'), market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'), name: z.string().optional().describe('股票名称'), reason: z.string().optional().describe('观察理由或目标'), });
- src/index.ts:218-231 (registration)Tool registration for watch_update in the ListTools handler with description and input schema{ name: 'watch_update', description: '更新观察股票(名称或观察理由)', inputSchema: { type: 'object', properties: { code: { type: 'string', description: '股票代码' }, market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' }, name: { type: 'string', description: '股票名称' }, reason: { type: 'string', description: '观察理由或目标' }, }, required: ['code', 'market'], }, },
- src/types.ts:93-99 (schema)Type definition for WatchItem interface used by watch_update operationsexport interface WatchItem { code: string; name: string; reason: string; market: Market; createdAt: string; }