Trades: honor an explicit 'outside' mark on trades from before marking began
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a0e7c5b7c2
commit
c109aff3e5
@@ -29,7 +29,7 @@ export async function GET(req: Request) {
|
|||||||
const open = t.closedAt === null && t.closeReason === null && t.closedBy === null;
|
const open = t.closedAt === null && t.closeReason === null && t.closedBy === null;
|
||||||
const closedBy = open ? null
|
const closedBy = open ? null
|
||||||
: t.closedBy === 'bot' ? 'bot'
|
: t.closedBy === 'bot' ? 'bot'
|
||||||
: t.closeReason === 'user_requested' ? (tracked(t.closedAt ?? t.openedAt) ? 'outside' : 'user_requested')
|
: t.closeReason === 'user_requested' ? (t.closedBy === 'outside' || tracked(t.closedAt ?? t.openedAt) ? 'outside' : 'user_requested')
|
||||||
: t.closeReason ?? 'unknown';
|
: t.closeReason ?? 'unknown';
|
||||||
const net = open || t.pnl === null ? null
|
const net = open || t.pnl === null ? null
|
||||||
: Math.round((t.pnl - Math.abs(t.fee ?? 0) + (t.funding ?? 0)) * 100) / 100;
|
: Math.round((t.pnl - Math.abs(t.fee ?? 0) + (t.funding ?? 0)) * 100) / 100;
|
||||||
@@ -48,7 +48,7 @@ export async function GET(req: Request) {
|
|||||||
net,
|
net,
|
||||||
openedAt: t.openedAt,
|
openedAt: t.openedAt,
|
||||||
closedAt: t.closedAt,
|
closedAt: t.closedAt,
|
||||||
openedBy: t.openedBy === 'bot' ? 'bot' : tracked(t.openedAt) ? 'outside' : null,
|
openedBy: t.openedBy === 'bot' ? 'bot' : t.openedBy === 'outside' || tracked(t.openedAt) ? 'outside' : null,
|
||||||
closedBy,
|
closedBy,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -582,7 +582,9 @@ export function wipeAccountData(accountId: number): void {
|
|||||||
// Every position a platform's history shows — the bot's and anyone else's
|
// Every position a platform's history shows — the bot's and anyone else's
|
||||||
// (Vest: GET /v3/positions). The platform can't tell an API order from a
|
// (Vest: GET /v3/positions). The platform can't tell an API order from a
|
||||||
// click, so opened_by / closed_by record what this instance did itself:
|
// click, so opened_by / closed_by record what this instance did itself:
|
||||||
// 'bot' when its own order opened or closed the position, NULL otherwise.
|
// 'bot' when its own order opened or closed the position, NULL otherwise —
|
||||||
|
// or 'outside', set by hand for a trade from before marking began whose
|
||||||
|
// origin the bot's own log settles.
|
||||||
// A wipe leaves these alone: they're refetched, but the marks aren't.
|
// A wipe leaves these alone: they're refetched, but the marks aren't.
|
||||||
|
|
||||||
db.exec(`
|
db.exec(`
|
||||||
|
|||||||
Reference in New Issue
Block a user