exchange.SetDirection(direction)
```direction```参数用于设置期货合约下单时的方向,可选值为:```"buy"```、```"closesell"```、```"sell"```、```"closebuy"```。
direction
true
string
```javascript
function main(){
// 举例设置为OKX期货当周合约
exchange.SetContractType("this_week")
// 设置杠杆为5倍
exchange.SetMarginLevel(5)
// 设置下单类型为做多
exchange.SetDirection("buy")
// 以10000的价格,合约数量为2张下单
exchange.Buy(10000, 2)
exchange.SetMarginLevel(5)
exchange.SetDirection("closebuy")
exchange.Sell(1000, 2)
}
def main():
exchange.SetContractType("this_week")
exchange.SetMarginLevel(5)
exchange.SetDirection("buy")
exchange.Buy(10000, 2)
exchange.SetMarginLevel(5)
exchange.SetDirection("closebuy")
exchange.Sell(1000, 2)
void main() {
exchange.SetContractType("this_week");
exchange.SetMarginLevel(5);
exchange.SetDirection("buy");
exchange.Buy(10000, 2);
exchange.SetMarginLevel(5);
exchange.SetDirection("closebuy");
exchange.Sell(1000, 2);
}
exchange.SetDirection()
Hubungan antara arah perdagangan kontrak niaga hadapan yang ditetapkan oleh fungsi dan fungsi bawah:
Fungsi bawah | Arahan untuk menetapkan parameter fungsi SetDirection | Nota: |
---|---|---|
exchange.Buy | Beli lebih banyak saham | |
exchange.Buy | Beli gudang kosong | |
exchange.Sell | Jualan gudang kosong | |
exchange.Sell | Jualan harga murah |
{@fun/Trade/exchange.Buy pertukaran.Buy}, {@fun/Trade/exchange.Sell pertukaran.Sell}
exchange.SetMarginLevel exchange.SetContractType