feat: expose instrument isin in portfolio positions
This commit is contained in:
@@ -41,6 +41,9 @@ export class PortfolioPositionDto {
|
||||
|
||||
@ApiProperty({ type: MoneyDto, nullable: true })
|
||||
absoluteReturn: MoneyDto | null;
|
||||
|
||||
@ApiProperty({ type: String, nullable: true })
|
||||
isin: string | null;
|
||||
}
|
||||
|
||||
export class PortfolioDto {
|
||||
|
||||
@@ -88,7 +88,7 @@ describe('PortfolioService', () => {
|
||||
],
|
||||
});
|
||||
tbank.getInstrumentByFigi
|
||||
.mockResolvedValueOnce({ ticker: 'ONE', name: 'Первая позиция' })
|
||||
.mockResolvedValueOnce({ ticker: 'ONE', name: 'Первая позиция', isin: 'RU000A0JX0J2' })
|
||||
.mockRejectedValueOnce(new Error('unavailable'));
|
||||
|
||||
await expect(service.get('user', 'account')).resolves.toMatchObject({
|
||||
@@ -100,6 +100,7 @@ describe('PortfolioService', () => {
|
||||
quantity: '2',
|
||||
currentValue: { currency: 'RUB', value: '6' },
|
||||
absoluteReturn: { currency: 'RUB', value: '2' },
|
||||
isin: 'RU000A0JX0J2',
|
||||
},
|
||||
{
|
||||
figi: 'TWO',
|
||||
@@ -107,6 +108,7 @@ describe('PortfolioService', () => {
|
||||
type: 'OTHER',
|
||||
quantity: '-0.5',
|
||||
currentValue: { currency: 'USD', value: '-2' },
|
||||
isin: null,
|
||||
},
|
||||
],
|
||||
cashBalances: [{ currency: 'RUB', value: '1.5' }],
|
||||
|
||||
@@ -44,7 +44,7 @@ const types: Record<string, string> = {
|
||||
|
||||
type CachedSnapshot = { snapshot: PortfolioDto; storedAt: number };
|
||||
type CachedMetadata = {
|
||||
value: { ticker?: string; name?: string } | null;
|
||||
value: { ticker?: string; name?: string; isin?: string } | null;
|
||||
storedAt: number;
|
||||
};
|
||||
|
||||
@@ -209,6 +209,7 @@ export class PortfolioService {
|
||||
currentValue,
|
||||
averagePurchasePrice,
|
||||
absoluteReturn,
|
||||
isin: metadata?.isin?.trim() || null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -236,7 +237,7 @@ export class PortfolioService {
|
||||
) {
|
||||
const lookup = async (
|
||||
key: string,
|
||||
fetch: () => Promise<{ ticker?: string; name?: string } | null>,
|
||||
fetch: () => Promise<{ ticker?: string; name?: string; isin?: string } | null>,
|
||||
) => {
|
||||
const cached = this.metadata.get(key);
|
||||
if (cached && Date.now() - cached.storedAt <= metadataForMs)
|
||||
|
||||
@@ -44,7 +44,7 @@ export type TbankPortfolio = {
|
||||
}[];
|
||||
};
|
||||
export type TbankPositions = { money?: TbankMoney[] };
|
||||
export type TbankInstrument = { ticker?: string; name?: string };
|
||||
export type TbankInstrument = { ticker?: string; name?: string; isin?: string };
|
||||
export type TbankTimestamp = { seconds?: string | number; nanos?: number };
|
||||
export type TbankOperationItem = {
|
||||
cursor?: string;
|
||||
|
||||
Reference in New Issue
Block a user