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

# Accounts

> Retrieve account balances, orders, and positions with the Go SDK

## Overview

The Accounts API provides access to account-level data including balances, buying power, positions, and order history.

## Package Reference

```go theme={null}
import (
    "fmt"
    "log"
    aries "github.com/aries-exchange/go-sdk"
)

client := aries.NewClient(
    aries.WithClientID("your_client_id"),
    aries.WithClientSecret("your_client_secret"),
)
```

## Methods

### GetBalances()

Retrieve account balances and buying power.

```go theme={null}
balances, err := client.Accounts.GetBalances("acc_123456")
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Cash: $%.2f\n", balances.Cash)
fmt.Printf("Buying Power: $%.2f\n", balances.BuyingPower)
fmt.Printf("Portfolio Value: $%.2f\n", balances.PortfolioValue)
```

**Parameters:**

* `accountID` (string): Account ID

**Returns:** `*Balances`, `error`

### GetOrders()

Retrieve all orders for an account.

```go theme={null}
orders, err := client.Accounts.GetOrders("acc_123456", &aries.OrderFilters{
    Status: "open",
})
if err != nil {
    log.Fatal(err)
}
```

**Parameters:**

* `accountID` (string): Account ID
* `filters` (\*OrderFilters, optional): Filter options

**Returns:** `[]Order`, `error`

### GetPositions()

Retrieve all positions for an account.

```go theme={null}
positions, err := client.Accounts.GetPositions("acc_123456")
if err != nil {
    log.Fatal(err)
}

for _, position := range positions {
    fmt.Printf("%s: %d shares, P/L: $%.2f\n",
        position.Symbol, position.Quantity, position.UnrealizedPL)
}
```

**Parameters:**

* `accountID` (string): Account ID

**Returns:** `[]Position`, `error`

## Type Definitions

```go theme={null}
type Balances struct {
    Cash                    float64 `json:"cash"`
    BuyingPower            float64 `json:"buying_power"`
    PortfolioValue         float64 `json:"portfolio_value"`
    Equity                 float64 `json:"equity"`
    LongMarketValue        float64 `json:"long_market_value"`
    DayTradingBuyingPower  float64 `json:"day_trading_buying_power"`
}

type Position struct {
    Symbol              string  `json:"symbol"`
    Quantity            int     `json:"quantity"`
    AverageCost         float64 `json:"average_cost"`
    CurrentPrice        float64 `json:"current_price"`
    MarketValue         float64 `json:"market_value"`
    UnrealizedPL        float64 `json:"unrealized_pl"`
    UnrealizedPLPercent float64 `json:"unrealized_pl_percent"`
    Side                string  `json:"side"`
}
```

## Examples

### Check Balance Before Trading

```go theme={null}
balances, err := client.Accounts.GetBalances("acc_123456")
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Available: $%.2f\n", balances.BuyingPower)

orderCost := 1500.00
if balances.BuyingPower >= orderCost {
    order, err := client.Orders.PlaceOrder(&aries.OrderRequest{
        Symbol:    "AAPL",
        Quantity:  10,
        Side:      "buy",
        OrderType: "market",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Order placed: %s\n", order.ID)
}
```

### Monitor Positions

```go theme={null}
positions, err := client.Accounts.GetPositions("acc_123456")
if err != nil {
    log.Fatal(err)
}

var totalPL float64
for _, position := range positions {
    fmt.Printf("%s: %d @ $%.2f\n",
        position.Symbol, position.Quantity, position.CurrentPrice)
    fmt.Printf("  P/L: $%.2f (%+.2f%%)\n",
        position.UnrealizedPL, position.UnrealizedPLPercent)

    totalPL += position.UnrealizedPL
}

fmt.Printf("\nTotal P/L: $%.2f\n", totalPL)
```

## Related APIs

* [Orders](/sdks/go/orders) - Place and manage orders
* [Users](/sdks/go/users) - Get list of user accounts
