Position
Documentation on interacting with ByBit's Position API functions through the PENDAX Javascript SDK.
Last updated
Documentation on interacting with ByBit's Position API functions through the PENDAX Javascript SDK.
Last updated
All parameters of type INTEGER listed in the Bybit API docs need to be passed in as a string.
getPositionInfo(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getPositionInfo(exchange, options) {
try {
let result = await exchange.getPositionInfo(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getPositionInfo(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSDT'
});
setLeverage(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function setLeverage(exchange, options) {
try {
let result = await exchange.setLeverage(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setLeverage(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
buyLeverage: '6',
sellLeverage: '6'
});
switchCrossIsolatedMargin(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function switchCrossIsolatedMargin(exchange, options) {
try {
let result = await exchange.switchCrossIsolatedMargin(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await switchCrossIsolatedMargin(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
tradeMode: '0',
buyLeverage: '6',
sellLeverage: '6'
});
setTpslMode(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function setTpslMode(exchange, options) {
try {
let result = await exchange.setTpslMode(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setTpslMode(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
tpSlMode: 'Full'
});
switchPositionMode(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function switchPositionMode(exchange, options) {
try {
let result = await exchange.switchPositionMode(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await switchPositionMode(myByBitAccount,
{
category: 'linear',
mode: '0'
});
setRiskLimit(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function setRiskLimit(exchange, options) {
try {
let result = await exchange.setRiskLimit(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setRiskLimit(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSDT',
riskId: '4'
});
setTradingStop(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function setTradingStop(exchange, options) {
try {
let result = await exchange.setTradingStop(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setTradingStop(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
positionIdx: '0',
takeProfit: '0'
});
setAutoAddMargin(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function setAutoAddMargin(exchange, options) {
try {
let result = await exchange.setAutoAddMargin(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await setAutoAddMargin(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD',
autoAddMargin: '0'
});
getExecution(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getExecution(exchange, options) {
try {
let result = await exchange.getExecution(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getExecution(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD'
});
getClosedPnl(options)
import { createExchange } from "./exchanges/exchange.js";
let myByBitAccount = createExchange({
exchange: "bybit",
authenticate: "true",
key: "myKeys",
secret: "mySecret",
label: "bybit",
testnet: "false"
});
async function getClosedPnl(exchange, options) {
try {
let result = await exchange.getClosedPnl(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getClosedPnl(myByBitAccount,
{
category: 'linear',
symbol: 'BTCUSD'
});