Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send spot limit order to ByBit, price and amount rounding #22520

Closed
Elferboy opened this issue May 16, 2024 · 2 comments
Closed

Send spot limit order to ByBit, price and amount rounding #22520

Elferboy opened this issue May 16, 2024 · 2 comments
Assignees
Labels

Comments

@Elferboy
Copy link

Elferboy commented May 16, 2024

Operating System

Windows 10

Programming Languages

PHP

CCXT Version

4.3.24

Description

Hi, there. I'm trying to open a spot SELL limit order on ByBit and I'm encountering that CCXT rounds up the variables before sending them to open the limit order. And when I look at markets for this crypto pair, it says that:

[precision][amount] => 0.01
[precision][price] => 0.0001

The changes happen in $orderRequest = \ccxt\bybit->create_order_request() of the method \ccxt\bybit->create_order(). Here $orderRequest already contains such an array:

$orderRequest: Array
(
    [symbol] => RUNEUSDT
    [side] => Sell
    [orderType] => Limit
    [price] => 10.309
    [category] => spot
    [qty] => 5
)

which is then sent via API to ByBit. I.e. price from 10.3089 became 10.309, and qty from 5.04 became 5. And on the page https://www.bybit.com/ru-RU/trade/spot/RUNE/USDT itself the price 10.3089 is set and the qty 5.04 is also set.

Code

$account = Account::getOneAsArrayById(2);

$exchange = new \ccxt\bybit([
	'apiKey'          => $account['api_key'],
	'secret'          => $account['api_secret'],
	'password'        => $account['api_password'],
	'enableRateLimit' => true,
]);

$exchange->load_time_difference();

$symbol = 'RUNEUSDT';
$amount = 5.04;
$price  = 10.3089;
$params = [
	'category' => 'spot',
];

$result = $exchange->create_limit_sell_order($symbol, $amount, $price, $params);
@ttodua ttodua self-assigned this May 17, 2024
@ttodua
Copy link
Member

ttodua commented May 17, 2024

thanks for the report! i've reproduced this. seems the issue is specific to PHP part, not in other langs.
I'll push a fix soon and let you know

@ttodua
Copy link
Member

ttodua commented May 17, 2024

seems i was in wrong direction. the problem is because of symbol id's clash.
Please try to use unified symbols format: RUNE/USDT (the slash between) for spot symbols, and RUNE/USDT:USDT format for USDT swap symbols.

$symbol = 'RUNE/USDT';
$amount = 5.04;
$price  = 10.3089;
$result = $exchange->create_order($symbol, 'limit', 'sell', $amount, $price);

it would work correctly. let us know if you'd face any further issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants