feat: options/F&O positions only — exclude equity holdings
This commit is contained in:
parent
60e5c7647d
commit
f809fbdaa1
1 changed files with 5 additions and 17 deletions
|
|
@ -110,24 +110,12 @@ function normaliseHolding(h: AngelHolding): Position | null {
|
||||||
* Deduplicates by key (position wins over holding for same symbol).
|
* Deduplicates by key (position wins over holding for same symbol).
|
||||||
*/
|
*/
|
||||||
export async function fetchAllPositions(): Promise<Position[]> {
|
export async function fetchAllPositions(): Promise<Position[]> {
|
||||||
const [rawPositions, rawHoldings] = await Promise.all([
|
// Holdings excluded — options/F&O positions only
|
||||||
fetchPositions(),
|
const rawPositions = await fetchPositions();
|
||||||
fetchHoldings(),
|
const results: Position[] = [];
|
||||||
]);
|
|
||||||
|
|
||||||
const map = new Map<string, Position>();
|
|
||||||
|
|
||||||
// Holdings first (lower priority)
|
|
||||||
for (const h of rawHoldings) {
|
|
||||||
const p = normaliseHolding(h);
|
|
||||||
if (p) map.set(p.key, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Positions override (intraday / F&O takes precedence)
|
|
||||||
for (const raw of rawPositions) {
|
for (const raw of rawPositions) {
|
||||||
const p = normalisePosition(raw);
|
const p = normalisePosition(raw);
|
||||||
if (p) map.set(p.key, p);
|
if (p) results.push(p);
|
||||||
}
|
}
|
||||||
|
return results;
|
||||||
return Array.from(map.values());
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue