我使用以下函数: exchange.create_order(t,'market','sell',1,params={‘reduceOnly:True}’)可以关闭FTX上的位置,但我没有找到在OKX上进行交易的正确方式。请告诉我如何关闭OKX的位置好吗?
发布于 2022-05-26 17:30:17
OKX需要一些特定的参数才能打开或关闭一个位置。请查看以下简单示例:
开仓:
symbol = "LTC/USDT:USDT"
side = 'buy'
type = 'market'
amount = 1
price = None
exchange_params = {
'tdMode': 'cross' # margin: is required to be either "isolated" or "cross",
'posSide': 'long' # direction either long or short
}
open_position = exchange.create_order(symbol, type, side, amount, price, exchange_params)在执行上面的代码片段之后,市场上的一个位置将被打开,如果我们想关闭它,我们只需要发出一个相反方向的订单,如下所示:
side = 'sell' # opposite side
exchange_params = {
'tdMode': 'cross' # margin: is required to be either "isolated" or "cross",
'posSide': 'long' # opposite direction now
}
# symbol, amount, type remain the same in this case
close_position = exchange.create_order(symbol, type, side, amount, price, exchange_params)如果你需要其他的澄清,请告诉我!
https://stackoverflow.com/questions/72374644
复制相似问题