okex上的合约,开多、平多、开空、平空分别怎么写?

Author: hahahay, Created: 2018-06-03 20:50:44, Updated: 2019-07-31 17:33:51

okex的原生API,通过type字段 1:开多 2:开空 3:平多 4:平空 就能实现各种交易了。 但通过发明者量化的API怎么写呢? 是下面这样吗?

开多

exchange.SetDirection(“buy”) exchange.Buy(Price, Amount)

平多

exchange.SetDirection(“closebuy”) exchange.Sell(Price, Amount)

开空

exchange.SetDirection(“sell”) exchange.sell(Price, Amount)

平空

exchange.SetDirection(“closesell”) exchange.buy(Price, Amount)


Related

More

小小梦 是的。

小小梦 买入 开空是不行的 ,但是不会报错,实盘也不会,不过可能执行成为 买入开多。或者 买入 平空。所以这个设置方向一定要正确。

wl 那exchange.SetDirection("buy") exchange.Sell(Price, Amount) 和 exchange.SetDirection("sell") exchange.buy(Price, Amount) 字面逻辑意思分别对应“卖出开多”,“买入开空”在程序中是否会有相应操作执行。模拟回测里像并没有报错。。