Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added some APIs #60

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## [1.0.10] - 2024-06-15

### Added APIs
- `GET /api/v3/hf/margin/order/active/symbols`
- `GET /api/v3/margin/symbols`
- `POST /api/v3/position/update-user-leverage`
- `GET /api/v1/otc-loan/loan`
- `GET /api/v1/otc-loan/accounts`
- `POST /api/v1/earn/orders`
- `DELETE /api/v1/earn/orders`
- `GET /api/v1/earn/redeem-preview`
- `GET /api/v1/earn/saving/products`
- `GET /api/v1/earn/hold-assets`
- `GET /api/v1/earn/promotion/products`
- `GET /api/v1/earn/kcs-staking/products`
- `GET /api/v1/earn/staking/products`
- `GET /api/v1/earn/eth-staking/products`
- `POST /api/v3/hf/margin/order`
- `POST /api/v3/hf/margin/order/test`
- `DELETE /api/v3/hf/margin/orders/{orderId}`
- `DELETE /api/v3/hf/margin/orders/client-order/{clientOid}`
- `DELETE /api/v3/hf/margin/orders`
- `GET /api/v3/hf/margin/orders/active`
- `GET /api/v3/hf/margin/orders/done`
- `GET /api/v3/hf/margin/orders/{orderId}`
- `GET /api/v3/hf/margin/orders/client-order/{clientOid}`
- `GET /api/v3/hf/margin/fills`

- **TOPIC**: `/margin/isolatedPosition` (Isolated Margin Position Push)

### Modified APIs
- `POST /api/v3/margin/borrow` - Added `isHf` field
- `POST /api/v3/margin/repay` - Added `isHf` field

### Deprecated APIs
- **TOPIC**: `/margin/fundingBook`

## [1.0.9] - 2024-05-30

### Added APIs
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,34 @@ Signature is not required for this part
- [x] getRedemptionOrdersV3
- [x] updatePurchaseOrderInterestRateV3

