# Modify Grid Order

`POST` `/v1/gridtrading/replace`

Modify an existing grid order's rule. The whole `grid_trading_rule` is replaced with the one you submit, so pass the complete rule — not just the fields you changed.

## Parameters

### Request Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `order_id` | string | Yes | Grid order ID, example: `764609681686573056` |
| `grid_trading_rule` | object | Yes | The full grid rule to apply. Fields below. |
| `grid_trading_rule.submitted_base_price` | string | Yes | Base price the grid is anchored to |
| `grid_trading_rule.upper_limit_price` | string | Yes | Upper price bound |
| `grid_trading_rule.lower_limit_price` | string | Yes | Lower price bound |
| `grid_trading_rule.trigger_price_type` | integer | Yes | How trigger thresholds are interpreted. **Enum Value:**, `1` - spread (absolute), `2` - percent |
| `grid_trading_rule.trigger_spread_up` | string | No | Upward trigger spread, required when `trigger_price_type` is `1` |
| `grid_trading_rule.trigger_spread_down` | string | No | Downward trigger spread, required when `trigger_price_type` is `1` |
| `grid_trading_rule.trigger_percent_up` | string | No | Upward trigger percent, required when `trigger_price_type` is `2` |
| `grid_trading_rule.trigger_percent_down` | string | No | Downward trigger percent, required when `trigger_price_type` is `2` |
| `grid_trading_rule.trigger_buy_quantity` | string | Yes | Buy quantity per trigger |
| `grid_trading_rule.trigger_sell_quantity` | string | Yes | Sell quantity per trigger |
| `grid_trading_rule.time_in_force` | integer | Yes | Time in force. **Enum Value:**, `0` - Day, `1` - GTC (Good-Til-Canceled), `6` - GTD (Good-Til-Date) |
| `grid_trading_rule.expire_time` | integer | No | Expiry time (Unix timestamp, in seconds), required when `time_in_force` is `6` (GTD) |
| `grid_trading_rule.upper_limit_event` | integer | No | Action when the upper bound is reached. **Enum Value:**, `1` - ignore (keep running), `2` - close position at last price |
| `grid_trading_rule.lower_limit_event` | integer | No | Action when the lower bound is reached. **Enum Value:**, `1` - ignore (keep running), `2` - close position at last price |
| `grid_trading_rule.trigger_sell_depth` | integer | No | Sell-side order-book depth (-5 ~ 5). `0` = use `grid_order_type_up` instead of a depth level |
| `grid_trading_rule.trigger_buy_depth` | integer | No | Buy-side order-book depth (-5 ~ 5). `0` = use `grid_order_type_down` instead of a depth level |
| `grid_trading_rule.grid_order_type_up` | string | No | Sell-side order type when `trigger_sell_depth` is `0`. **Enum Value:**, `GMO` / `GLO` / `GTG` |
| `grid_trading_rule.grid_order_type_down` | string | No | Buy-side order type when `trigger_buy_depth` is `0`. **Enum Value:**, `GMO` / `GLO` / `GTG` |
| `grid_trading_rule.multiple_trigger` | boolean | No | Whether a single grid level may trigger multiple times |
| `grid_trading_rule.support_shortsell` | boolean | No | Whether short selling is allowed |
| `grid_trading_rule.rth` | integer | No | Regular-trading-hours flag (`0` / `1` / `2`) |

## Request Example

```bash
curl --request POST \
  --url 'https://openapi.longbridge.com/v1/gridtrading/replace' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{"order_id":"<order_id>","grid_trading_rule":{},"submitted_base_price":"<submitted_base_price>","upper_limit_price":"<upper_limit_price>","lower_limit_price":"<lower_limit_price>","trigger_price_type":0,"trigger_spread_up":"<trigger_spread_up>","trigger_spread_down":"<trigger_spread_down>","trigger_percent_up":"<trigger_percent_up>","trigger_percent_down":"<trigger_percent_down>","trigger_quantity":"<trigger_quantity>","upper_limit_quantity":"<upper_limit_quantity>","lower_limit_quantity":"<lower_limit_quantity>","time_in_force":0,"expire_time":0,"upper_limit_event":0,"lower_limit_event":0,"trigger_sell_depth":0,"trigger_buy_depth":0,"grid_order_type_up":"<grid_order_type_up>","grid_order_type_down":"<grid_order_type_down>","multiple_trigger":false,"support_shortsell":false,"rth":0}'
```

## Response

### Response JSON Example

```json
{
  "code": 0,
  "message": "success",
  "data": {}
}
```
