|
@ -369,9 +369,9 @@ export class PortfolioService { |
|
|
): Promise<PortfolioPositionDetail> { |
|
|
): Promise<PortfolioPositionDetail> { |
|
|
const userId = await this.getUserId(aImpersonationId, this.request.user.id); |
|
|
const userId = await this.getUserId(aImpersonationId, this.request.user.id); |
|
|
|
|
|
|
|
|
const orders = ( |
|
|
const orders = (await this.orderService.getOrders({ userId })).filter( |
|
|
await this.orderService.getOrders({ userId, types: ['BUY', 'SELL'] }) |
|
|
(order) => order.symbol === aSymbol |
|
|
).filter((order) => order.symbol === aSymbol); |
|
|
); |
|
|
|
|
|
|
|
|
if (orders.length <= 0) { |
|
|
if (orders.length <= 0) { |
|
|
return { |
|
|
return { |
|
@ -401,7 +401,11 @@ export class PortfolioService { |
|
|
const positionCurrency = orders[0].currency; |
|
|
const positionCurrency = orders[0].currency; |
|
|
const name = orders[0].SymbolProfile?.name ?? ''; |
|
|
const name = orders[0].SymbolProfile?.name ?? ''; |
|
|
|
|
|
|
|
|
const portfolioOrders: PortfolioOrder[] = orders.map((order) => ({ |
|
|
const portfolioOrders: PortfolioOrder[] = orders |
|
|
|
|
|
.filter((order) => { |
|
|
|
|
|
return order.type === 'BUY' || order.type === 'SELL'; |
|
|
|
|
|
}) |
|
|
|
|
|
.map((order) => ({ |
|
|
currency: order.currency, |
|
|
currency: order.currency, |
|
|
dataSource: order.dataSource, |
|
|
dataSource: order.dataSource, |
|
|
date: format(order.date, DATE_FORMAT), |
|
|
date: format(order.date, DATE_FORMAT), |
|
|