position_get
Retrieve a specific stock position record by providing the stock code and market identifier. Use this tool to access individual holding details for portfolio management.
Instructions
获取单个持仓记录
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | 股票代码 | |
| market | Yes | 市场 |
Implementation Reference
- src/index.ts:375-389 (handler)Main handler for position_get tool that parses arguments, calls position.getPosition(), and returns the resultif (name === 'position_get') { const params = GetPositionSchema.parse(args); const result = position.getPosition(params.code, params.market as Market); if (!result) { throw new Error('Position not found'); } return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/position.ts:96-100 (handler)Implementation of getPosition function that loads positions from file and finds a single position by code and market// 获取单个持仓 export function getPosition(code: string, market: Market): Position | null { const positions = loadPositions(); return positions.find(p => p.code === code && p.market === market) || null; }
- src/index.ts:192-203 (registration)Tool registration for position_get in the ListToolsRequestSchema handler, defining the tool's name, description, and input schema{ name: 'position_get', description: '获取单个持仓记录', inputSchema: { type: 'object', properties: { code: { type: 'string', description: '股票代码' }, market: { type: 'string', enum: ['sh', 'sz', 'hk', 'us'], description: '市场' }, }, required: ['code', 'market'], }, },
- src/index.ts:47-50 (schema)Zod validation schema for position_get tool parameters (code and market)const GetPositionSchema = z.object({ code: z.string().describe('股票代码'), market: z.enum(['sh', 'sz', 'hk', 'us']).describe('市场'), });
- src/types.ts:81-90 (schema)Type definition for Position interface that defines the structure of position data returned by position_getexport interface Position { code: string; name: string; quantity: number; costPrice: number; currency: string; market: Market; createdAt: string; updatedAt: string; }