Skip to content

@livefolio/sdk / Position

Type Alias: Position

Position = object

Defined in: portfolio/types.ts:32

A single open position in an asset.

basis tracks the total cost of the position (including fees) and is used for realized P&L calculations. It is updated by applyFills as the position is added to or reduced.

Example

ts
import type { Position } from '@livefolio/sdk';

const pos: Position = {
  id:       'pos_1',
  asset:    { kind: 'equity', id: 'AAPL', symbol: 'AAPL' },
  side:     'long',
  quantity: 100,
  entry:    { date: new Date('2024-01-02'), price: 185.5 },
  basis:    18_550.50,  // quantity * price + fees
  tags:     { strategy: 'momentum' },
};

Properties

asset

asset: Asset

Defined in: portfolio/types.ts:35


basis

basis: number

Defined in: portfolio/types.ts:45

Total cost basis of the current quantity in base currency (fill price × shares + fees at entry, adjusted on partial closes).


entry

entry: object

Defined in: portfolio/types.ts:40

Price and date at which this position lot was initially opened.

date

date: Date

price

price: number


id

id: PositionId

Defined in: portfolio/types.ts:34

Stable opaque ID assigned when the position was opened.


quantity

quantity: number

Defined in: portfolio/types.ts:38

Current number of shares (or units) held.


side

side: "long" | "short"

Defined in: portfolio/types.ts:36


tags?

optional tags?: Record<string, unknown>

Defined in: portfolio/types.ts:47

Optional key-value labels for strategy attribution or downstream reporting.

Released under the MIT License.