交易
鉴权
签名方式:每个请求用 App Key / Secret 签名。请求头如下:
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string · header | 必填 | OpenAPI 后台 上的账户 Access Token,作为原始 token 传入(不带 Bearer 前缀),并参与签名计算。 |
X-Api-Key | string · header | 必填 | 你的 App Key。 |
X-Timestamp | string · header | 必填 | 请求时间戳,单位秒(Unix 时间)。 |
X-Api-Signature | string · header | 必填 | HMAC-SHA256 签名。格式:HMAC-SHA256 SignedHeaders=authorization;x-api-key;x-timestamp, Signature=。 |
修改已存在的网格订单规则。提交的 grid_trading_rule 会整体替换原有规则,因此需要传入完整的规则,而不是仅传改动的字段。
# Modify a grid order's base/bound prices and quantities
longbridge grid replace 764609681686573056 --base-price 305 --upper-price 360 --lower-price 240 --trigger-type percent --trigger-up 2 --trigger-down 2 --quantity 100 --upper-quantity 200 --lower-quantity 100 --order-type GMO --tif gtc
# Validate the new rule without applying it
longbridge grid replace 764609681686573056 --base-price 305 --upper-price 360 --lower-price 240 --trigger-type percent --trigger-up 2 --trigger-down 2 --quantity 100 --upper-quantity 200 --lower-quantity 100 --order-type GMO --tif gtc --dry-run
请求
请求体
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
order_id | string | 必填 | 网格订单 ID,例如:`764609681686573056` |
grid_trading_rule | object | 必填 | 要应用的完整网格规则,字段见下。 |
grid_trading_rule.submitted_base_price | string | 必填 | 网格锚定的基准价 |
grid_trading_rule.upper_limit_price | string | 必填 | 价格上边界 |
grid_trading_rule.lower_limit_price | string | 必填 | 价格下边界 |
grid_trading_rule.trigger_price_type | integer | 必填 | 触发阈值的计算方式。**可选值:**, `1` - 价差(绝对值), `2` - 百分比 |
grid_trading_rule.trigger_spread_up | string | 可选 | 向上触发价差,`trigger_price_type` 为 `1` 时必填 |
grid_trading_rule.trigger_spread_down | string | 可选 | 向下触发价差,`trigger_price_type` 为 `1` 时必填 |
grid_trading_rule.trigger_percent_up | string | 可选 | 向上触发百分比,`trigger_price_type` 为 `2` 时必填 |
grid_trading_rule.trigger_percent_down | string | 可选 | 向下触发百分比,`trigger_price_type` 为 `2` 时必填 |
grid_trading_rule.trigger_buy_quantity | string | 必填 | 每次触发买入数量 |
grid_trading_rule.trigger_sell_quantity | string | 必填 | 每次触发卖出数量 |
grid_trading_rule.time_in_force | integer | 必填 | 订单有效期类型。**可选值:**, `0` - 当日有效,`1` - GTC(撤单前有效), `6` - GTD(到期前有效) |
grid_trading_rule.expire_time | integer | 可选 | 到期时间(Unix 时间戳,单位秒),`time_in_force` 为 `6`(GTD)时必填 |
grid_trading_rule.upper_limit_event | integer | 可选 | 到达上边界时的动作。**可选值:**, `1` - 忽略(保持运行), `2` - 以最新价平仓 |
grid_trading_rule.lower_limit_event | integer | 可选 | 到达下边界时的动作。**可选值:**, `1` - 忽略(保持运行), `2` - 以最新价平仓 |
grid_trading_rule.trigger_sell_depth | integer | 可选 | 卖方向盘口档位(-5 ~ 5)。为 `0` 时使用 `grid_order_type_up` 而非档位 |
grid_trading_rule.trigger_buy_depth | integer | 可选 | 买方向盘口档位(-5 ~ 5)。为 `0` 时使用 `grid_order_type_down` 而非档位 |
grid_trading_rule.grid_order_type_up | string | 可选 | `trigger_sell_depth` 为 `0` 时的卖方向订单类型。**可选值:**, `GMO` / `GLO` / `GTG` |
grid_trading_rule.grid_order_type_down | string | 可选 | `trigger_buy_depth` 为 `0` 时的买方向订单类型。**可选值:**, `GMO` / `GLO` / `GTG` |
grid_trading_rule.multiple_trigger | boolean | 可选 | 单个网格档位是否可多次触发 |
grid_trading_rule.support_shortsell | boolean | 可选 | 是否允许卖空 |
grid_trading_rule.rth | integer | 可选 | 常规交易时段标志(`0` / `1` / `2`) |
响应
响应 JSON 示例
{
"code": 0,
"message": "success",
"data": {}
}错误码
参见错误码文档。