All parameters of type INTEGER listed in the Bybit API docs need to be passed in as a string.
Get Wallet Balance
Function name:
getWalletBalance(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getWalletBalance(exchange, options) {
try {
let result = await exchange.getWalletBalance(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getWalletBalance(myByBitAccount,
{
accountType: "UNIFIED"
});
Upgrade to Unified Account
Function name:
upgradeToUta(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function upgradeToUta(exchange, options) {
try {
let result = await exchange.upgradeToUta(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await upgradeToUta(myByBitAccount);
Get Borrow History
Function name:
getBorrowHistory(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getBorrowHistory(exchange, options) {
try {
let result = await exchange.getBorrowHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getBorrowHistory(myByBitAccount,
{
currency: "USDT"
});
Get Collateral Info
Function name:
getCollateralInfo(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getCollateralInfo(exchange, options) {
try {
let result = await exchange.getCollateralInfo(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getCollateralInfo(myByBitAccount);
Get Coin Greeks
Function name:
getCoinGreeks(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getCoinGreeks(exchange, options) {
try {
let result = await exchange.getCoinGreeks(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getCoinGreeks(myByBitAccount);
Get Fee Rate
Function name:
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getFeeRate(exchange, options) {
try {
let result = await exchange.getFeeRate(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getFeeRate(myByBitAccount,
{
category: 'linear'
});
Get Account Info
Function name:
getAccountInfo(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getAccountInfo(exchange, options) {
try {
let result = await exchange.getAccountInfo(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getAccountInfo(myByBitAccount);
Get Transaction Log
Function name:
getTransactionLog(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getTransactionLog(exchange, options) {
try {
let result = await exchange.getTransactionLog(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getTransactionLog(myByBitAccount);
Set Margin Mode
Function name:
setMarginMode(options)
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function setMarginMode(exchange, options) {
try {
let result = await exchange.setMarginMode(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setMarginMode(myByBitAccount,
{
setMarginMode: "REGULAR_MARGIN"
});
Set MMP
This function is under construction and may not behave as expected
Function name:
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function setMmp(exchange, options) {
try {
let result = await exchange.setMmp(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setMmp(myByBitAccount,
{
baseCoin: "ETH",
window: "5000",
frozenPeriod: "100000",
qtyLimit: "50",
deltaLimit: "20"
});
Reset MMP
This function is under construction and may not behave as expected
Function name:
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function resetMmp(exchange, options) {
try {
let result = await exchange.resetMmp(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await resetMmp(myByBitAccount,
{
baseCoin: "BTC"
});
Get MMP State
This function is under construction and may not behave as expected
Function name:
Usage:
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getMmpState(exchange, options) {
try {
let result = await exchange.getMmpState(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getMmpState(myByBitAccount,
{
baseCoin: "ETH"
});