fix(ledger): 修复币种符号映射逻辑,并扩充引擎下发流水明细支持 UI 下钻
This commit is contained in:
@@ -37,6 +37,15 @@ interface Position {
|
||||
floatingPnlPercent: string;
|
||||
cumulativePnlNative: string;
|
||||
cumulativePnlPercent: string;
|
||||
transactions: TransactionRecord[];
|
||||
}
|
||||
|
||||
interface TransactionRecord {
|
||||
txType: string;
|
||||
quantity: string;
|
||||
price: string;
|
||||
txCurrency: string;
|
||||
executedAt: Date | null;
|
||||
}
|
||||
|
||||
interface RawRate {
|
||||
@@ -174,6 +183,8 @@ export async function getPortfolioPositions(): Promise<Position[]> {
|
||||
accumulatedDividendsNative: Big;
|
||||
// 首次买入日期
|
||||
firstBuyDate: Date | null;
|
||||
// 原始流水明细
|
||||
transactions: TransactionRecord[];
|
||||
}>();
|
||||
|
||||
for (const tx of allTransactions) {
|
||||
@@ -198,6 +209,7 @@ export async function getPortfolioPositions(): Promise<Position[]> {
|
||||
accumulatedDividendsCny: new Big('0'),
|
||||
accumulatedDividendsNative: new Big('0'),
|
||||
firstBuyDate: null,
|
||||
transactions: [],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,6 +277,14 @@ export async function getPortfolioPositions(): Promise<Position[]> {
|
||||
if (tx.assetLatestPrice) {
|
||||
holding.latestPrice = tx.assetLatestPrice;
|
||||
}
|
||||
|
||||
holding.transactions.push({
|
||||
txType: tx.txType,
|
||||
quantity: tx.quantity,
|
||||
price: tx.price,
|
||||
txCurrency: tx.txCurrency,
|
||||
executedAt: tx.executedAt,
|
||||
});
|
||||
}
|
||||
|
||||
const today = getTodayInShanghai();
|
||||
@@ -373,6 +393,7 @@ export async function getPortfolioPositions(): Promise<Position[]> {
|
||||
floatingPnlPercent: floatingPnlPercent.toString(),
|
||||
cumulativePnlNative: cumulativePnlNative.toString(),
|
||||
cumulativePnlPercent: cumulativePnlPercent.toString(),
|
||||
transactions: holding.transactions,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user