# Account and Trading

### Accounts and Trading Operations

#### Method: `account_linked`

```python
client.account_linked()
```

Retrieves a list of all linked accounts, returning plain text and encrypted account values for further use in account-related operations.

**Returns:**

* A `request.Response` object containing the linked account numbers and corresponding encrypted values.

***

#### Method: `account_details_all`

```python
client.account_details_all(fields=None)
```

Fetches detailed information for all linked accounts, including balances and optionally positions (if the `fields` parameter is set to `"positions"`).

**Parameters:**

* **fields** (`str`, optional): Set to `"positions"` to include positions in the account details. Default is `None`.

**Returns:**

* A `request.Response` object containing account details for all linked accounts.

***

#### Method: `account_details`

```python
client.account_details(accountHash, fields=None)
```

Fetches detailed information for a specific linked account, including balances and optionally positions.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **fields** (`str`, optional): Set to `"positions"` to include positions in the account details. Default is `None`.

**Returns:**

* A `request.Response` object containing account details for the specified account.

***

#### Method: `account_orders`

```python
client.account_orders(accountHash, fromEnteredTime, toEnteredTime, maxResults=None, status=None)
```

Fetches all orders for a specific linked account, with optional filtering by date, status, and other parameters. The maximum date range is one year.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **fromEnteredTime** (`datetime | str`): The start time for filtering orders.
* **toEnteredTime** (`datetime | str`): The end time for filtering orders.
* **maxResults** (`int`, optional): Maximum number of results to return. Default is `None`.
* **status** (`str`, optional): Filter orders by status (e.g., `"FILLED"`, `"CANCELED"`, etc.). Default is `None`.

**Returns:**

* A `request.Response` object containing orders for the specified account.

***

#### Method: `order_place`

```python
client.order_place(accountHash, order)
```

Places a new order for the specified account.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **order** (`dict`): A dictionary representing the order details (as specified in Schwab’s API documentation).

**Returns:**

* A `request.Response` object containing the order number in the response header (if the order is not immediately filled).

***

#### Method: `order_details`

```python
client.order_details(accountHash, orderId)
```

Retrieves details of a specific order for the specified account.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **orderId** (`str | int`): The ID of the order.

**Returns:**

* A `request.Response` object containing the order details.

***

#### Method: `order_cancel`

```python
client.order_cancel(accountHash, orderId)
```

Cancels a specific order for the specified account.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **orderId** (`str | int`): The ID of the order to cancel.

**Returns:**

* A `request.Response` object indicating the success of the cancellation.

***

#### Method: `order_replace`

```python
client.order_replace(accountHash, orderId, order)
```

Replaces an existing order with a new order. The old order is canceled, and the new order is created.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **orderId** (`str | int`): The ID of the order to replace.
* **order** (`dict`): A dictionary representing the new order details.

**Returns:**

* A `request.Response` object containing the result of the order replacement.

***

#### Method: `transactions`

```python
client.transactions(accountHash, startDate, endDate, types, symbol=None)
```

Fetches all transactions for a specific account, filtered by date and transaction type. The maximum number of transactions returned is 3,000, and the maximum date range is one year.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **startDate** (`datetime | str`): The start date for filtering transactions.
* **endDate** (`datetime | str`): The end date for filtering transactions.
* **types** (`str`): The type of transaction (e.g., `"TRADE"`, `"DIVIDEND_OR_INTEREST"`).
* **symbol** (`str`, optional): The stock symbol to filter transactions. Default is `None`.

**Returns:**

* A `request.Response` object containing the list of transactions.

***

#### Method: `transaction_details`

```python
client.transaction_details(accountHash, transactionId)
```

Retrieves specific transaction details for a given account and transaction ID.

**Parameters:**

* **accountHash** (`str`): The encrypted account hash obtained from `account_linked()`.
* **transactionId** (`str | int`): The ID of the transaction.

**Returns:**

* A `request.Response` object containing the transaction details.
