简体   繁体   中英

How to make a Bybit futures order with ccxt in python?

I use ccxt for Bybit.
I can order BTCUSD(Futures Perp) by following code.

import ccxt

bybit = ccxt.bybit({
    "apiKey":"my api",
    "secret":"my secret"
})

symbol = 'BTC/USD'
order_type = 'limit'
side = 'buy'
amount = 1
price = 10000

order = bybit.create_order(symbol, order_type, side, amount, price, {
   'qty': amount
})

But ↓this code return "ret_msg":"invalid symbol".

symbol = 'BTCUSDU21'
order_type = 'limit'
side = 'sell'
amount = 1
price = 50000

order = bybit.create_order(symbol, order_type, side, amount, price, {
   'qty': amount
})

I wanna place order in BTCUSDU21(Inverse Futures)☹

You need to pass all those parameters as a dict and I would recommend using the futuresPrivatePostOrderCreate() method.

order = bybit.futuresPrivatePostOrderCreate({
'symbol':"symbol", 
'side' : side,
'order_type' : 'Limit',
'qty' : amount,
'time_in_force': "GoodTillCancel",
'price' : price
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM