feat(#261): add tpsl params missing from position endpoints. add new endpoint for add/reduce margin. add doc examples
This commit is contained in:
3
examples/apidoc/V5/Position/README.md
Normal file
3
examples/apidoc/V5/Position/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# V5 - REST - Position
|
||||
|
||||
https://bybit-exchange.github.io/docs/v5/position
|
||||
20
examples/apidoc/V5/Position/add-or-reduce-margin.js
Normal file
20
examples/apidoc/V5/Position/add-or-reduce-margin.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.addOrReduceMargin({
|
||||
category: 'linear',
|
||||
symbol: 'BTCUSDT',
|
||||
margin: '10',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
19
examples/apidoc/V5/Position/get-closed-pnl.js
Normal file
19
examples/apidoc/V5/Position/get-closed-pnl.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.getClosedPnL({
|
||||
category: 'linear',
|
||||
limit: 1,
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
20
examples/apidoc/V5/Position/get-execution.js
Normal file
20
examples/apidoc/V5/Position/get-execution.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.addOrReduceMargin({
|
||||
category: 'linear',
|
||||
symbol: 'BTCUSDT',
|
||||
margin: '10',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
19
examples/apidoc/V5/Position/get-position-info.js
Normal file
19
examples/apidoc/V5/Position/get-position-info.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.getPositionInfo({
|
||||
category: 'inverse',
|
||||
symbol: 'BTCUSD',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
20
examples/apidoc/V5/Position/set-auto-add-margin.js
Normal file
20
examples/apidoc/V5/Position/set-auto-add-margin.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.setAutoAddMargin({
|
||||
category: 'linear',
|
||||
symbol: 'BTCUSDT',
|
||||
autoAddMargin: 1,
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
21
examples/apidoc/V5/Position/set-leverage.js
Normal file
21
examples/apidoc/V5/Position/set-leverage.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.setLeverage({
|
||||
category: 'linear',
|
||||
symbol: 'BTCUSDT',
|
||||
buyLeverage: '6',
|
||||
sellLeverage: '6',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
20
examples/apidoc/V5/Position/set-risk-limit.js
Normal file
20
examples/apidoc/V5/Position/set-risk-limit.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.setRiskLimit({
|
||||
category: 'linear',
|
||||
symbol: 'BTCUSDT',
|
||||
riskId: 4,
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
20
examples/apidoc/V5/Position/set-tpsl-mode.js
Normal file
20
examples/apidoc/V5/Position/set-tpsl-mode.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.setTPSLMode({
|
||||
symbol: 'XRPUSDT',
|
||||
category: 'linear',
|
||||
tpSlMode: 'Full',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
31
examples/apidoc/V5/Position/set-trading-stop.js
Normal file
31
examples/apidoc/V5/Position/set-trading-stop.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.setTradingStop({
|
||||
category: 'linear',
|
||||
symbol: 'XRPUSDT',
|
||||
takeProfit: '0.5',
|
||||
stopLoss: '0.2',
|
||||
tpTriggerBy: 'MarkPrice',
|
||||
slTriggerBy: 'IndexPrice',
|
||||
tpslMode: 'Partial',
|
||||
tpOrderType: 'Limit',
|
||||
slOrderType: 'Limit',
|
||||
tpSize: '50',
|
||||
slSize: '50',
|
||||
tpLimitPrice: '0.49',
|
||||
slLimitPrice: '0.21',
|
||||
positionIdx: 0,
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
22
examples/apidoc/V5/Position/switch-cross-isolated-margin.js
Normal file
22
examples/apidoc/V5/Position/switch-cross-isolated-margin.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.switchIsolatedMargin({
|
||||
category: 'linear',
|
||||
symbol: 'ETHUSDT',
|
||||
tradeMode: 1,
|
||||
buyLeverage: '10',
|
||||
sellLeverage: '10',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
20
examples/apidoc/V5/Position/switch-position-mode.js
Normal file
20
examples/apidoc/V5/Position/switch-position-mode.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.switchPositionMode({
|
||||
category: 'inverse',
|
||||
symbol: 'BTCUSDH23',
|
||||
mode: 0,
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
Reference in New Issue
Block a user