交易
鉴权
签名方式:每个请求用 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=。 |
提交网格策略订单。网格以 submitted_base_price 为基准价,在 [lower_limit_price, upper_limit_price] 区间内,价格下跌时挂买单、价格上涨时挂卖单。
使用网格交易前,你需要先记录一次策略风险揭示的同意确认,详见提交策略问卷。
# Submit a percent-triggered grid on 700.HK
longbridge grid submit 700.HK --currency HKD --base-price 300 --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 rule without submitting
longbridge grid submit 700.HK --currency HKD --base-price 300 --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
请求
请求体
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
symbol | string | 必填 | 标的代码,`ticker.region` 格式,例如:`700.HK` |
settlement_currency | string | 必填 | 结算货币,例如:`HKD` |
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` - spread(绝对价差), `2` - percent(百分比) |
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` - Day(当日有效), `1` - GTC(撤单前有效), `6` - GTD(到期前有效) |
grid_trading_rule.expire_time | integer | 可选 | 到期时间(Unix 时间戳,单位秒),`time_in_force` 为 `6`(GTD)时必填 |
grid_trading_rule.upper_limit_event | integer | 可选 | 达到上边界时的动作。**可选值:**, `1` - ignore(继续运行), `2` - 按最新价平仓 |
grid_trading_rule.lower_limit_event | integer | 可选 | 达到下边界时的动作。**可选值:**, `1` - ignore(继续运行), `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": {
"order_id": "764609681686573056"
}
}错误码
参见错误码文档。