get_margin_attributes
Retrieve margin account attributes like liquid portfolio value and initial margin requirements from T-Invest to manage trading positions and risk exposure.
Instructions
Получить маржинальные атрибуты счёта (ликвидный портфель, начальная маржа) из Т-Инвестиций
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | Идентификатор счёта (можно получить через get_accounts) |
Implementation Reference
- src/tools/get-user-info.ts:38-71 (handler)The 'get_margin_attributes' tool is registered and implemented within the registerGetUserInfo function in src/tools/get-user-info.ts. It handles the API call to GetMarginAttributes and formats the response.
server.tool( 'get_margin_attributes', 'Получить маржинальные атрибуты счёта (ликвидный портфель, начальная маржа) из Т-Инвестиций', { accountId: z.string().describe('Идентификатор счёта (можно получить через get_accounts)'), }, READ_ONLY, async ({ accountId }) => { try { const response = await client.post<GetMarginAttributesResponse>( API_PATHS.USERS.GET_MARGIN_ATTRIBUTES, { accountId }, ); const lines: string[] = []; if (response.liquidPortfolio) lines.push(`Ликвидный портфель: ${formatMoney(response.liquidPortfolio)}`); if (response.startingMargin) lines.push(`Начальная маржа: ${formatMoney(response.startingMargin)}`); if (response.minimalMargin) lines.push(`Минимальная маржа: ${formatMoney(response.minimalMargin)}`); if (response.amountOfMissingFunds) lines.push(`Дефицит средств: ${formatMoney(response.amountOfMissingFunds)}`); if (response.fundsSufficiencyLevel) { lines.push(`Уровень достаточности: ${quotationToNumber(response.fundsSufficiencyLevel).toFixed(4)}`); } return { content: [{ type: 'text' as const, text: lines.length > 0 ? lines.join('\n') : 'Данные недоступны.' }], }; } catch (error) { return { content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } }, );