From 4b7683d5b2c683d0b099b78f1347d27611aedc46 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Fri, 9 Jun 2023 14:53:32 +0100 Subject: [PATCH] feat(): add samples & missing endpoints for spot leverage token and spot margin --- .../apidoc/V5/Spot-Leverage-Token/README.md | 3 +++ .../get-leverage-token-info.js | 16 +++++++++++++++ .../get-leveraged-token-market.js | 16 +++++++++++++++ .../get-purchase-redemption-records.js | 18 +++++++++++++++++ .../apidoc/V5/Spot-Leverage-Token/purchase.js | 20 +++++++++++++++++++ .../apidoc/V5/Spot-Leverage-Token/redeem.js | 20 +++++++++++++++++++ .../V5/Spot-Margin-Trade-(Normal)/README.md | 3 +++ .../V5/Spot-Margin-Trade-(Normal)/borrow.js | 16 +++++++++++++++ .../get-borrow-order-detail.js | 16 +++++++++++++++ .../get-borrowable-coin-info.js | 16 +++++++++++++++ .../get-interest-and-quota.js | 16 +++++++++++++++ .../get-loan-account-info.js | 16 +++++++++++++++ .../get-margin-coin-info.js | 16 +++++++++++++++ .../get-repayment-order-detail.js | 16 +++++++++++++++ .../V5/Spot-Margin-Trade-(Normal)/repay.js | 16 +++++++++++++++ .../toggle-margin-trade-normal.js | 16 +++++++++++++++ .../V5/Spot-Margin-Trade-(UTA)/README.md | 3 +++ .../Spot-Margin-Trade-(UTA)/set-leverage.js | 16 +++++++++++++++ .../toggle-margin-trade.js | 16 +++++++++++++++ 19 files changed, 275 insertions(+) create mode 100644 examples/apidoc/V5/Spot-Leverage-Token/README.md create mode 100644 examples/apidoc/V5/Spot-Leverage-Token/get-leverage-token-info.js create mode 100644 examples/apidoc/V5/Spot-Leverage-Token/get-leveraged-token-market.js create mode 100644 examples/apidoc/V5/Spot-Leverage-Token/get-purchase-redemption-records.js create mode 100644 examples/apidoc/V5/Spot-Leverage-Token/purchase.js create mode 100644 examples/apidoc/V5/Spot-Leverage-Token/redeem.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/README.md create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/borrow.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrow-order-detail.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrowable-coin-info.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-interest-and-quota.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-loan-account-info.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-margin-coin-info.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-repayment-order-detail.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/repay.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(Normal)/toggle-margin-trade-normal.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(UTA)/README.md create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(UTA)/set-leverage.js create mode 100644 examples/apidoc/V5/Spot-Margin-Trade-(UTA)/toggle-margin-trade.js diff --git a/examples/apidoc/V5/Spot-Leverage-Token/README.md b/examples/apidoc/V5/Spot-Leverage-Token/README.md new file mode 100644 index 0000000..a28b252 --- /dev/null +++ b/examples/apidoc/V5/Spot-Leverage-Token/README.md @@ -0,0 +1,3 @@ +# V5 - REST - Spot Leverage Token + +https://bybit-exchange.github.io/docs/v5/lt/leverage-token-info diff --git a/examples/apidoc/V5/Spot-Leverage-Token/get-leverage-token-info.js b/examples/apidoc/V5/Spot-Leverage-Token/get-leverage-token-info.js new file mode 100644 index 0000000..ad5c82d --- /dev/null +++ b/examples/apidoc/V5/Spot-Leverage-Token/get-leverage-token-info.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getLeveragedTokenInfo('BTC3L') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Leverage-Token/get-leveraged-token-market.js b/examples/apidoc/V5/Spot-Leverage-Token/get-leveraged-token-market.js new file mode 100644 index 0000000..8303f11 --- /dev/null +++ b/examples/apidoc/V5/Spot-Leverage-Token/get-leveraged-token-market.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getLeveragedTokenMarket('BTC3L') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Leverage-Token/get-purchase-redemption-records.js b/examples/apidoc/V5/Spot-Leverage-Token/get-purchase-redemption-records.js new file mode 100644 index 0000000..b720c1f --- /dev/null +++ b/examples/apidoc/V5/Spot-Leverage-Token/get-purchase-redemption-records.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotLeveragedTokenOrderHistory({ + orderId: '2611', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Leverage-Token/purchase.js b/examples/apidoc/V5/Spot-Leverage-Token/purchase.js new file mode 100644 index 0000000..28a3a40 --- /dev/null +++ b/examples/apidoc/V5/Spot-Leverage-Token/purchase.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .purchaseSpotLeveragedToken({ + ltCoin: 'EOS3L', + amount: '200', + serialNo: 'purchase-001', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Leverage-Token/redeem.js b/examples/apidoc/V5/Spot-Leverage-Token/redeem.js new file mode 100644 index 0000000..495e600 --- /dev/null +++ b/examples/apidoc/V5/Spot-Leverage-Token/redeem.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .redeemSpotLeveragedToken({ + ltCoin: 'EOS3L', + quantity: '200', + serialNo: 'redeem-001', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/README.md b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/README.md new file mode 100644 index 0000000..3582e5f --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/README.md @@ -0,0 +1,3 @@ +# V5 - REST - Spot Margin Trade (Normal) + +https://bybit-exchange.github.io/docs/v5/spot-margin-normal/margin-data diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/borrow.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/borrow.js new file mode 100644 index 0000000..394d5e1 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/borrow.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .spotMarginBorrow({ coin: 'ETH', qty: '10' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrow-order-detail.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrow-order-detail.js new file mode 100644 index 0000000..ea3b874 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrow-order-detail.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotMarginBorrowOrderDetail({ coin: 'ETH', limit: 1, status: 2 }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrowable-coin-info.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrowable-coin-info.js new file mode 100644 index 0000000..7525bdb --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-borrowable-coin-info.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotMarginBorrowableCoinInfo('ETH') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-interest-and-quota.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-interest-and-quota.js new file mode 100644 index 0000000..b437c22 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-interest-and-quota.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotMarginInterestAndQuota('ETH') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-loan-account-info.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-loan-account-info.js new file mode 100644 index 0000000..3d3850c --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-loan-account-info.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotMarginLoanAccountInfo() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-margin-coin-info.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-margin-coin-info.js new file mode 100644 index 0000000..d7db7cb --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-margin-coin-info.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotMarginCoinInfo('ETH') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-repayment-order-detail.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-repayment-order-detail.js new file mode 100644 index 0000000..2071944 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/get-repayment-order-detail.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotMarginRepaymentOrderDetail({ coin: 'ETH', limit: 1 }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/repay.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/repay.js new file mode 100644 index 0000000..32d86a3 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/repay.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .spotMarginRepay({ coin: 'ETH', completeRepayment: 1 }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/toggle-margin-trade-normal.js b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/toggle-margin-trade-normal.js new file mode 100644 index 0000000..b0e3e11 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(Normal)/toggle-margin-trade-normal.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .toggleSpotCrossMarginTrade({ switch: 0 }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/README.md b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/README.md new file mode 100644 index 0000000..23f0517 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/README.md @@ -0,0 +1,3 @@ +# V5 - REST - Spot Margin Trade (UTA) + +https://bybit-exchange.github.io/docs/v5/spot-margin-uta/switch-mode diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/set-leverage.js b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/set-leverage.js new file mode 100644 index 0000000..20da8f9 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/set-leverage.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .setSpotMarginLeverage('4') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/toggle-margin-trade.js b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/toggle-margin-trade.js new file mode 100644 index 0000000..0814846 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/toggle-margin-trade.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .toggleSpotMarginTrade('0') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + });