Spot Margin Trade (Normal)
Documentation on interacting with ByBit's Spot Margin Trade (Normal) API functions through the PENDAX Javascript SDK.
All parameters of type INTEGER listed in the Bybit API docs need to be passed in as a string.
Get Margin Coin Info
Function name:
getMarginCoinInfo(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 getMarginCoinInfo(exchange, options) {
try {
let result = await exchange.getMarginCoinInfo(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getMarginCoinInfo(myByBitAccount);
Get Borrowable Coin Info
Function name:
getBorrowableCoinInfo(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 getBorrowableCoinInfo(exchange, options) {
try {
let result = await exchange.getBorrowableCoinInfo(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getBorrowableCoinInfo(myByBitAccount, {coin: "ETH"});
Get Interest & Quota
Function name:
getInterestAndQuota(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 getInterestAndQuota(exchange, options) {
try {
let result = await exchange.getInterestAndQuota(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getInterestAndQuota(myByBitAccount,
{
coin: "USDT"
});
Get Loan Account Info
Function name:
getLoanAccountInfo(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 getLoanAccountInfo(exchange, options) {
try {
let result = await exchange.getLoanAccountInfo(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getLoanAccountInfo(myByBitAccount);
Borrow
Function name:
borrowMargin(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 borrowMargin(exchange, options) {
try {
let result = await exchange.borrowMargin(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await borrowMargin(myByBitAccount,
{
coin: "USDT",
qty: "10"
});
Repay
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 repayMargin(exchange, options) {
try {
let result = await exchange.repayMargin(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await repayMargin(myByBitAccount,
{
coin: "USDT",
completeRepayments: "1"
});
Get Borrow Order Detail
Function name:
getBorrowOrderDetail(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 getBorrowOrderDetail(exchange, options) {
try {
let result = await exchange.getBorrowOrderDetail(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getBorrowOrderDetail(myByBitAccount);
Get Repayment Order Detail
Function name:
getRepaymentOrderDetail(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 getRepaymentOrderDetail(exchange, options) {
try {
let result = await exchange.getRepaymentOrderDetail(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getRepaymentOrderDetail(myByBitAccount);
Toggle Margin Trade
Function name:
toggleNormalMarginTrade(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 toggleNormalMarginTrade(exchange, options) {
try {
let result = await exchange.toggleNormalMarginTrade(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await toggleNormalMarginTrade(myByBitAccount,
{
switch: "1"
});