如何使用CCXT在BYBIT上进行现货市场秩序?

发布于 2025-01-29 00:45:38 字数 363 浏览 6 评论 0原文

我正在使用CCXT库与Exchange一起工作。努力在Bybit上进行市场订单。如何修复? 我遇到的错误是TypeError:exchange.request()从1到3个位置参数,但给出了5个

 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)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

時窥 2025-02-05 00:45:38

您从哪里获得private_post_spot_v1_order从哪里获取?据我所知,这似乎不是CCXT方法。订单的正确方法是createorder,如手动

这是一个具有binance的工作示例,但是Bybit应该是相同的:

import ccxt
exchange = ccxt.binance({
    'apiKey': '...',
    'secret': '...',
})

exchange.createOrder('BTC/USDT', 'market', 'sell', 0.1)

让我知道它是否不起作用,我将与Bybit开设一个帐户以在此处测试它。

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.

浪菊怪哟 2025-02-05 00:45:38

希望这可以有所帮助:

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);
    }
})();

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);
    }
})();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文