> ## 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 TWAP Order

> Place a Time-Weighted Average Price (TWAP) order

**Function:**

```
{package}::dex_accounts_entry::place_twap_order_to_subaccount_v2
```

**ABI Object:**

```typescript theme={null}
const functionAbi: MoveFunction = {
  name: "place_twap_order_to_subaccount_v2",
  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>",
    "u64",
    "bool",
    "bool",
    "0x1::option::Option<0x1::string::String>",
    "u64",
    "u64",
    "0x1::option::Option<address>",
    "0x1::option::Option<u64>",
  ],
  return: [],
};
```

**Parameters:**

* `signer` - The account signer
* `subaccount` - The Trading Account object
* `market` - The PerpMarket object
* `size` - Total size to execute (u64)
* `is_buy` - True for buy, false for sell
* `is_reduce_only` - Whether order can only reduce position
* `client_order_id` - Optional client-assigned order ID `` `<Option<String>>` ``
* `twap_frequency_seconds` - How often to execute sub-orders (u64)
* `twap_duration_seconds` - Total duration for TWAP order (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_twap_order_to_subaccount_v2`,
      typeArguments: [],
      functionArguments: [
        "0x123...abc", // subaccountAddr
        "0x456...def", // marketAddr (PerpMarket object address)
        10000000000, // size (10.0 with 9 decimals)
        true, // isBuy (true for buy, false for sell)
        false, // isReduceOnly
        null, // clientOrderId (optional)
        60, // twapFrequencySeconds (execute every 60 seconds)
        3600, // twapDurationSeconds (total duration: 1 hour)
        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_twap_order_to_subaccount_v2",
          "type_arguments": [],
          "function_arguments": [
              "0x123...abc",  # subaccountAddr
              "0x456...def",  # marketAddr (PerpMarket object address)
              10000000000,  # size (10.0 with 9 decimals)
              True,  # isBuy (true for buy, false for sell)
              False,  # isReduceOnly
              None,  # clientOrderId (optional)
              60,  # twapFrequencySeconds (execute every 60 seconds)
              3600,  # twapDurationSeconds (total duration: 1 hour)
              None,  # builderAddress (optional)
              None,  # builderFees (optional)
          ],
      },
  )
  ```
</CodeGroup>