- [x] getCrossMarginTradingPairs
- [x] updateLeverageMultiplier
- [x] placeHfMarginOrder
- [x] testHfMarginOrder
- [x] cancelHfMarginOrder
- [x] cancelHfMarginOrderByClientOid
- [x] cancelAllHfMarginOrdersBySymbol
- [x] getActiveHfMarginOrders
- [x] getFilledHfMarginOrders
- [x] getHfOrderDetails
- [x] getHfOrderDetailsByClientOid
- [x] getHfTransactionRecords
- [x] getActiveHfOrderSymbols
#### Rest/Earn/General
- [x] subscribeToEarnFixedIncomeProducts
- [x] redeemByEarnHoldingId
- [x] getEarnRedeemPreviewByHoldingId
#### Rest/Earn/KucoinEarn
- [x] getEarnSavingsProducts
- [x] getEarnFixedIncomeCurrentHoldings
- [x] getEarnPromotionProducts
#### Rest/Earn/Staking
- [x] getKcsStakingProducts
- [x] getEarnStakingProducts
- [x] getEthStakingProducts
#### Rest/VIPLending
- [x] getOtcLoanInformation
- [x] getOtcLoanAccounts
#### Rest/Others
- [x] getTimestamp
- [x] getStatus
Expand Down
9 changes: 7 additions & 2 deletions demo/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ const priceTopics = {
"indexPrice" :"/indicator/index:USDT-BTC",
"markPrice" :"/indicator/markPrice:USDT-BTC"
}
//orderBookChange deprecated
const orderBookTopics = {
"orderBookChange":"/margin/fundingBook:BTC"
"orderBookChange":"/margin/fundingBook:BTC"
}
const isolatedTopics = {
"isolatedPosition":"/margin/isolatedPosition:BTC-USDT"
}
module.exports = {
tickerTopics,
Expand All @@ -31,5 +35,6 @@ module.exports = {
klineTopics,
matchTopics,
priceTopics,
orderBookTopics
orderBookTopics,
isolatedTopics
}
200 changes: 200 additions & 0 deletions demo/earn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
const API = require("../src");

API.init(require("./config"));

const earnMain = async () => {
const getTimestampRl = await API.rest.Others.getTimestamp();
console.log(getTimestampRl.data);

/**
* @name demoSubscribeToEarnFixedIncomeProducts
* @description Demo function to subscribe to fixed income products
* @updateTime 07/12/24
*/
async function demoSubscribeToEarnFixedIncomeProducts() {
try {
const result =
await API.rest.Earn.General.subscribeToEarnFixedIncomeProducts({
productId: "12345", // Example product ID
amount: "1000", // Example subscription amount
accountType: "MAIN", // Example account type
});
console.log("Subscription successful:", result);
} catch (error) {
console.error(
"Error subscribing to fixed income products:",
error.message
);
}
}

demoSubscribeToEarnFixedIncomeProducts();

/**
* @name demoRedeemByEarnHoldingId
* @description Demo function to initiate redemption by holding ID
* @updateTime 07/12/24
*/
async function demoRedeemByEarnHoldingId() {
try {
const result = await API.rest.Earn.General.redeemByEarnHoldingId({
orderId: "13100", // Example holding ID
amount: "1", // Example redemption amount
fromAccountType: "MAIN", // Example account type (optional)
confirmPunishRedeem: "1", // Example confirmation for early redemption penalty (optional)
});
console.log("Redemption successful:", result);
} catch (error) {
console.error("Error initiating redemption:", error.message);
}
}

demoRedeemByEarnHoldingId();

/**
* @name demoGetEarnRedeemPreviewByHoldingId
* @description Demo function to get redemption preview information by holding ID
* @updateTime 07/12/24
*/
async function demoGetEarnRedeemPreviewByHoldingId() {
try {
const result =
await API.rest.Earn.General.getEarnRedeemPreviewByHoldingId({
orderId: "13100", // Example holding ID
fromAccountType: "MAIN", // Example account type (optional)
});

console.log("Redemption Preview Information:", result);
} catch (error) {
console.error(
"Error fetching redemption preview information:",
error.message
);
}
}

demoGetEarnRedeemPreviewByHoldingId();

/**
* @name demoGetEarnSavingsProducts
* @description Demo function to get savings products
* @updateTime 07/12/24
*/

async function demoGetEarnSavingsProducts() {
try {
const result = await API.rest.Earn.KucoinEarn.getEarnSavingsProducts({
currency: "USDT", // Example currency (optional)
});

console.log("Savings Products:", result);
} catch (error) {
console.error("Error fetching savings products:", error.message);
}
}

demoGetEarnSavingsProducts();

/**
* @name demoGetEarnFixedIncomeCurrentHoldings
* @description Demo function to get current holding assets of fixed income products
* @updateTime 07/12/24
*/

async function demoGetEarnFixedIncomeCurrentHoldings() {
try {
const result =
await API.rest.Earn.KucoinEarn.getEarnFixedIncomeCurrentHoldings({
currentPage: 1, // Example page number (optional)
pageSize: 20, // Example page size (optional)
productId: "1", // Example product ID (optional)
productCategory: "STAKING", // Example product category (optional)
currency: "ATOM", // Example subscription currency (optional)
});

console.log("Current Holdings:", result);
} catch (error) {
console.error("Error fetching current holdings:", error.message);
}
}

demoGetEarnFixedIncomeCurrentHoldings();

/**
* @name demoGetEarnPromotionProducts
* @description Demo function to get limited-time promotion products
* @updateTime 07/12/24
*/
async function demoGetEarnPromotionProducts() {
try {
const result = await API.rest.Earn.KucoinEarn.getEarnPromotionProducts({
currency: "USDT", // Example currency (optional)
});

console.log("Promotion Products:", result);
} catch (error) {
console.error("Error fetching promotion products:", error.message);
}
}

demoGetEarnPromotionProducts();

/**
* @name demoGetKcsStakingProducts
* @description Demo function to get KCS Staking products
* @updateTime 07/12/24
*/
async function demoGetKcsStakingProducts() {
try {
const result = await API.rest.Earn.Staking.getKcsStakingProducts({
currency: "KCS", // Example currency (optional)
});

console.log("KCS Staking Products:", result);
} catch (error) {
console.error("Error fetching KCS Staking products:", error.message);
}
}

demoGetKcsStakingProducts();

/**
* @name demoGetEarnStakingProducts
* @description Demo function to get staking products
* @updateTime 07/12/24
*/

async function demoGetEarnStakingProducts() {
try {
const result = await API.rest.Earn.Staking.getEarnStakingProducts({
currency: "USDT", // Example currency (optional)
});

console.log("Staking Products:", result);
} catch (error) {
console.error("Error fetching staking products:", error.message);
}
}

demoGetEarnStakingProducts();

/**
* @name demoGetEthStakingProducts
* @description Demo function to get ETH Staking products
* @updateTime 07/12/24
*/
async function demoGetEthStakingProducts() {
try {
const result = await API.rest.Earn.Staking.getEthStakingProducts();

console.log("ETH Staking Products:", result);
} catch (error) {
console.error("Error fetching ETH Staking products:", error.message);
}
}

demoGetEthStakingProducts();
};

// run rest earnMain
earnMain();
Loading