我尝试通过下面的代码来做到这一点,但出现错误
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)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:ccxt.base.errors.BadRequest:binance {“code”:-1106,“msg”:“不需要时发送参数'stopPrice'。”}
在这种情况下,ccxt 文档不正确(币安停止限制,可能适用于其他交易所)。
您需要将type参数设置为stop_loss_limitor take_profit_limit(取决于是否price大于/小于stopPrice)。此外,params.type不会覆盖该type值。
type = 'stop_loss_limit'
params = {
'stopPrice': 0.20,
}
Run Code Online (Sandbox Code Playgroud)
Binance API(文档stopPrice)仅在type以下情况之一时接受参数:
并且 ccxt(GitHub 源)仅设置uppercaseType来自函数参数的值type,并且不会覆盖来自 的值params。
| 归档时间: |
|
| 查看次数: |
8209 次 |
| 最近记录: |