> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/open-and-close-positions.md).

# Open & close positions

**Prerequisite:** a funded, delegated wallet — see [Set up & fund a wallet](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/set-up-and-fund-a-wallet.md).

## Pick your entry

| You want to…                  | Use                                                                                                                                                               |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enter now at market           | `open-position` with `orderType: "MARKET"` (default)                                                                                                              |
| Enter at a target price       | `open-position` with `orderType: "LIMIT"` + `limitPrice` → [Limit orders](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/limit-orders.md) |
| See the quote, commit nothing | `open-position` **without** `owner` (returns `transactionBase64: null`)                                                                                           |

## Open

```bash
curl -X POST $FLASH_API_URL/transaction-builder/open-position -d '{
  "inputTokenSymbol": "USDC", "outputTokenSymbol": "SOL",
  "inputAmountUi": "100.0", "leverage": 5.0, "tradeType": "LONG",
  "owner": "<WALLET>"
}'
```

Sign, submit to the **v2 RPC**, confirm. Attach exits in the same call with `takeProfit` / `stopLoss` → [Take-profit & stop-loss](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/take-profit-and-stop-loss.md).

→ Every field: [API reference › Trading › Open position](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/trading.md#open-position)

## Read the result

The trade response is a quote, not state. Read the position from the basket:

```bash
curl $FLASH_API_URL/owner/<WALLET>
```

→ [Read positions & orders](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/read-positions-and-orders.md)

## Close

`close-position` does both full and partial closes. Set `closeAll: true` to force a full close regardless of rounding.

```bash
# Full close
curl -X POST $FLASH_API_URL/transaction-builder/close-position -d '{
  "marketSymbol": "SOL", "side": "LONG", "inputUsdUi": "500", "closeAll": true,
  "withdrawTokenSymbol": "USDC", "owner": "<WALLET>"
}'

# Partial close ($200 of a $500 position)
curl -X POST $FLASH_API_URL/transaction-builder/close-position -d '{
  "marketSymbol": "SOL", "side": "LONG", "inputUsdUi": "200",
  "withdrawTokenSymbol": "USDC", "owner": "<WALLET>"
}'
```

→ [API reference › Trading › Close position](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/trading.md#close-position)

## Related

* Resize an open position → [Increase, decrease & reverse](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/increase-decrease-and-reverse.md)
* Lower your liquidation price → [Manage collateral](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/manage-collateral.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/open-and-close-positions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
