tiagosiebler / bybit-api

Node.js SDK for the Bybit APIs and WebSockets, with TypeScript & browser support.

Home Page:https://www.npmjs.com/package/bybit-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when setLeverage for Copytrade

nic-JDV opened this issue · comments

yo guys, i'm working with copy-trading-client v3 but met an error and can't find a fix

here is my code

const res2 = await client.setLeverage({ symbol: "BTCUSDT", buyLeverage: "8", sellLeverage: "8", });

I'm getting responses below
{ retCode: 10001, retMsg: 'Request parameter error.', result: {}, retExtInfo: {}, time: 1681049448842 }

any update on this?

The correct way to use the code

const res2 = await client.setLeverage("BTCUSDT", "8","8");

commented

The correct way to use the code

const res2 = await client.setLeverage("BTCUSDT", "8","8");

Good catch! This is correct, although in hindsight I should've made all these methods accept an object instead of some taking direct parameters like that. In the source it can be seen that this method expects parameters like this:
https://github.com/tiagosiebler/bybit-api/blob/master/src/copy-trading-client.ts#L116

I also recommend trying out typescript. My SDKs are heavily typed, meaning typescript would warn you that passing an object here is incorrect, before you even try to run your code. It can be a huge time saver and can catch a ton of mistakes before you ever deploy your code in production.

commented

While cleaning up some open issues, will close this since it seems resolved. If you have other comments/issues/questions, feel free to open a new issue. Thanks!