Skip to content

Commit

Permalink
Merge pull request #2 from Adamant-im/dev
Browse files Browse the repository at this point in the history
v1.4.0
  • Loading branch information
adamant-al committed Aug 6, 2020
2 parents 3f93964 + ff7d85d commit 548a287
Show file tree
Hide file tree
Showing 24 changed files with 1,186 additions and 176 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ADAMANT Trading & Market making bot is a software that allows to run trades on crypto exchanges or make fake volume. Trading is a mode when bot run orders according to some strategy. It can be profitable or not.
In Market making mode, the bot places orders and execute them by himself, making a trade volume.
ADAMANT Trading & Market making bot is a software that allows to run trades on crypto exchanges, make fake volume (wash trading) and build live-like dynamic order book.

* In Market making mode, the bot places orders and execute them by himself, making a trade volume; and builds live-like dynamic order book.
* Trading is a mode when bot run orders according to some strategy. It can be profitable or not. Unavailable now—use [Zenbot](https://github.com/DeviaVir/zenbot).

Trade bots work in ADAMANT Messenger chats directly.

Features:
Expand All @@ -10,6 +13,7 @@ Features:
* Fill order books
* Place buy and sell limit or market orders
* Market making
* Dynamic order book
* Stores and displays statistics

Supported exchanges (more in progress):
Expand All @@ -18,8 +22,11 @@ Supported exchanges (more in progress):
* [Bit-Z](https://u.bit-z.com/register?invite_code=2423317)
* [CoinDeal](https://coindeal.com/ref/9WZN)
* [Resfinex](https://trade.resfinex.com?ref=7ccb34d867&pair=ADM_USDT)
* [Atomars](https://atomars.com/refcode/kaba)

# Usage

Available commands: ask a bot with `/help` command. Read more: [Crypto trading & Market making bot in ADAMANT](https://medium.com/adamant-im/crypto-trading-market-making-bot-in-adamant-82fa48b78f51).
Available commands: ask a bot with `/help` command. Read more how to use the bot: [Crypto trading & Market making bot in ADAMANT](https://medium.com/adamant-im/crypto-trading-market-making-bot-in-adamant-82fa48b78f51).

# Installation

Expand Down Expand Up @@ -50,8 +57,9 @@ Parameters:
* `pair` <string> Pair to with on the exchange. Obligatory.
* `coin1Decimals` <number> Meaningful decimals for output of coin1 amounts. Default is 8.
* `coin2Decimals` <number> Meaningful decimals for output of coin2 amounts. Default is 8.
* `apikey` <string> Exchange's account API key for connection. Obligatory.
* `apisecret` <string> Exchange's account API secret for connection. Obligatory.
* `clearAllOrdersInterval` <number> Interval in minutes to clear all opened orders. Default is 0 (disabled).
* `apikey` <string> Exchange's account API key (username/login for some exchanges) for connection. Obligatory.
* `apisecret` <string> Exchange's account API secret (password for some exchanges) for connection. Obligatory.
* `apipassword` <string> Exchange's account trade password. If needed for exchange.
* `passPhrase` <string> The bot's secret phrase for accepting commands. Obligatory. Bot's ADM address will correspond this passPhrase.
* `admin_accounts` <string, array> ADAMANT accounts to accept commands from. Commands from other accounts will not be executed. At lease one account.
Expand Down
1 change: 1 addition & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function init() {
}
checker();
require('./trade/mm_trader').run();
require('./trade/mm_orderbook_builder').run();
notify(`*${config.notifyName} started* for address _${Store.user.ADM.address}_ (ver. ${Store.version}).`, 'info');
});
}
Expand Down
35 changes: 24 additions & 11 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{

/** The bot's secret phrase for accepting commands.
/** The bot's secret passphrase. Create separate ADM account for the bot.
Bot's ADM address will correspond this passPhrase.
**/
"passPhrase": "distance expect praise frequent..",
Expand Down Expand Up @@ -39,22 +39,32 @@
/** Notify non-admins that they are not admins. If false, bot will be silent. **/
"notify_non_admins": true,

/** Exchange to work with. Available values: "IDCM", "Bit-Z", "CoinDeal", "Resfinex". Case insensitive. **/
"exchange": "IDCM",
/** Exchange to work with. Available values: "IDCM", "Bit-Z", "CoinDeal", "Resfinex", "Atomars". Case insensitive. **/
"exchange": "Resfinex",

/** Pair to trade **/
"pair": "ADM/BTC",
"pair": "ADM/USDT",

/** Meaningful decimals for output of coin1 amounts **/
"coin1Decimals": 0,
/** Meaningful decimals for output of coin1 amounts. Depends on coin and exchange **/
"coin1Decimals": 2, // 0.12 ADM

/** Meaningful decimals for output of coin2 amounts **/
"coin2Decimals": 8,
/** Meaningful decimals for output of coin2 amounts. Depends on coin and exchange **/
"coin2Decimals": 6, // 0.123456 USDT

/** Exchange's account API key for connection **/
/** Interval in minutes to clear all opened orders.
Some exchanges has API issues with closing or matching orders.
Because of this, your account can accumulate open orders and lead to freezed balances.
In such a case you can run "/clear all" command manually, or set this parameter for automatic clearing.
Note: this command cancels all of account orders, including ones which you set manually with "/fill" command.
If the exchange supports getting orders by pair param, only orders for the trade pair will be cleared.
0 means disabled.
**/
"clearAllOrdersInterval": 0,

/** Exchange's account API key for connection. Or login for Atomars **/
"apikey": "YOUR-KEY..",

/** Exchange's account API secret for connection **/
/** Exchange's account API secret for connection. Or password for Atomars **/
"apisecret": "YOUR-SECRET..",

/** Exchange's account trade password. If needed. **/
Expand All @@ -72,7 +82,10 @@
/** Slack key for notifications and monitoring (if needed) **/
"slack": "https://hooks.slack.com/services/...",

/** Port for getting debug info.
/** If you don't want to receive "not enough balance" and "unable to execute cross-order" notifications, set this "true" **/
"silent_mode": false,

/** Port for getting debug info.
Do not set for live bots, use only for debugging.
Allows to get DBs records like http://ip:port/db?tb=incomingTxsDb
**/
Expand Down
79 changes: 41 additions & 38 deletions helpers/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,52 @@ const {
} = config;


module.exports = (message, type) => {
module.exports = (message, type, silent_mode = false) => {
try {
log[type](message.replace(/\*/g, '').replace(/_/g, ''));

if (!slack && !adamant_notify) {
return;
}
let color;
switch (type) {
case ('error'):
color = '#FF0000';
break;

case ('warn'):
color = '#FFFF00';
break;
log[type](message.replace(/\*/g, '').replace(/_/g, ''));

case ('info'):
color = '#00FF00';
break;
case ('log'):
color = '#FFFFFF';
break;
}
const opts = {
uri: slack,
method: 'POST',
json: true,
body: {
'attachments': [{
'fallback': message,
'color': color,
'text': message,
'mrkdwn_in': ['text']
}]
if (!silent_mode) {

if (!slack && !adamant_notify) {
return;
}
let color;
switch (type) {
case ('error'):
color = '#FF0000';
break;
case ('warn'):
color = '#FFFF00';
break;
case ('info'):
color = '#00FF00';
break;
case ('log'):
color = '#FFFFFF';
break;
}
const opts = {
uri: slack,
method: 'POST',
json: true,
body: {
'attachments': [{
'fallback': message,
'color': color,
'text': message,
'mrkdwn_in': ['text']
}]
}
};
if (slack && slack.length > 34) {
request(opts);
}
if (adamant_notify && adamant_notify.length > 5 && adamant_notify.startsWith('U') && config.passPhrase && config.passPhrase.length > 30) {
api.send(config.passPhrase, adamant_notify, `${type}| ${message.replace(/\*/g, '**')}`, 'message');
}
};
if (slack && slack.length > 34) {
request(opts);
}
if (adamant_notify && adamant_notify.length > 5 && adamant_notify.startsWith('U') && config.passPhrase && config.passPhrase.length > 30) {
api.send(config.passPhrase, adamant_notify, `${type}| ${message.replace(/\*/g, '**')}`, 'message');
}

} catch (e) {
log.error('Notifier error: ' + e);
}
Expand Down
4 changes: 2 additions & 2 deletions helpers/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ module.exports = {
return null;
}
},
async userDailiValue(senderId){
async userDailyValue(senderId){
return (await db.paymentsDb.find({
transactionIsValid: true,
senderId: senderId,
needToSendBack: false,
inAmountMessageUsd: {$ne: null},
date: {$gt: (this.unix() - 24 * 3600 * 1000)} // last 24h
})).reduce((r, c) => {
return r + c.inAmountMessageUsd;
return +r + +c.inAmountMessageUsd;
}, 0);
},
async updateAllBalances(){
Expand Down
Loading

0 comments on commit 548a287

Please sign in to comment.