All parameters of type INTEGER listed in the Bybit API docs need to be passed in as a string.
Place Order
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 placeOrder(exchange, options) {
try {
let result = await exchange.placeOrder(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await placeOrder(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
side: 'Buy',
orderType: 'Market',
qty: '10'
});
Amend Order
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 amendOrder(exchange, options) {
try {
let result = await exchange.amendOrder(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await amendOrder(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
qty: '0.000034',
orderId: '12345'
})
Cancel Order
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 cancelOrder(exchange, options) {
try {
let result = await exchange.cancelOrder(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await cancelOrder(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
orderId: '12345'
});
Get Open Orders
Function name:
getOpenOrders(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 getOpenOrders(exchange, options) {
try {
let result = await exchange.getOpenOrders(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOpenOrders(myByBitAccount,
{
category: 'linear'
});
Cancel All Orders
Function name:
cancelAllOrders(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 cancelAllOrders(exchange, options) {
try {
let result = await exchange.cancelAllOrders(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await cancelAllOrders(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD'
});
Get Order History
Function name:
getOrderHistory(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 getOrderHistory(exchange, options) {
try {
let result = await exchange.getOrderHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOrderHistory(myByBitAccount,
{
category: 'linear'
});
Batch Place Order
This function is under construction and may behave unexpectedly
Function name:
placeBatchOrder(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 placeBatchOrder(exchange, options) {
try {
let result = await exchange.placeBatchOrder(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await placeBatchOrder(myByBitAccount,
{
category: 'linear',
request: [
{
category: 'linear',
symbol: 'BTCPERP',
side: 'Buy',
orderType: 'Market',
qty: '0.000033'
},
{
category: 'linear',
symbol: 'BTCPERP',
side: 'Buy',
orderType: 'Market',
qty: '0.000030'
}
]
});
Batch Amend Order
This function is under construction and may behave unexpectedly
Function name:
amendBatchOrder(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 amendBatchOrder(exchange, options) {
try {
let result = await exchange.amendBatchOrder(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await amendBatchOrder(myByBitAccount,
{
category: 'linear',
request: [
{
symbol: 'BTCPERP',
qty: '0.000034',
orderId: '12345'
},
{
symbol: 'BTCPERP',
orderId: '12346'
qty: '0.000030'
}
]
});
Batch Cancel Order
This function is under construction and may behave unexpectedly
Function name:
cancelBatchOrder(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 cancelBatchOrder(exchange, options) {
try {
let result = await exchange.cancelBatchOrder(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await cancelBatchOrder(myByBitAccount,
{
category: 'linear',
request: [
{
symbol: 'BTCUSD',
orderId: '12345'
},
{
symbol: 'BTCUSD',
orderId: '12346'
}
]
});
Get Borrow Quota
Function name:
getBorrowQuotaSpot(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 getBorrowQuotaSpot(exchange, options) {
try {
let result = await exchange.getBorrowQuotaSpot(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getBorrowQuotaSpot(myByBitAccount,
{
category: 'spot',
symbol: 'BTCUSDT',
side: 'buy'
});
Set Disconnect Cancel All
This function is under construction and may behave unexpectedly
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 setDcp(exchange, options) {
try {
let result = await exchange.setDcp(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setDcp(myByBitAccount,
{
timeWindow: '100'
});