> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orica.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Positions

> Track user positions and holdings.

Positions represent a user's share holdings in a market.

***

## Fetch Position

Get a user's position in a specific market:

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const position = await sdk.orica.fetchPosition(marketAddress, userPubkey);
>
> if (position) {
>   console.log("Market:", position.market.toBase58());
>   console.log("User:", position.user.toBase58());
>
>   // Outcome amounts (shares held per outcome)
>   position.outcomeAmounts.forEach((amount, i) => {
>     console.log(`Outcome ${i}: ${amount.toString()} shares`);
>   });
> } else {
>   console.log("No position in this market");
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> position = await sdk.orica.fetch_position(market_address, user_pubkey)
>
> if position:
>     print(f"Market: {position.market}")
>     print(f"User: {position.user}")
>
>     # Outcome amounts (shares held per outcome)
>     for i, amount in enumerate(position.outcome_amounts):
>         print(f"Outcome {i}: {amount} shares")
> else:
>     print("No position in this market")
> ```

***

## Fetch All User Positions (TypeScript)

Get all positions for a user across all markets:

```typescript theme={"dark"}
const positions = await sdk.orica.fetchUserPositions(userPubkey);

for (const { publicKey, account } of positions) {
  console.log("Position address:", publicKey.toBase58());
  console.log("Market:", account.market.toBase58());
  console.log("Amounts:", account.outcomeAmounts.map(a => a.toString()));
}
```

***

## Position Structure

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> interface Position {
>   market: PublicKey;
>   user: PublicKey;
>   outcomeAmounts: BN[];
>   bump: number;
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> @dataclass
> class Position:
>     market: Pubkey
>     user: Pubkey
>     outcome_amounts: list[int]
>     bump: int
> ```

***

## Calculate Position Value

Estimate the current value of a position:

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const position = await sdk.orica.fetchPosition(marketAddress, userPubkey);
> const market = await sdk.orica.fetchMarket(marketAddress);
> const prices = sdk.orica.calculatePrices(market);
>
> if (position) {
>   let totalValue = 0;
>   position.outcomeAmounts.forEach((amount, i) => {
>     const shares = amount.toNumber();
>     const value = shares * prices[i];
>     totalValue += value;
>     console.log(`${market.optionNames[i]}: ${shares} shares @ $${prices[i].toFixed(4)} = $${value.toFixed(2)}`);
>   });
>   console.log(`Total position value: $${totalValue.toFixed(2)}`);
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> position = await sdk.orica.fetch_position(market_address, user_pubkey)
> market = await sdk.orica.fetch_market(market_address)
> prices = sdk.orica.calculate_prices(market)
>
> if position:
>     total_value = 0
>     for i, amount in enumerate(position.outcome_amounts):
>         value = amount * prices[i]
>         total_value += value
>         print(f"{market.option_names[i]}: {amount} shares @ ${prices[i]:.4f} = ${value:.2f}")
>     print(f"Total position value: ${total_value:.2f}")
> ```

***

## Derive Position PDA

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> const [positionPDA, bump] = sdk.orica.pda.position(marketAddress, userPubkey);
> console.log("Position address:", positionPDA.toBase58());
> ```

> [tab] Python
>
> ```python theme={"dark"}
> position_pda, bump = sdk.orica.pda.position(market_address, user_pubkey)
> print(f"Position address: {position_pda}")
> ```

***

## Position Lifecycle

1. **Created** - First time user buys shares in a market
2. **Updated** - Each buy/sell modifies outcome amounts
3. **Redeemed** - After market resolves, winning shares are redeemed

***

## Next Steps

> [card] [Trading](https://docs.orica.markets/sdk/trading.md)
>
> Execute buy and sell operations.

> [card] [Redeeming](https://docs.orica.markets/sdk/redeeming.md)
>
> Redeem winning positions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.