Skip to content

Commit

Permalink
Merge pull request #59 from Adamant-im/dev
Browse files Browse the repository at this point in the history
v6.1.0
  • Loading branch information
adamant-al authored Aug 17, 2024
2 parents 815c35f + fc37140 commit 9c94de1
Show file tree
Hide file tree
Showing 25 changed files with 4,458 additions and 5,581 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

41 changes: 0 additions & 41 deletions .eslintrc.js

This file was deleted.

8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ node_modules/
logs/
.vscode/
tests.js
config.test
config.test.json
config.test.jsonc
config.json
config.*.jsonc
config.jsonc
!config.default.jsonc
.DS_Store
.idea/
test_*.js
Expand All @@ -18,5 +16,5 @@ trade/tests/debug_trader.js
client.py
test_encode.py
coverage/
trade/settings/
trade/settings/*
!trade/settings/tradeParams_Default.js
69 changes: 46 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ADAMANT Trading & Market making bot is a software that allows to run trades on crypto exchanges, make trade volume, maintain spread and liquidity, set price range, and build live-like dynamic order book.

This is a free version. For premium features, see [marketmaking.app/services](https://marketmaking.app/services/).
This is a free version. For premium features, see [marketmaking.app/mm-services](https://marketmaking.app/mm-services/).

# Market making

Expand All @@ -25,12 +25,45 @@ Profit trading is a mode in which a bot runs orders according to some strategy.
* Initial fill order books
* Dynamic order book building
* Place buy and sell limit or market orders
* Market making with 3 policies: spread, orderbook, optimal
* Spread & liquidity maintenance
* Market making with 4 policies: spread, orderbook, optimal, and depth
* Spread & liquidity/depth maintenance
* Price range setting
* Arbitrage token price on other trade pairs or exchanges
* Managed with your commands using ADAMANT Messenger

## Premium features

For premium features, see [marketmaking.app/mm-services](https://marketmaking.app/mm-services/).

* High-frequency order books
* Watch order books and eliminate gaps
* Anti-cheat cleans price manipulation orders
* 2-keys trading
* Running commands for the second trade account
* Fund balancer for 2-keys trading
* Fund supplier for multi-pair trading on one exchange using one account
* Liquidity/depth set up to support spread and place main volume further from current price
* Support price to maintain by any means
* Setting manual price trends and target
* Automatic volatility life-like chart
* In-orderbook market-making without in-spread trading
* Maintaining a small spread and consistent chart with in-orderbook market-making
* Volume volatility: more volume on pumps and dumps
* Stores and displays statistics
* Account info: fees and daily volume
* Quote hunter to replenish quote coin balance
* Withdrawals
* Show deposits, withdrawals, coin network information
* Transfer funds between account types (main, trade, margin)
* Cross-bot communication to run commands remotely across all the bots at once
* Command aliases
* High-frequency order book updates
* Price maker & Price watcher, including depth policy
* Balance equalizer: Ensures coin1 (base) and coin2 (quote) balances are near equal in USD value
* TWAP orders
* Socket support for exchange connections
* Socket-pull support as a preferred to socket-subscribe model

# Supported exchanges

* [P2PB2B](https://p2pb2b.com)
Expand All @@ -41,21 +74,21 @@ Profit trading is a mode in which a bot runs orders according to some strategy.
* [NonKYC](https://nonkyc.io?ref=655b4df9eb13acde84677358)
* [XeggeX](https://xeggex.com?ref=656846d209bbed85b91aba4d)

To add other exchange support, see [marketmaking.app/services](https://marketmaking.app/services/).
To add other exchange support, see [marketmaking.app/mm-services](https://marketmaking.app/mm-services/).

# Usage and Installation

After installation, you control the bot in secure ADAMANT Messenger chat directly.
After installation, you control the bot in secure ADAMANT Messenger chat directly. It's self-hosted.

Available commands: ask a bot with the `/help` command. Read more about installing and using the bot: [marketmaking.app/guides](https://marketmaking.app/guides/).
[Installation and usage guide](https://marketmaking.app/cex-mm/installation/).

We can run market-making for you, see [marketmaking.app/services](https://marketmaking.app/services/).
[Command reference](https://marketmaking.app/cex-mm/command-reference/).

## Requirements

* Ubuntu 18–22, centOS 8 (we didn't test others)
* NodeJS v16+
* MongoDB v6+ ([installation instructions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/))
* Ubuntu 20+, centOS 8+ (we didn't test others)
* NodeJS v18+
* MongoDB ([installation instructions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/))

## Setup

Expand All @@ -68,14 +101,14 @@ npm i

## Pre-launch tuning

The bot will use `config.jsonc`, if available, or `config.default.jsonc` otherwise.
The bot will use `config.jsonc` if available, or `config.default.jsonc` otherwise.

```
cp config.default.jsonc config.jsonc
nano config.jsonc
```

Parameters: see comments in the config file.
Parameters: see comments in `config.jsonc`.

## Launching

Expand All @@ -85,17 +118,7 @@ You can start the Bot with the `node app` command, but it is recommended to use
pm2 start app.js --name tradebot
```

## Add a Bot to cron

```
crontab -e
```

Add string:

```
@reboot cd /home/adamant/adamant-tradebot && pm2 start app.js --name tradebot
```
Remember to add tradebot to `pm2 startup` or cron.

## Updating

Expand Down
20 changes: 14 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const config = require('./modules/configReader');
const db = require('./modules/DB');
const doClearDB = process.argv.includes('clear_db');

// It may take up to a second to create trading params file 'tradeParams_{exchange}.js' from the default one
setTimeout(initServices, 1000);
Expand All @@ -14,7 +13,10 @@ function initServices() {
const api = require('./modules/api');
const txParser = require('./modules/incomingTxsParser');

api.socket.initSocket({ socket: config.socket, wsType: config.ws_type, onNewMessage: txParser, admAddress: config.address });
if (config.socket) {
api.initSocket({ wsType: config.ws_type, admAddress: config.address });
api.socket.on(txParser);
}
}

// Debug and health API init
Expand All @@ -32,15 +34,18 @@ function startModules() {
try {
const notify = require('./helpers/notify');

if (doClearDB) {
console.log('Clearing database…');
if (config.doClearDB) {
console.log(`${config.notifyName}: Clearing database…`);

db.systemDb.db.drop();
db.incomingTxsDb.db.drop();
db.incomingTgTxsDb.db.drop();
db.incomingCLITxsDb.db.drop();
db.ordersDb.db.drop();
db.fillsDb.db.drop();
db.webTerminalMessages.drop();

notify(`*${config.notifyName}: database cleared*. Manually stop the Bot now.`, 'info');
console.log(`${config.notifyName}: Database cleared. Manually stop the Bot now.`);
} else {
if (config.passPhrase) {
const checker = require('./modules/checkerTransactions');
Expand All @@ -51,7 +56,10 @@ function startModules() {
require('./trade/mm_orderbook_builder').run();
require('./trade/mm_liquidity_provider').run();
require('./trade/mm_price_watcher').run();
// require('./trade/mm_orderbook_builder').test();

if (config.dev) {
require('./trade/tests/manual.test').run();
}

const addressInfo = config.address ? ` for address _${config.address}_` : ' in CLI mode';
notify(`${config.notifyName} *started*${addressInfo} (${config.projectBranch}, v${config.version}).`, 'info');
Expand Down
9 changes: 8 additions & 1 deletion config.default.jsonc
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
/**
States if this config file is for development (not a production bot).
Config files 'config.dev.jsonc' and 'config.test.jsonc' considered as dev independent of this option.
You can also add 'dev' or 'test' command argument, or set env DEV=true.
**/
"dev": false,

