refactor: refactor future event list

This commit is contained in:
2026-08-20 08:23:42 +03:00
parent 5aa9bd395a
commit e0055414d6
8 changed files with 245 additions and 69 deletions
+24
View File
@@ -45,6 +45,11 @@ export type TbankPortfolio = {
};
export type TbankPositions = { money?: TbankMoney[] };
export type TbankInstrument = { ticker?: string; name?: string; isin?: string };
export type TbankDividend = {
dividendNet?: TbankMoney;
recordDate?: TbankTimestamp;
dividendType?: string;
};
export type TbankTimestamp = { seconds?: string | number; nanos?: number };
export type TbankOperationItem = {
cursor?: string;
@@ -229,6 +234,21 @@ export class TbankClient {
);
}
getDividends(
token: string,
instrumentId: string,
from: string,
to: string,
): Promise<TbankDividend[]> {
return this.call(token, this.instruments, 'getDividends', {
instrumentId,
from: { seconds: String(utcSeconds(from)) },
to: { seconds: String(utcSeconds(to)) },
}).then(
(response: { dividends?: TbankDividend[] }) => response.dividends ?? [],
);
}
private async call<Response>(
token: string,
client: TbankClientService,
@@ -307,3 +327,7 @@ export class TbankClient {
});
}
}
function utcSeconds(date: string): number {
return Math.floor(Date.parse(`${date}T00:00:00Z`) / 1000);
}