下单 (TRADE)
<p>[TOC]</p>
<h2>接口描述</h2>
<ul>
<li>合约下单</li>
</ul>
<h2>HTTP请求</h2>
<ul>
<li>POST <code>/perp/contract/order/place</code></li>
</ul>
<h2>请求限流</h2>
<ul>
<li>10s order rate limit(X-MBX-ORDER-COUNT-10S)为1; 1min order rate limit(X-MBX-ORDER-COUNT-1M)为1; IP rate limit(x-mbx-used-weight-1m)为0</li>
</ul>
<h2>参数类型</h2>
<ul>
<li>Body JSON</li>
</ul>
<h2>请求参数</h2>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>是否必需</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>symbol</td>
<td>STRING</td>
<td>YES</td>
<td>交易对</td>
</tr>
<tr>
<td>side</td>
<td>ENUM</td>
<td>YES</td>
<td>买卖方向 <code>SELL</code>, <code>BUY</code></td>
</tr>
<tr>
<td>positionSide</td>
<td>ENUM</td>
<td>NO</td>
<td>持仓方向,单向持仓模式下非必填,默认且仅可填<code>BOTH</code>;在双向持仓模式下必填,且仅可选择 <code>LONG</code> 或 <code>SHORT</code></td>
</tr>
<tr>
<td>type</td>
<td>ENUM</td>
<td>YES</td>
<td>订单类型 <code>LIMIT</code>, <code>MARKET</code>, <code>STOP</code>, <code>TAKE_PROFIT</code>, <code>STOP_MARKET</code>, <code>TAKE_PROFIT_MARKET</code>, <code>TRIGGER</code>,<code>TRIGGER_MARKET</code></td>
</tr>
<tr>
<td>reduceOnly</td>
<td>STRING</td>
<td>NO</td>
<td><code>true</code>, <code>false</code>; 非双开模式下默认<code>false</code>;双开模式下不接受此参数; 使用<code>closePosition</code>不支持此参数。</td>
</tr>
<tr>
<td>quantity</td>
<td>DECIMAL</td>
<td>NO</td>
<td>下单数量,使用<code>closePosition</code>不支持此参数。</td>
</tr>
<tr>
<td>price</td>
<td>DECIMAL</td>
<td>NO</td>
<td>委托价格</td>
</tr>
<tr>
<td>leverage</td>
<td>INT</td>
<td>NO</td>
<td>杠杆倍数</td>
</tr>
<tr>
<td>stopPrice</td>
<td>DECIMAL</td>
<td>NO</td>
<td>触发价, 仅 <code>STOP</code>, <code>STOP_MARKET</code>, <code>TAKE_PROFIT</code>, <code>TAKE_PROFIT_MARKET</code> 需要此参数</td>
</tr>
<tr>
<td>closePosition</td>
<td>STRING</td>
<td>NO</td>
<td><code>true</code>, <code>false</code>;触发后全部平仓,仅支持<code>STOP_MARKET</code>和<code>TAKE_PROFIT_MARKET</code>;不与<code>quantity</code>合用;自带只平仓效果,不与<code>reduceOnly</code> 合用</td>
</tr>
<tr>
<td>postOnly</td>
<td>Boolean</td>
<td>NO</td>
<td>只挂单</td>
</tr>
<tr>
<td>workingType</td>
<td>ENUM</td>
<td>NO</td>
<td>stopPrice 触发类型: <code>MARK_PRICE</code>(标记价格), <code>CONTRACT_PRICE</code>(合约最新价). 默认 <code>MARK_PRICE</code></td>
</tr>
<tr>
<td>slPrice</td>
<td>DECIMAL</td>
<td>NO</td>
<td>止损价格</td>
</tr>
<tr>
<td>tpPrice</td>
<td>DECIMAL</td>
<td>NO</td>
<td>止盈价格</td>
</tr>
</tbody>
</table>
<p>根据 order <code>type</code>的不同,某些参数强制要求,具体如下:</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>强制要求的参数</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>LIMIT</code></td>
<td> <code>quantity</code>, <code>price</code></td>
</tr>
<tr>
<td><code>MARKET</code></td>
<td><code>quantity</code></td>
</tr>
<tr>
<td><code>STOP</code>, <code>TAKE_PROFIT</code> ,<code>TRIGGER</code></td>
<td><code>quantity</code>, <code>price</code>, <code>stopPrice</code></td>
</tr>
<tr>
<td><code>STOP_MARKET</code>, <code>TAKE_PROFIT_MARKET</code>,<code>TRIGGER_MARKET</code></td>
<td><code>stopPrice</code></td>
</tr>
</tbody>
</table>
<p>> * 条件单的触发必须:</p>
<p>> <em> <code>STOP</code>, <code>STOP_MARKET</code> 止损单:
> </em> 买入: 最新合约价格/标记价格高于等于触发价<code>stopPrice</code>
> <em> 卖出: 最新合约价格/标记价格低于等于触发价<code>stopPrice</code>
> </em> <code>TAKE_PROFIT</code>, <code>TAKE_PROFIT_MARKET</code> 止盈单:
> <em> 买入: 最新合约价格/标记价格低于等于触发价<code>stopPrice</code>
> </em> 卖出: 最新合约价格/标记价格高于等于触发价<code>stopPrice</code>
> <em> <code>newOrderRespType</code> 如果传 <code>RESULT</code>:
><br />
> </em> <code>MARKET</code> 订单将直接返回成交结果;
> <em> 配合使用特殊 <code>timeInForce</code> 的 <code>LIMIT</code> 订单将直接返回成交或过期拒绝结果。
> </em> <code>STOP_MARKET</code>, <code>TAKE_PROFIT_MARKET</code> 配合 <code>closePosition</code>=<code>true</code>:
><br />
> <em> 条件单触发依照上述条件单触发逻辑
> </em> 条件触发后,平掉当时持有所有多头仓位(若为卖单)或当时持有所有空头仓位(若为买单)
> <em> 不支持 <code>quantity</code> 参数
> </em> 自带只平仓属性,不支持<code>reduceOnly</code>参数</p>
<h3>请求示例</h3>
<ul>
<li>限价单请求示例
<pre><code>{
&quot;symbol&quot;: &quot;BTC_USDT&quot;,
&quot;side&quot;: &quot;BUY&quot;,
&quot;type&quot;: &quot;LIMIT&quot;,
&quot;positionSide&quot;: &quot;BOTH&quot;,
&quot;quantity&quot;: 1,
&quot;price&quot;: 58333.26,
&quot;closePosition&quot;: false,
&quot;stopPrice&quot;: null,
&quot;workingType&quot;: &quot;MARK_PRICE&quot;,
&quot;reduceOnly&quot;: true,
&quot;leverage&quot;: 100,
&quot;slPrice&quot;: null,
&quot;tpPrice&quot;: null,
&quot;timestamp&quot;: 188888888888
}</code></pre></li>
</ul>
<h2>响应参数</h2>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th style="text-align: left;">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">code</td>
<td style="text-align: left;">string</td>
<td style="text-align: left;">返回码</td>
</tr>
<tr>
<td style="text-align: left;">msg</td>
<td style="text-align: left;">string</td>
<td style="text-align: left;">消息说明</td>
</tr>
<tr>
<td style="text-align: left;">data</td>
<td style="text-align: left;">number</td>
<td style="text-align: left;">订单号</td>
</tr>
</tbody>
</table>
<h3>响应示例</h3>
<ul>
<li>成功示例
<pre><code>{
&quot;code&quot;: &quot;0&quot;,
&quot;msg&quot;: &quot;Success&quot;,
&quot;data&quot;: 689974771346313216
}</code></pre></li>
<li>错误示例
<pre><code>{
&quot;code&quot;: &quot;10000002&quot;,
&quot;msg&quot;: &quot;invalid qty, Please choose an amount between 0.00010000000000-50.00000000000000&quot;,
&quot;data&quot;: null
}</code></pre></li>
</ul>
<h2>备注</h2>
<ul>
<li>更多返回错误代码请看首页的错误代码描述</li>
</ul>