Trades: an open position shows no close price or P&L
Vest's position history gives an open position a placeholder close price and a $0 P&L (290.25 on an NDX short at 29,538.96). Only a closed position keeps them now — in the parser, in the stored row (a placeholder already stored is cleared on the next read) and in the API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a03bfb5605
commit
016444239e
@@ -293,6 +293,13 @@ test('parseHistoryPosition: open, snake_case, seconds, and junk', () => {
|
||||
assert.equal(open.openedAt, 1793065590000);
|
||||
assert.equal(open.closedAt, null);
|
||||
assert.equal(open.closeReason, null);
|
||||
const held = parseHistoryPosition({
|
||||
positionId: 'p3', symbol: 'NDX-USD-PERP', side: 'short', quantity: '85.7363', openPrice: '29538.96', closePrice: '290.25',
|
||||
pnl: '0.0', fee: '63.314059', funding: '0.0', openDate: 1793065422000, closeDate: null,
|
||||
});
|
||||
assert.equal(held.closePrice, null, "an open position's placeholder close price is dropped");
|
||||
assert.equal(held.pnl, null, 'and its $0 P&L');
|
||||
assert.equal(held.fee, 63.314059, 'its entry fee is real');
|
||||
assert.equal(parseHistoryPosition({ symbol: 'GC-PERP', openDate: 1 }), null, 'no id');
|
||||
assert.equal(parseHistoryPosition({ positionId: 'p2', symbol: 'GC-PERP' }), null, 'no open time');
|
||||
assert.equal(parseHistoryPosition(null), null);
|
||||
|
||||
Reference in New Issue
Block a user