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

# Place TP/SL Order for Position

> Place take-profit and/or stop-loss orders for an existing position

**Function:**

```
{package}::dex_accounts_entry::place_tp_sl_order_for_position
```

**ABI Object:**

```typescript theme={null}
const functionAbi: MoveFunction = {
  name: "place_tp_sl_order_for_position",
  visibility: "private",
  is_entry: true,
  is_view: false,
  generic_type_params: [],
  params: [
    "&signer",
    "0x1::object::Object<{package}::dex_accounts::Subaccount>",
    "0x1::object::Object<{package}::perp_market::PerpMarket>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<u64>",
    "0x1::option::Option<address>",
    "0x1::option::Option<u64>",
  ],
  return: [],
};
```

**Parameters:**

* `signer` - The account signer
* `subaccount` - The Trading Account object
* `market` - The PerpMarket object
* `tp_trigger_price` - Optional take-profit trigger price `` `<Option<u64>>` ``
* `tp_limit_price` - Optional take-profit limit price `` `<Option<u64>>` ``
* `tp_size` - Optional take-profit size `` `<Option<u64>>` ``
* `sl_trigger_price` - Optional stop-loss trigger price `` `<Option<u64>>` ``
* `sl_limit_price` - Optional stop-loss limit price `` `<Option<u64>>` ``
* `sl_size` - Optional stop-loss size `` `<Option<u64>>` ``
* `builder_address` - Optional builder address `` `<Option<address>>` ``
* `builder_fees` - Optional builder fee `` `<Option<u64>>` ``

**Example:**

<CodeGroup>
  ```typescript Typescript theme={null}
  const transaction = await aptos.transaction.build.simple({
    sender: account.accountAddress,
    data: {
      function: `${PACKAGE}::dex_accounts_entry::place_tp_sl_order_for_position`,
      typeArguments: [],
      functionArguments: [
        "0x123...abc", // subaccountAddr
        "0x456...def", // marketAddr (PerpMarket object address)
        6000000000, // tpTriggerPrice (optional, 6.0 with 9 decimals)
        6050000000, // tpLimitPrice (optional, 6.05 with 9 decimals)
        500000000, // tpSize (optional, 0.5 with 9 decimals)
        5500000000, // slTriggerPrice (optional, 5.5 with 9 decimals)
        5450000000, // slLimitPrice (optional, 5.45 with 9 decimals)
        500000000, // slSize (optional, 0.5 with 9 decimals)
        null, // builderAddress (optional)
        null, // builderFees (optional)
      ],
    },
  });
  ```

  ```python Python theme={null}
  transaction = rest_client.build_transaction(
      sender=account.address(),
      payload={
          "function": f"{PACKAGE}::dex_accounts_entry::place_tp_sl_order_for_position",
          "type_arguments": [],
          "function_arguments": [
              "0x123...abc",  # subaccountAddr
              "0x456...def",  # marketAddr (PerpMarket object address)
              6000000000,  # tpTriggerPrice (optional, 6.0 with 9 decimals)
              6050000000,  # tpLimitPrice (optional, 6.05 with 9 decimals)
              500000000,  # tpSize (optional, 0.5 with 9 decimals)
              5500000000,  # slTriggerPrice (optional, 5.5 with 9 decimals)
              5450000000,  # slLimitPrice (optional, 5.45 with 9 decimals)
              500000000,  # slSize (optional, 0.5 with 9 decimals)
              None,  # builderAddress (optional)
              None,  # builderFees (optional)
          ],
      },
  )
  ```
</CodeGroup>
