我试着用下面的代码做这件事,但是我错了。
import ccxt # noqa: E402
import apiConfig
exchange = ccxt.binance({
'apiKey': apiConfig.API_KEY,
'secret': apiConfig.API_SECRET,
'enableRateLimit': True,
})
symbol = 'RVN/USDT'
type = 'limit' # or 'market', other types aren't unified yet
side = 'buy'
amount = 69 # your amount
price = 0.21 # your price
# overrides
params = {
'stopPrice': 0.20, # your stop price
'type': 'stopLimit',
}
order = exchange.create_order(symbol, type, side, amount, price, params)我得到了以下错误: ccxt.base.errors.BadRequest: binance {"code":-1106,“msg”:“参数'stopPrice‘在不需要时发送”}
发布于 2021-04-12 13:40:05
在这种情况下,ccxt文档是不正确的(对Binance的停止限制,可能与其他交换一起工作)。
您需要将type参数设置为stop_loss_limit或take_profit_limit (取决于price是否大于/小于stopPrice)。而且,params.type不覆盖type值。
type = 'stop_loss_limit'
params = {
'stopPrice': 0.20,
}Binance (文档)只在stopPrice是以下内容之一时才接受type参数:
并且ccxt (GitHub源)只从函数参数type设置uppercaseType,而不覆盖来自params的值。
https://stackoverflow.com/questions/67050373
复制相似问题