feat(performance): consume investment performance API contract (WealthLedger/main#54)

This commit is contained in:
2026-11-08 14:20:56 +03:00
parent 010e3ab8af
commit 21383852d9
4 changed files with 716 additions and 716 deletions
@@ -0,0 +1,20 @@
import { apiQueryClient, type paths, useAuthenticatedQuery } from "@/shared/api";
type Performance = NonNullable<
paths["/api/v1/brokerage-accounts/{accountId}/performance"]["get"]["responses"][200]["content"]["application/json"]["data"]
>;
function usePerformance(accountId: string) {
return useAuthenticatedQuery({
meta: { accessGroup: "brokerage" },
...apiQueryClient.queryOptions(
"get",
"/api/v1/brokerage-accounts/{accountId}/performance",
{ params: { path: { accountId } } },
),
enabled: Boolean(accountId),
staleTime: 30_000,
});
}
export { type Performance, usePerformance };
+1
View File
@@ -0,0 +1 @@
export { type Performance, usePerformance } from "./api/usePerformance";
+241 -204
View File
@@ -276,6 +276,38 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/v1/brokerage-accounts/all/performance": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["PerformanceController_all"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/brokerage-accounts/{accountId}/performance": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["PerformanceController_account"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/brokerage-accounts/all/operations": {
parameters: {
query?: never;
@@ -708,22 +740,6 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/v1/tbank-sync/{id}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["TbankSyncController_status"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
@@ -1138,6 +1154,73 @@ export interface components {
data: components["schemas"]["PortfolioDto"] | null;
meta: components["schemas"]["InvestmentResourceMetaDto"];
};
PerformancePeriodDto: {
/** Format: date */
from: string;
/** Format: date */
to: string;
days: number;
};
/** @enum {string} */
PerformanceUnavailableReason: "ACCOUNT_VALUATION_DATES_DIFFER" | "AMBIGUOUS_RETURN" | "HISTORY_START_UNKNOWN" | "INDEX_HISTORY_UNAVAILABLE" | "NON_RUB_ACTIVITY" | "NO_SOLUTION" | "OPERATIONS_HISTORY_INCOMPLETE" | "PORTFOLIO_VALUATION_INCOMPLETE" | "UNCONFIRMED_TRANSFER" | "UNVALUED_SECURITIES_TRANSFER";
PerformanceReturnDto: {
/** @description Decimal fraction: 0.151 = 15.1% */
value: string | null;
/** @enum {string} */
basis: "annual" | "period";
unavailableReason: components["schemas"]["PerformanceUnavailableReason"] | null;
};
PerformanceIndexDto: {
/** @enum {string} */
code: "MCFTRR" | "IMOEX";
value: components["schemas"]["MoneyDto"] | null;
return: components["schemas"]["PerformanceReturnDto"];
/** Format: date */
asOf: string | null;
unavailableReason: components["schemas"]["PerformanceUnavailableReason"] | null;
};
PerformanceOutperformanceDto: {
/** @description Difference between rates as decimal fractions */
percentagePoints: string;
money: components["schemas"]["MoneyDto"];
};
PerformanceSeriesPointDto: {
/** Format: date */
date: string;
netInvested: string;
benchmarkValue: string;
referenceValue: string | null;
};
PerformanceExcludedAccountDto: {
accountId: string;
name: string;
reason: components["schemas"]["PerformanceUnavailableReason"];
};
PerformanceDto: {
accountId: string;
period: components["schemas"]["PerformancePeriodDto"];
netInvested: components["schemas"]["MoneyDto"];
currentValue: components["schemas"]["MoneyDto"];
profit: components["schemas"]["MoneyDto"];
return: components["schemas"]["PerformanceReturnDto"];
benchmark: components["schemas"]["PerformanceIndexDto"];
reference: components["schemas"]["PerformanceIndexDto"];
outperformance: components["schemas"]["PerformanceOutperformanceDto"] | null;
series: components["schemas"]["PerformanceSeriesPointDto"][];
/** @enum {string} */
completeness: "complete" | "incomplete";
excludedAccounts: components["schemas"]["PerformanceExcludedAccountDto"][];
/** Format: date-time */
calculatedAt: string;
};
PerformanceMetaDto: {
dependencies: components["schemas"]["InvestmentDependencyDto"][];
unavailable: components["schemas"]["PerformanceExcludedAccountDto"][];
};
PerformanceResourceDto: {
data: components["schemas"]["PerformanceDto"] | null;
meta: components["schemas"]["PerformanceMetaDto"];
};
BrokerageOperationDto: {
account?: components["schemas"]["AccountReferenceDto"];
id: string;
@@ -1708,84 +1791,6 @@ export interface components {
PutTbankConnectionDto: {
token: string;
};
EventsInvestmentScreenDto: {
accountId: string;
/**
* @description discriminator enum property added by openapi-typescript
* @enum {string}
*/
screen: "events";
/**
* Format: date
* @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC.
*/
from?: string;
/**
* Format: date
* @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end.
*/
to?: string;
};
IncomeInvestmentScreenDto: {
accountId: string;
/**
* @description discriminator enum property added by openapi-typescript
* @enum {string}
*/
screen: "income";
/**
* Format: date
* @description Inclusive start calendar date in Europe/Moscow (YYYY-MM-DD). Supply both from and to, or neither for the current Moscow month.
*/
from?: string;
/**
* Format: date
* @description Inclusive end calendar date in Europe/Moscow (YYYY-MM-DD). Supply both from and to, or neither. Timestamp queries use the start of the following Moscow day as the exclusive end, capped at now.
*/
to?: string;
};
SyncCandleRangeDto: {
/** Format: date-time */
from: string;
/** Format: date-time */
to: string;
};
TimestampInvestmentScreenDto: {
accountId?: string;
/** Format: uuid */
instrumentUid?: string;
query?: string;
/** @enum {string} */
candlePeriod?: "month" | "halfYear" | "year" | "all";
candleRange?: components["schemas"]["SyncCandleRangeDto"];
categories?: ("trade" | "income" | "tax" | "fee" | "transfer" | "other")[];
limit?: number;
/**
* @description discriminator enum property added by openapi-typescript
* @enum {string}
*/
screen: "accounts" | "account" | "operations" | "stocks" | "bonds" | "stock" | "bond";
/**
* Format: date-time
* @description Start instant for operations.
*/
from?: string;
/**
* Format: date-time
* @description End instant for operations.
*/
to?: string;
};
TbankSyncStatusDto: {
/** Format: uuid */
id: string;
scope: (components["schemas"]["IncomeInvestmentScreenDto"] | components["schemas"]["EventsInvestmentScreenDto"] | components["schemas"]["TimestampInvestmentScreenDto"]) | null;
/** Format: date-time */
now: string;
/** @enum {string} */
state: "running" | "succeeded" | "failed" | "cancelled";
errorCode: string | null;
};
};
responses: never;
parameters: never;
@@ -3525,6 +3530,136 @@ export interface operations {
};
};
};
PerformanceController_all: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["PerformanceResourceDto"];
};
};
/** @description Invalid request */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Authentication required */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Resource not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Internal server error */
500: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Upstream service unavailable */
503: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
};
};
PerformanceController_account: {
parameters: {
query?: never;
header?: never;
path: {
accountId: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["PerformanceResourceDto"];
};
};
/** @description Invalid request */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Authentication required */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Resource not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Internal server error */
500: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Upstream service unavailable */
503: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
};
};
BrokerageOperationsController_all: {
parameters: {
query?: {
@@ -3673,9 +3808,7 @@ export interface operations {
};
IncomeAnalyticsController_allSummary: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path?: never;
cookie?: never;
@@ -3740,7 +3873,6 @@ export interface operations {
IncomeAnalyticsController_allAnalytics: {
parameters: {
query?: {
sync?: "observe";
/** @description Inclusive calendar date in Europe/Moscow. Supply both from/to or neither. */
from?: string;
/** @description Inclusive calendar date in Europe/Moscow, no later than today. Supply both from/to or neither. */
@@ -3809,9 +3941,7 @@ export interface operations {
};
IncomeAnalyticsController_summary: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
accountId: string;
@@ -3878,7 +4008,6 @@ export interface operations {
IncomeAnalyticsController_analytics: {
parameters: {
query?: {
sync?: "observe";
/** @description Inclusive calendar date in Europe/Moscow. Supply both from/to or neither. */
from?: string;
/** @description Inclusive calendar date in Europe/Moscow, no later than today. Supply both from/to or neither. */
@@ -3950,7 +4079,6 @@ export interface operations {
UpcomingEventsController_all: {
parameters: {
query?: {
sync?: "observe";
/** @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC. */
from?: string;
/** @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end. */
@@ -4020,7 +4148,6 @@ export interface operations {
UpcomingEventsController_get: {
parameters: {
query?: {
sync?: "observe";
/** @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC. */
from?: string;
/** @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end. */
@@ -4092,7 +4219,6 @@ export interface operations {
StockController_search: {
parameters: {
query: {
sync?: "observe";
query: string;
};
header?: never;
@@ -4158,9 +4284,7 @@ export interface operations {
};
StockController_getByTicker: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
ticker: string;
@@ -4362,9 +4486,7 @@ export interface operations {
};
StockController_get: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -4430,9 +4552,7 @@ export interface operations {
};
StockController_quote: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -4499,7 +4619,6 @@ export interface operations {
StockController_candles: {
parameters: {
query?: {
sync?: "observe";
period?: "month" | "halfYear" | "year" | "all";
};
header?: never;
@@ -4633,9 +4752,7 @@ export interface operations {
};
StockController_company: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -4701,9 +4818,7 @@ export interface operations {
};
StockController_dividends: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -4769,9 +4884,7 @@ export interface operations {
};
BondController_metrics: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -4838,7 +4951,6 @@ export interface operations {
BondController_search: {
parameters: {
query: {
sync?: "observe";
query: string;
};
header?: never;
@@ -4904,9 +5016,7 @@ export interface operations {
};
BondController_getByTicker: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
ticker: string;
@@ -4972,9 +5082,7 @@ export interface operations {
};
BondController_get: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -5040,9 +5148,7 @@ export interface operations {
};
BondController_quote: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -5109,7 +5215,6 @@ export interface operations {
BondController_candles: {
parameters: {
query?: {
sync?: "observe";
period?: "month" | "halfYear" | "year" | "all";
};
header?: never;
@@ -5243,9 +5348,7 @@ export interface operations {
};
BondController_coupons: {
parameters: {
query?: {
sync?: "observe";
};
query?: never;
header?: never;
path: {
uid: string;
@@ -5503,70 +5606,4 @@ export interface operations {
};
};
};
TbankSyncController_status: {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["TbankSyncStatusDto"];
};
};
/** @description Invalid request */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Authentication required */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Resource not found */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Internal server error */
500: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
/** @description Upstream service unavailable */
503: {
headers: {
[name: string]: unknown;
};
content: {
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
};
};
};
};
}
File diff suppressed because it is too large Load Diff