/**
The bot's secret passphrase. Create a separate ADM account for the bot.
Bot's ADM address will correspond to this passPhrase.
Expand Down Expand Up @@ -78,7 +85,7 @@
"exchange_restrictions": {
/** Max number of open orders. Set 'false' to skip **/
"orderNumberLimit": false,
/** If the exchange doesn't provide min order amount value, the bot uses the default one. Set 'false' to use DEFAULT_MIN_ORDER_AMOUNT_USD **/
/** If an exchange doesn't provide a minimum order amount value, the bot uses the DEFAULT_MIN_ORDER_AMOUNT_USD const. You can override it with any positive value. **/
"minOrderAmountUSD": false,
/** Same for the upper bound of the min order amount **/
"minOrderAmountUpperBoundUSD": false
Expand Down
58 changes: 58 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const js = require('@eslint/js');
const google = require('eslint-config-google');
const globals = require('globals');
const babelParser = require('@babel/eslint-parser');

module.exports = [
js.configs.recommended,
google,
{
languageOptions: {
ecmaVersion: 2021,
sourceType: 'commonjs',
globals: {
...globals.node,
},
parser: babelParser,
parserOptions: {
sourceType: 'script',
ecmaVersion: 2021,
},
},
rules: {
quotes: [
'error',
'single',
{
allowTemplateLiterals: true,
},
],
'prefer-arrow-callback': ['error'],
'object-shorthand': ['error', 'always'],
'quote-props': ['error', 'as-needed'],
'object-curly-spacing': ['error', 'always'],
'max-len': ['error',
{ code: 133,
ignoreTrailingComments: true,
ignoreComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
}],
'require-jsdoc': ['off'],
'valid-jsdoc': ['off'],
'no-array-constructor': ['off'],
'no-caller': ['off'],
'prefer-promise-reject-errors': ['off'],
'guard-for-in': ['off'],
'padded-blocks': ['off'],
'new-cap': ['off'],
camelcase: ['off'],
eqeqeq: ['error', 'always'],
},
},
{
ignores: ['trade/settings/', 'trade/tests/', 'trade/cs/test/', 'trade/cs/web_legacy/', '*.spec.js'],
},
];
Loading

0 comments on commit 9c94de1

Please sign in to comment.