ccxt OKEx下单

ccxt OKEx placing orders

我在OKEx下了模拟订单,金额为246,价格为0.46。我在现场看,订单金额超过11k:

我获取了有关订单的信息:

{'info': {'accFillSz': '0', 'avgPx': '', 'cTime': '1652262833825', 'category': 'normal', 'ccy': '', 'clOrdId': 'e847386590ce4dBCc812b22b16d7807c', 'fee': '0', 'feeCcy': 'USDT', 'fillPx': '', 'fillSz': '0', 'fillTime': '', 'instId': 'XRP-USDT-SWAP', 'instType': 'SWAP', 'lever': '1', 'ordId': '444557778278035458', 'ordType': 'limit', 'pnl': '0', 'posSide': 'long', 'px': '0.45693', 'rebate': '0', 'rebateCcy': 'USDT', 'side': 'buy', 'slOrdPx': '-1', 'slTriggerPx': '0.44779', 'slTriggerPxType': 'mark', 'source': '', 'state': 'live', 'sz': '246', 'tag': '', 'tdMode': 'isolated', 'tgtCcy': '', 'tpOrdPx': '-1', 'tpTriggerPx': '0.46606', 'tpTriggerPxType': 'mark', 'tradeId': '', 'uTime': '1652262833825'}, 'id': '444557778278035458', 'clientOrderId': 'e847386590ce4dBCc812b22b16d7807c', 'timestamp': 1652262833825, 'datetime': '2022-05-11T09:53:53.825Z', 'lastTradeTimestamp': None, 'symbol': 'XRP/USDT:USDT', 'type': 'limit', 'timeInForce': None, 'postOnly': None, 'side': 'buy', 'price': 0.45693, 'stopPrice': 0.44779, 'average': None, 'cost': 0.0, 'amount': 246.0, 'filled': 0.0, 'remaining': 246.0, 'status': 'open', 'fee': {'cost': 0.0, 'currency': 'USDT'}, 'trades': [], 'fees': [{'cost': 0.0, 'currency': 'USDT'}]}

金额为246

这是我的代码:

exchange = ccxt.okx(
    {
        'apiKey': API_KEY,
        'secret': API_SECRET,
        'password': API_PASSPHRASE,
        'options': {
            'defaultType': 'swap'
        },
        'headers': {
            'x-simulated-trading': '1'
        }
}

exchange.load_markets()
market = exchange.market(PAIR)
params = {
    'tdMode': 'isolated',
    'posSide': 'long',
    'instId': market['id'],
    'side': 'buy',
    'sz': 246,
    'tpOrdPx': '-1',
    'slOrdPx': '-1',
    'tpTriggerPx': str(take_profit),
    'slTriggerPx': str(stop_loss),
    'tpTriggerPxType': 'mark',
    'slTriggerPxType': 'mark',
}
order = exchange.create_order(
    f"{PAIR}", ORDER_TYPE, 'buy', summa, price, params=params)
info = exchange.fetch_order(order['id'], PAIR)
print(info)

我做错了什么?

对于初学者,您只能购买 100 的倍数 XRP,如下面的屏幕截图所示,因此您只能购买 200 或 300 而不是 246。

其次,在 api 中似乎应用了 100 的乘数,其中 1 = 100 XRP。我能够通过输入 24,600 XRP 来推断出这一点,这给了你提到的大约 11,000 美元。

在您的情况下,如果您要购买 200 或 300 XRP,则需要在 api 请求中输入 2 或 3 作为金额。