This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-predictions / PortfolioApi

PortfolioApi ​

The user's positions and portfolio summary. Every method requires a session (UNAUTHENTICATED without one, before any request).

Methods ​

get() ​

get(params?, options?): Promise<Portfolio>

Portfolio summary: totals, open positions and open orders.

Parameters ​

params? ​

NoParams

options? ​

CallOptions

Returns ​

Promise<Portfolio>

Example ​

ts
const { totalValue, openPositions, openOrders } = await predictions.portfolio.get()

Throws ​

As in PortfolioApi.listPositions.


getPosition() ​

getPosition(input, options?): Promise<MarketPosition>

The user's position in a market, summed per side. Without a position, the numbers come as 0 (not an error). The gateway sums only the first page of 10 positions of the market.

Parameters ​

input ​
marketId ​

string

options? ​

CallOptions

Returns ​

Promise<MarketPosition>

Example ​

ts
const { yesQuantity, yesAvgPrice } = await predictions.portfolio.getPosition({ marketId: 'mkt-1' })

Throws ​

CONFIGURATION_ERROR without a request if marketId is empty, has whitespace at the start or end, has /, is . or .., and the errors of PortfolioApi.listPositions.


listPositions() ​

listPositions(params?, options?): Promise<Position[]>

Lists the user's positions. The gateway ignores filters and pagination: it always returns the first page of 100.

Parameters ​

params? ​

NoParams

options? ​

CallOptions

Returns ​

Promise<Position[]>

Example ​

ts
const positions = await predictions.portfolio.listPositions()

Throws ​

UNAUTHENTICATED without a session, NETWORK_ERROR, TIMEOUT, ABORTED, VALIDATION_ERROR or CONFIGURATION_ERROR (including after dispose()). Identify with isEnginexError(error, code).