Reputation: 33
I am using ccxt library to work with exchange. Struggling with making market order on Bybit. How it can be fixed? The error i've got is TypeError: Exchange.request() takes from 1 to 3 positional arguments but 5 were given
bybit_spot = ccxt.bybit({
"apiKey": config.bybit_API_KEY,
"secret": config.bybit_SECRET_KEY,
"options": {'defaultType': 'spot' }})
bybit_spot.private_post_spot_v1_order("GMTUSDT", "buy", "market", amount)
Upvotes: 2
Views: 3285
Reputation: 23
Hope this could help:
import ccxt from 'ccxt';
const bybit = new ccxt.bybit();
bybit.apiKey = 'YOUR_API_KEY';
bybit.secret = 'YOUR_SECRET';
const symbol = 'BTC/USDT';
const amount = 1;
const side = 'sell';
(async function () {
try {
const order = await bybit.createOrder(symbol, 'market', side, amount);
console.log(order);
const orderDetails = await bybit.fetchOrder(order.id, symbol);
console.log(orderDetails);
} catch (e) {
console.error(e);
}
})();
Upvotes: 0
Reputation: 1182
Where are you getting private_post_spot_v1_order
method from? It doesn't seem to be a ccxt method as far as I can see. The correct method for place an order is createOrder
as defined in the manual.
Here is a working example with binance but it should be the same for bybit:
import ccxt
exchange = ccxt.binance({
'apiKey': '...',
'secret': '...',
})
exchange.createOrder('BTC/USDT', 'market', 'sell', 0.1)
Let me know if it doesn't work and I will open an account with bybit to test it there.
Upvotes: 1