Skip to content

Commit

Permalink
Merge pull request #19 from Adamant-im/dev
Browse files Browse the repository at this point in the history
v5.2.0
  • Loading branch information
adamant-al authored Feb 20, 2023
2 parents 1120ef5 + 0f061c4 commit ac4642a
Show file tree
Hide file tree
Showing 15 changed files with 4,207 additions and 3,706 deletions.
3 changes: 3 additions & 0 deletions helpers/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ module.exports = {
EXECUTE_IN_ORDER_BOOK_MAX_PRICE_CHANGE_PERCENT: 0.15, // In-orderbook trading: don't change price by mm-order more, than 0.15%
LIQUIDITY_SS_MAX_SPREAD_PERCENT: 0.3, // Liquidity spread support orders: Maintain spread percent
DEFAULT_ORDERBOOK_ORDERS_COUNT: 15,
LADDER_STATES: ['Not placed', 'Open', 'Filled', 'Partly filled', 'Cancelled', 'Missed', 'To be removed', 'Removed'],
LADDER_OPENED_STATES: ['Open', 'Partly filled'],
REGEXP_WHOLE_NUMBER: /^[0-9]+$/,
};
8 changes: 8 additions & 0 deletions helpers/dbModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ module.exports = (db) => {
});
});
}
static deleteOne(a) {
return new Promise((resolve, reject) => {
delete a.db;
db.deleteOne(a).then((res) => {
resolve(res.deletedCount);
});
});
}
static count(a) {
return new Promise((resolve, reject) => {
db.count(a).then((count) => {
Expand Down
21 changes: 21 additions & 0 deletions helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,27 @@ module.exports = {
return number > 1 ? some: one;
},

/**
* Inclines a number
* @param {Number} number Number to incline
* @return {String} 1-st, 2-d, 3-d, 4-th, 10-th, 20-th, 21-st, 22-d, 23-d, 30-th
*/
inclineNumber(number) {
if (!this.isPositiveOrZeroInteger(number)) {
return number;
}

if (number === 0) {
return `zero-index`;
} else if (number % 10 === 1 && number !== 11) {
return `${number}st`;
} else if ([2, 3].includes(number % 10) && ![12, 13].includes(number)) {
return `${number}d`;
} else {
return `${number}th`;
}
},

/**
* Returns readable timestamp in days, hours, minutes
* @param {Number} timestamp
Expand Down
17 changes: 15 additions & 2 deletions modules/commandTxs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ async function rates(params) {
}
if (exchangeRates) {
const delta = exchangeRates.ask-exchangeRates.bid;
const average = (exchangeRates.ask+exchangeRates.ask)/2;
const average = (exchangeRates.ask+exchangeRates.bid)/2;
const deltaPercent = delta/average * 100;
output += `${config.exchangeName} rates for ${pair} pair:\nBid: ${exchangeRates.bid.toFixed(coin2Decimals)}, ask: ${exchangeRates.ask.toFixed(coin2Decimals)}, spread: _${(delta).toFixed(coin2Decimals)}_ ${coin2} (${(deltaPercent).toFixed(2)}%).`;
} else {
Expand Down Expand Up @@ -1646,6 +1646,13 @@ async function pair(params) {
};
}

/**
* Get open orders details for accountNo
* @param {Number} accountNo 0 is for the first trade account, 1 is for the second
* @param {Object} tx Command Tx info
* @param {Object} params Includes optional trade pair
* @returns Order details for an account
*/
async function getOrdersInfo(accountNo = 0, tx = {}, pair) {
let output = '';
const pairObj = orderUtils.parseMarket(pair);
Expand Down Expand Up @@ -1724,14 +1731,20 @@ async function getOrdersInfo(accountNo = 0, tx = {}, pair) {
previousOrders[accountNo][tx.senderId][pairObj.pair] = ordersByType;

return output;

}

/**
* Get open orders details
* @param {Object} params Includes optional trade pair
* @param {Object} tx Command Tx info
* @returns Notification messages
*/
async function orders(params, tx = {}) {
let pair = params[0];
if (!pair) {
pair = config.pair;
}

if (pair.indexOf('/') === -1) {
return {
msgNotify: ``,
Expand Down
Loading

0 comments on commit ac4642a

Please sign in to comment.