Skip to content

Commit

Permalink
Upgrade API SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
qhxin committed Dec 1, 2020
1 parent 8a87b86 commit 445a50a
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 42 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Signature is required for this part.
- [x] getWithdrawalQuotas
- [x] applyWithdraw
- [x] cancelWithdrawal
#### Rest/User/TradeFee
- [x] getBasicUserFee
- [x] getActualFeeRateBySymbols

### Rest/Trade
```
Expand Down Expand Up @@ -111,7 +114,6 @@ Signature is not required for this part
- [x] getLevel2_20
- [x] getLevel2_100
- [x] getLevel2_full
- [x] getLevel3_full_v1
- [x] getLevel3_full
#### Rest/Market/Histories
- [x] getMarketHistories
Expand Down
2 changes: 1 addition & 1 deletion demo/config.tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
/** default baseUrl will be set by `process.env.PRODUCTION` */
/** if process.env.PRODUCTION === 'prod', the default value will be https://api.kucoin.io */
/** else use sandbox as https://openapi-sandbox.kucoin.io */
baseUrl: 'https://openapi-sandbox.kucoin.io',
baseUrl: 'https://openapi-sandbox.kucoin.cc',
/** Auth infos */
/** key is API key */
/** secret is API secret */
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exports.rest = {
Account: require('./rest/User/Account'),
Deposit: require('./rest/User/Deposit'),
Withdrawals: require('./rest/User/Withdrawals'),
TradeFee: require('./rest/User/TradeFee'),
},
Trade: {
Orders: require('./rest/Trade/Orders'),
Expand Down
2 changes: 2 additions & 0 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const CryptoJS = require('crypto');
const path = require('path');
const fs = require('fs');
const uuid = require('uuid');
const { version } = require('../../package.json');

function sign(text, secret, outputType = 'base64') {
return CryptoJS
Expand All @@ -21,6 +22,7 @@ function auth(ApiKey, method, url, data) {
'KC-API-TIMESTAMP': timestamp.toString(),
'KC-API-PASSPHRASE': ApiKey.passphrase || '',
'Content-Type': 'application/json',
'User-Agent': `KuCoin-Node-SDK/${version}`,
};
}

Expand Down
81 changes: 41 additions & 40 deletions src/rest/Market/OrderBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,51 +73,52 @@ exports.getLevel2_full = async function getLevel2_full(symbol) {


/**
* @deprecated
* @name getLevel3_full_v1
* @description Get Full Order Book(atomic)
* @param {string} symbol - symbol
* @return {Object} { code, success, data }
*/
exports.getLevel3_full_v1 = async function getLevel3_full_v1(symbol) {
/*
{
"code": "200000",
"data": {
"sequence": "1573503933086",
"asks": [
[
"5e0d672c1f311300093ac522", //orderId
"0.1917", //price
"390.9275", //size
"1577936689346546088" //time,nanoseconds
],
[
"5e0d672891432f000819ecc3",
"0.19171",
"1456.1316",
"1577936685718811031"
]
],
"bids": [
[
"5e0d672cdc53860007f30262",
"0.19166",
"178.1936",
"1577936689166023452"
],
[
"5e0d671a91432f000819d1b0",
"0.19165",
"583.6298",
"1577936671595901518"
]
],
"time": 1577936685107
}
}
*/
return await Http().GET('/api/v1/market/orderbook/level3', { symbol });
};
// exports.getLevel3_full_v1 = async function getLevel3_full_v1(symbol) {
// /*
// {
// "code": "200000",
// "data": {
// "sequence": "1573503933086",
// "asks": [
// [
// "5e0d672c1f311300093ac522", //orderId
// "0.1917", //price
// "390.9275", //size
// "1577936689346546088" //time,nanoseconds
// ],
// [
// "5e0d672891432f000819ecc3",
// "0.19171",
// "1456.1316",
// "1577936685718811031"
// ]
// ],
// "bids": [
// [
// "5e0d672cdc53860007f30262",
// "0.19166",
// "178.1936",
// "1577936689166023452"
// ],
// [
// "5e0d671a91432f000819d1b0",
// "0.19165",
// "583.6298",
// "1577936671595901518"
// ]
// ],
// "time": 1577936685107
// }
// }
// */
// return await Http().GET('/api/v1/market/orderbook/level3', { symbol });
// };


/**
Expand Down
47 changes: 47 additions & 0 deletions src/rest/User/TradeFee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

const Http = require('../../lib/http');

/**
* @name getBasicUserFee
* @description This interface is for the basic fee rate of users.
* @return {Object} { code, success, data }
*/
exports.getBasicUserFee = async function getBasicUserFee() {
/*
{
"code": "200000",
"data": {
"takerFeeRate": "0.001",
"makerFeeRate": "0.001"
}
}
*/
return await Http().GET('/api/v1/base-fee');
};

/**
* @name getActualFeeRateBySymbols
* @description This interface is for the actual fee rate of the trading pair. You can inquire about fee rates of 10 trading pairs each time at most. The fee rate of your sub-account is the same as that of the master account.
* @param {string} symbols - Trading pair (optional, you can inquire fee rates of 10 trading pairs each time at most) . exp: BTC-USDT,KCS-USDT
* @return {Object} { code, success, data }
*/
exports.getActualFeeRateBySymbols = async function getActualFeeRateBySymbols(symbols) {
/*
{
"code": "200000",
"data": [
{
"symbol": "BTC-USDT",
"takerFeeRate": "0.001",
"makerFeeRate": "0.001"
},
{
"symbol": "KCS-USDT",
"takerFeeRate": "0.002",
"makerFeeRate": "0.0005"
}
]
}
*/
return await Http().GET('/api/v1/trade-fees', { symbols });
};

0 comments on commit 445a50a

Please sign in to comment.