Coder Social home page Coder Social logo

haehnchen / crypto-trading-bot Goto Github PK

View Code? Open in Web Editor NEW
3.0K 180.0 967.0 4.96 MB

Cryptocurrency trading bot in javascript for Bitfinex, Bitmex, Binance, Bybit ... (public edition)

License: MIT License

JavaScript 87.89% Dockerfile 0.06% Twig 11.11% Vue 0.94%
cryptocurrency crypto exchange trading trading-bot trading-strategies websocket nodejs bitfinex bitmex binance tradingview bot javascript docker bybit margin coinbase

crypto-trading-bot's Introduction

Crypto Trading Bot

Build Status

A work in progress Cryptocurrency for common exchanges like Bitfinex, Bitmex and Binance. As most trading bots just provide basic buy and sell signals they provide many stuff to get profitable eg exchange orders like stop-losses or stop-limits are not supported by main bots. Also the limitation of fixed timeframe and technical indicators must be broken

Not production ready only basic functionality

Features

  • Fully use Websocket for exchange communication to react as fast as possible on market
  • Multi pair support in one instance
  • sqlite3 storage for candles, tickers, ...
  • Webserver UI
  • Support for going "Short" and "Long"
  • Signal browser dashboard for pairs
  • Slack and email notification
  • Join foreign exchange candles (eg. Trade on Bitmex with the faster moving Binance trades / candles)

Exchanges

TODOS:

Technical stuff and packages

How to use

[optional] Preinstall

The tulip library is used for indicators; which sometimes is having some issues on npm install because of code compiling:

Install build tools

sudo apt-get install build-essential

The nodejs wrapper for tulipindicators is called Tulip Node (tuind), check out installation instructions there.

Also the build from source is not supporting all nodejs version. It looks like versions <= 10 are working. You can use nodejs 12 if you compiled it once via older version.

Install packages

➜ npm install --production
➜ npm run postinstall

Create instance file for pairs and changes

cp instance.js.dist instance.js

Provide a configuration with your exchange credentials

cp conf.json.dist conf.json

Create a new sqlite database use bot.sql scheme to create the tables

sqlite3 bot.db < bot.sql

Lets start it

npm start

How to use: Docker

For initialize the configuration once

➜ cp instance.js.dist instance.js && cp conf.json.dist conf.json && sqlite3 bot.db < bot.sql
➜ docker-compose build
➜ docker-compose up -d

After this you can use docker-compose which will give you a running bot via http://127.0.0.1:8080

Setting Up Telegram Bot

First, you'll need to create a bot for Telegram. Just talk to BotFather and follow simple steps until it gives you a token for it. You'll also need to create a Telegram group, the place where you and crypto-trading-bot will communicate. After creating it, add the bot as administrator (make sure to uncheck "All Members Are Admins").

Retrieving Chat IDs

Invite @RawDataBot to your group and get your group id in sended chat id field

Message
 ├ message_id: 338
 ├ from
 ┊  ├ id: *****
 ┊  ├ is_bot: false
 ┊  ├ first_name: 사이드
 ┊  ├ username: ******
 ┊  └ language_code: en
 ├ chat
 ┊  ├ id: -1001118554477
 ┊  ├ title: Test Group
 ┊  └ type: supergroup
 ├ date: 1544948900
 └ text: A

Look for id: -1001118554477 is your chat id (with the negative sign).

Log messages to Telegram

For example setup, check conf.json.dist file, log.telegram section , set chatId, token, level (default is info). Check more options https://github.com/ivanmarban/winston-telegram#readme

Webserver

Some browser links

Security / Authentication

As the webserver provides just basic auth for access you should combine some with eh a https for public server. Here s simple proxy_pass for nginx.

# /etc/nginx/sites-available/YOURHOST
server {
    server_name YOURHOST;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/YOURHOST/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/YOURHOST/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

You should also set the listen ip to a local one

# config.json
webserver.ip: 127.0.0.1

Web UI

Dashboard

Webserver UI

Trades / Positions / Orders

Webserver UI

Backtesting

Currently there is a the UI for backtesting

Webserver UI

Manual Orders

Webserver UI

Build In Strategies

Common strategy with indicators are inside, which most of the time are not profitable. See some more advanced strategy in the list below

Find some example strategies inside src/modules/strategy/strategies

Custom Strategies

For custom strategies use var/strategies folder.

# simple file structure
var/strategies/your_strategy.js

# or wrap strategy into any sub folder depth
var/strategies/my_strategy/my_strategy.js
var/strategies/subfolder1/our_strategy/our_strategy.js

Tools / Watchdog

  • order_adjust Keep open orders in bid / ask of the orderbook in first position

Watchdog

  • stoploss provide general stoploss order in percent of entry price (Exchange Order)
  • risk_reward_ratio Creates Risk Reward order for take profit and stoploss (Exchange Order Limit+Stop)
  • stoploss_watch Close open position if ticker price falls below the percent lose; use this for exchange that dont support stop_loss order liek Binance
  • trailing_stop Use native exchange trailing stop; if supported by exchange eg Bitfinex
    'watchdogs': [
        {
            'name': 'stoploss',
            'percent': 3,
        },
        {
            'name': 'risk_reward_ratio',
            'target_percent': 6,
            'stop_percent': 3,
        },
        {
            'name': 'stoploss_watch',
            'stop': 1.2,
        },
        {
            'name': 'trailing_stop',
            'target_percent': 1.2,
            'stop_percent': 0.5
        }
    ],

Tick Interval

Per default every strategy is "ticked" every full minute with a ~10sec time window. If you want to tick every 15 minutes or less see possible examples below.

Supported units are "m" (minute) and "s" (seconds)

{
  "strategies": [
    {
      "strategy": "cci",
      "interval": "15m"
    },
    {
      "strategy": "cci2",
      "interval": "30s"
    },
    {
      "strategy": "cci3",
      "interval": "60m"
    }
  ]
}

Trading

Capital

To allow the bot to trade you need to give some "playing capital". You can allow to by via asset or currency amount, see examples below. You should only provide one of them, first wins.

    c.symbols.push({
        'symbol': 'BTC-EUR',
        'exchange': 'coinbase_pro',
        'trade': {
            'capital': 0.015, // this will buy 0.015 BTC
            'currency_capital': 50,  // this will use 50 EUR and buys the equal amount of BTC (example: BTC price 3000 use 50 EUR. will result in 0.016 BTC)
            'balance_percent': 75,  // this will use 75 % of your exchange margin tradable balance. Currently implemented only on Bitfinex exchange.
        },
    })

Live Strategy

Every strategy stat should be live must be places inside trade.

{
  "trade": {
    "strategies": [
      {
        "strategy": "dip_catcher",
        "interval": "15m",
        "options": {
          "period": "15m"
        }
      }
    ]
  }
}

Inside logs, visible via browser ui, you can double check the strategies init process after the application started.

[info] Starting strategy intervals
[info] "binance_futures" - "ETHUSDT" - "trade" - init strategy "dip_catcher" (15m) in 11.628 minutes
[info] "binance_futures" - "BTCUSDT" - "trade" first strategy run "dip_catcher" now every 15.00 minutes

Full Trade Example

An example instance.js which trades can be found inside instance.js.dist_trade. Rename it or move the content to you file.

const c = (module.exports = {});

c.symbols = [
  {
    symbol: 'ETHUSDT',
    exchange: 'binance_futures',
    periods: ['1m', '15m', '1h'],
    trade: {
      currency_capital: 10,
      strategies: [
        {
          strategy: 'dip_catcher',
          interval: '15m',
          options: {
            period: '15m'
          }
        }
      ]
    },
    watchdogs: [
      {
        name: 'risk_reward_ratio',
        target_percent: 3.1,
        stop_percent: 2.1
      }
    ]
  }
];

Margin / Leverage

Per pair you can set used margin before orders are created; depending on exchange

    c.symbols.push({
        'symbol': 'BTCUSD',
        'exchange': 'bitmex',
        'extra': {
            'bitmex_leverage': 5,
        },
    })

    c.symbols.push({
        'symbol': 'EOSUSD',
        'exchange': 'bybit',
        'extra': {
            'bybit_leverage': 5,
        },
    })

Tools

Fill data

outdated, but there as an automatic filling on startup ~1000 candles from the past (depending on exchange) and continuously fetched when running

node index.js backfill -e bitmex -p 1m -s XRPZ18

Signals

Slack

Webserver UI

Tests

npm test

Related Links

Trading Bots Inspiration

Other bots with possible design pattern

Strategies

Some strategies based on technical indicators for collection some ideas

crypto-trading-bot's People

Contributors

antoniomuso avatar arnisl avatar dependabot-preview[bot] avatar dependabot[bot] avatar dhairyagada avatar egisz avatar fidel1986 avatar haehnchen avatar juandelacruz-calvo avatar kangoulya avatar luis-fernando-molina avatar minhphuc429 avatar nickmitchko avatar ripkens avatar rivermoon21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crypto-trading-bot's Issues

duplicate stoploss

image

here is my instance.js

let y = [
    'XBTUSD', 'ETHUSD'
]

y.forEach((pair) => {
    c.symbols.push({
        'symbol': pair,
        'periods': ['1m', '15m', '1h'],
        'exchange': 'bitmex',
        'state': 'watch',
        'extra': {
            'bitmex_leverage': 25,
            'bitmex_rest_order_sync': 2000
        },
        'watchdogs': [
            {
                'name': 'stoploss',
                'percent': 3,
            },
            {
                'name': 'risk_reward_ratio',
                'target_percent': 3,
                'stop_percent': 3,
            }
        ],
        'strategies': [
            {
                'strategy': 'cci',
                'options': {
                    'period': '15m'
                }
            },
            {
                'strategy': 'obv_pump_dump'
            },
            {
                'strategy': 'macd',
                'options': {
                    'period': '1h'
                }
            }
        ]
    })
})

Cannot read property 'symbols' of undefined

This command:
node index.js server

gives me:


Webserver listening on: 0.0.0.0:8080
(node:7909) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'symbols' of undefined
...
(node:7909) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7909) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

want to use bitmex testnet for backtesting

Bitmex - Multiple close commands due to "lastSignal" not being up to date?

Hey guys,
I have noticed the following. Sometimes the bot is not updating the lastSignal variable in the strategy correctly (at least thats my assumption). Probably the positions are not up to date in that moment?
This causes the bot to send multiple close commands again and again because the strat thinks the position is not closed yet as lastSignal is still short or long (even though the position is already closed and lastSignal should be undefined).

I have never seen this behavior with sell or buy orders, only for the close orders!
Attached you can find the log of an example, hope that helps to further narrow this down?

logtoday.txt

Bot buys even with insufficient funds

What I notice:
The bot gets a cancellation on bitmex due to "insufficient funds", however it keeps retrying to put up a limit order until I manually cancel it or when it has sufficient funds, causing it to buy at a loss.

Expected:
Stop putting an order in when it receives a message for "insufficient" funds, or try to put in a smaller order that can be filled.

Order gets executed multiple times since newest Commits

When executing an order I receive the following error since the newest commits:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined
at ExchangeOrderWatchdogListener.onPositionChanged (c:\Users\Documents\Archive\ctb\modules\listener\exchange_order_watchdog_listener.js:80:36)
at EventEmitter.eventEmitter.on (c:\Users\Documents\Archive\ctb\modules\trade.js:150:52)
at EventEmitter.emit (events.js:198:13)
at ExchangePositionWatcher.onPositionStateChangeTick (c:\Users\Documents\Archive\ctb\modules\exchange\exchange_position_watcher.js:48:35)
warning.js:18
(node:9796) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
warning.js:18
(node:9796) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
warning.js:18

This causes one order being created multiple times on the exchange :-/
It seems to be related to the newest position handling update?

Signals working - but not trading

Hi

For some reason, signals are working fine, but the bot is not making trades on the signals?

signals
trades
pairs

On the pairs page, the Strategies Column is blank? I thought the strategies picked in instance.js should be displayed on this page, is that correct?

Not too sure if its because i am using the Bitmex Testnet or not? I am meant to change the state from Watch to trade or something?

My Bitmex Test net API looks like this -

bitmex

Signal Ticker Interval

How does the bot actually use the Ticker Interval ? The backtest gives different results when the parameter "ticker_interval" is changed from its default forced 15 minutes but there is no way to apply a strategy with this setting changed.

In trade.js

setInterval(() => { eventEmitter.emit('signal_tick', {}) }, this.systemUtil.getConfig('tick.signal', 10600))

In conf.json
"tick": { "default": null, "warmup": null, "signal": null, "watchdog": null, "ordering": null, "pair_signal_concurrency": null },

In http.js
res.render('../templates/backtest_submit.html.twig', await this.backtest.getBacktestResult( parseInt(req.body['ticker_interval']), req.body.hours, req.body.strategy, req.body.candle_period, pair[0], pair[1], req.body.options ? JSON.parse(req.body.options) : {} ))

In backtest.js the parameter is used in GetBacktestResult

how do backtest with self data

firstly,thanks for your work.The problem is that the backtest data size is too small.I want to do
backtest with my data.Do you have any advices? Thanks

Ticker no found for + bitmex_testnetETHUSD

Hi there,

first of all, thank you very much for publishing your development! Very much appreciate it!

However, I just gave it a first try on the bitmex testate. However with the following instance.js I get the following error message very time the system creates a new candle/tick?:
"Ticker no found for + bitmex_testnetETHUSD"

Does anybody have an idea what the issue is here?
I have guessed that setting the state to trade would be the correct way to get it start trading.

My instance.js looks like this:

`// bitmex testnet
let l = [
'ETHUSD'
]

l.forEach((pair) => {
c.symbols.push({
'symbol': pair,
'periods': ['1m'],
'exchange': 'bitmex_testnet',
'state': 'trade',
'extra': {
'bitmex_leverage': 3,
},
'trade': {
'capital': 50,
},
'strategies': [
{
'strategy': 'cci',
'options': {
'period': '1m'
}
},
]
})
})`

missing signals

two issues:

  1. the signal tab is always empty ?
  2. under Pairs the Strategy column returns a empty list although a strategy is set in instance.js?

SQLITE_ERROR: no such table: logs

C:\Users\sRs3\Downloads\crypto-trading-bot-master>node index.js trade
(node:7920) [DEP0025] DeprecationWarning: sys is deprecated. Use util instead.
Webserver listening on: 127.0.0.1:8080
WebSocket [INFO]: Connected.
Bitmex: Connection opened.
SQLITE_ERROR: no such table: logs
{"op":"subscribe","args":"tradeBin1m:XBTUSD"}
{"op":"subscribe","args":"tradeBin5m:XBTUSD"}
{"op":"subscribe","args":"tradeBin1h:XBTUSD"}
{"op":"subscribe","args":"instrument:XBTUSD"}
{"op":"subscribe","args":"tradeBin1m:ETHUSD"}
{"op":"subscribe","args":"tradeBin5m:ETHUSD"}
{"op":"subscribe","args":"tradeBin1h:ETHUSD"}
{"op":"subscribe","args":"instrument:ETHUSD"}
{"op":"subscribe","args":"tradeBin1m:XBTM19"}
{"op":"subscribe","args":"tradeBin5m:XBTM19"}
{"op":"subscribe","args":"tradeBin1h:XBTM19"}
{"op":"subscribe","args":"instrument:XBTM19"}
{"op":"subscribe","args":"tradeBin1m:ETHM19"}
{"op":"subscribe","args":"tradeBin5m:ETHM19"}
{"op":"subscribe","args":"tradeBin1h:ETHM19"}
{"op":"subscribe","args":"instrument:ETHM19"}
{"op":"subscribe","args":"tradeBin1m:ADAM19"}
{"op":"subscribe","args":"tradeBin5m:ADAM19"}
{"op":"subscribe","args":"tradeBin1h:ADAM19"}
{"op":"subscribe","args":"instrument:ADAM19"}
{"op":"subscribe","args":"tradeBin1m:TRXM19"}
{"op":"subscribe","args":"tradeBin5m:TRXM19"}
{"op":"subscribe","args":"tradeBin1h:TRXM19"}
{"op":"subscribe","args":"instrument:TRXM19"}
{"op":"subscribe","args":"tradeBin1m:XRPM19"}
{"op":"subscribe","args":"tradeBin5m:XRPM19"}
{"op":"subscribe","args":"tradeBin1h:XRPM19"}
{"op":"subscribe","args":"instrument:XRPM19"}
SQLITE_ERROR: no such table: logs
SQLITE_ERROR: no such table: logs
SQLITE_ERROR: no such table: logs
SQLITE_ERROR: no such table: logs
SQLITE_ERROR: no such table: logs
WebSocket [INFO]: Connected.
Bitmex: Connection opened.
SQLITE_ERROR: no such table: logs
{"op":"subscribe","args":"tradeBin1m:XBTUSD"}
{"op":"subscribe","args":"tradeBin5m:XBTUSD"}
{"op":"subscribe","args":"tradeBin1h:XBTUSD"}
{"op":"subscribe","args":"instrument:XBTUSD"}
events.js:174
throw er; // Unhandled 'error' event
^

Error: SQLITE_ERROR: no such table: ticker
Emitted 'error' event at:

Installation requirements / errors

Hi Daniel,

It's awesome what you implemented here the tons of awesome implementations. Respect.

Can you please provide requirements for a proper installation, please? Like OS, nodejs version, Development Tools etc. I made it up and running with changes but I met heaps of errors on the way trying different OSes.

`

[email protected] install /home/crypto/crypto-trading-bot/node_modules/tulind
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download

/home/crypto/crypto-trading-bot/node_modules/tulind/node_modules/node-pre-gyp/node_modules/tar/lib/create.js:4
const hlo = require('./high-level-opt.js')
^^^^^
node-pre-gyp ERR! UNCAUGHT EXCEPTION
node-pre-gyp ERR! stack SyntaxError: Use of const in strict mode.
node-pre-gyp ERR! stack at Module._compile (module.js:439:25)
node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:474:10)
node-pre-gyp ERR! stack at Module.load (module.js:356:32)
node-pre-gyp ERR! stack at Function.Module._load (module.js:312:12)
node-pre-gyp ERR! stack at Module.require (module.js:364:17)
node-pre-gyp ERR! stack at require (module.js:380:17)
node-pre-gyp ERR! stack at Object. (/home/crypto/crypto-trading-bot/node_modules/tulind/node_modules/node-pre-gyp/node_modules/tar/index.js:4:30)
node-pre-gyp ERR! stack at Module._compile (module.js:456:26)
node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:474:10)
node-pre-gyp ERR! stack at Module.load (module.js:356:32)
node-pre-gyp ERR! System Linux 3.10.0-957.el7.x86_64
node-pre-gyp ERR! command "node" "/home/crypto/crypto-trading-bot/node_modules/tulind/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/crypto/crypto-trading-bot/node_modules/tulind
node-pre-gyp ERR! node -v v0.10.30
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! This is a bug in node-pre-gyp.
node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help:
node-pre-gyp ERR! https://github.com/mapbox/node-pre-gyp/issues
npm WARN engine [email protected]: wanted: {"node":">=4.0.0"} (current: {"node":"0.10.30","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=0.12"} (current: {"node":"0.10.30","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">=0.12"} (current: {"node":"0.10.30","npm":"1.4.21"})
npm WARN engine [email protected]: wanted: {"node":">= 4.5.0"} (current: {"node":"0.10.30","npm":"1.4.21"})
|

[email protected] install /home/crypto/crypto-trading-bot/node_modules/sqlite3
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download

/home/crypto/crypto-trading-bot/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/tar/lib/create.js:4
const hlo = require('./high-level-opt.js')
^^^^^
node-pre-gyp ERR! UNCAUGHT EXCEPTION
node-pre-gyp ERR! stack SyntaxError: Use of const in strict mode.
node-pre-gyp ERR! stack at Module._compile (module.js:439:25)
node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:474:10)
node-pre-gyp ERR! stack at Module.load (module.js:356:32)
node-pre-gyp ERR! stack at Function.Module._load (module.js:312:12)
node-pre-gyp ERR! stack at Module.require (module.js:364:17)
node-pre-gyp ERR! stack at require (module.js:380:17)
node-pre-gyp ERR! stack at Object. (/home/crypto/crypto-trading-bot/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/tar/index.js:4:30)
node-pre-gyp ERR! stack at Module._compile (module.js:456:26)
node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:474:10)
node-pre-gyp ERR! stack at Module.load (module.js:356:32)
node-pre-gyp ERR! System Linux 3.10.0-957.el7.x86_64
node-pre-gyp ERR! command "node" "/home/crypto/crypto-trading-bot/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/crypto/crypto-trading-bot/node_modules/sqlite3
node-pre-gyp ERR! node -v v0.10.30
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! This is a bug in node-pre-gyp.
node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help:
node-pre-gyp ERR! https://github.com/mapbox/node-pre-gyp/issues

[email protected] install /home/crypto/crypto-trading-bot/node_modules/talib
node ./src/lib/build.js && node-gyp configure && node-gyp build


/home/crypto/crypto-trading-bot/node_modules/talib/src/lib/build.js:8
let msbuildPath;
^^^^^^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/crypto/crypto-trading-bot/npm-debug.log
npm ERR! not ok code 0
`

Its fresh CentOs.

Thank you.

candle data delayed

Maybe its worthwhile to test the indicators with the data on the last, current, incomplete candle since it takes a while to update on larger timeframes.
CCI or MFI or even RSI are going to be more efficient if the indicator is fed with the current, actual tick data before the close of the current candle.
A few minutes earlier BTC had a drop of 50 usd (significant for leveraged trades) that none of the 15, nor 1hr had any clue about, however if the last candle would have been fed with the actual unclosed candle data, the CCI strategy at least would have signaled correctly a short.

User requested an account-locked subscription but no authorization was provided

Help me

r00t@ubuntu:~/crypto-trading-bot$ node index.js trade
body-parser deprecated undefined extended: provide extended option modules/http.js:43:25
Webserver listening on: 127.0.0.1:8080
(node:2504) [DEP0025] DeprecationWarning: sys is deprecated. Use util instead.
(node:2504) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined
    at new Hmac (internal/crypto/hash.js:88:11)
    at Object.createHmac (crypto.js:133:10)
    at BitmexTestnet.syncPositionViaRestApi (/home/r00t/crypto-trading-bot/exchange/bitmex.js:685:32)
    at f (/home/r00t/crypto-trading-bot/exchange/bitmex.js:91:20)
    at BitmexTestnet.start (/home/r00t/crypto-trading-bot/exchange/bitmex.js:94:14)
    at activeExchanges.forEach.activeExchange (/home/r00t/crypto-trading-bot/modules/exchange/exchange_manager.js:35:66)
    at Array.forEach (<anonymous>)
    at ExchangeManager.init (/home/r00t/crypto-trading-bot/modules/exchange/exchange_manager.js:35:25)
    at Object.boot (/home/r00t/crypto-trading-bot/modules/services.js:110:35)
    at Object.<anonymous> (/home/r00t/crypto-trading-bot/index.js:10:10)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:282:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2504) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:2504) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined
    at new Hmac (internal/crypto/hash.js:88:11)
    at Object.createHmac (crypto.js:133:10)
    at BitmexTestnet.syncOrdersViaRestApi (/home/r00t/crypto-trading-bot/exchange/bitmex.js:728:32)
    at f (/home/r00t/crypto-trading-bot/exchange/bitmex.js:92:20)
    at BitmexTestnet.start (/home/r00t/crypto-trading-bot/exchange/bitmex.js:94:14)
    at activeExchanges.forEach.activeExchange (/home/r00t/crypto-trading-bot/modules/exchange/exchange_manager.js:35:66)
    at Array.forEach (<anonymous>)
    at ExchangeManager.init (/home/r00t/crypto-trading-bot/modules/exchange/exchange_manager.js:35:25)
    at Object.boot (/home/r00t/crypto-trading-bot/modules/services.js:110:35)
    at Object.<anonymous> (/home/r00t/crypto-trading-bot/index.js:10:10)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:282:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
WebSocket [INFO]: Connected.
Bitmex: Connection opened.
{"op":"subscribe","args":"tradeBin1m:XBTUSD"}
{"op":"subscribe","args":"tradeBin5m:XBTUSD"}
{"op":"subscribe","args":"tradeBin1h:XBTUSD"}
{"op":"subscribe","args":"instrument:XBTUSD"}
{"op":"subscribe","args":"order:*"}
{"op":"subscribe","args":"position:*"}
WebSocket [INFO]: Connected.
Bitmex: Connection opened.
{"op":"subscribe","args":"tradeBin1m:ADAZ18"}
{"op":"subscribe","args":"tradeBin5m:ADAZ18"}
{"op":"subscribe","args":"tradeBin1h:ADAZ18"}
{"op":"subscribe","args":"instrument:ADAZ18"}
{"op":"subscribe","args":"tradeBin1m:TRXZ18"}
{"op":"subscribe","args":"tradeBin5m:TRXZ18"}
{"op":"subscribe","args":"tradeBin1h:TRXZ18"}
{"op":"subscribe","args":"instrument:TRXZ18"}
{"op":"subscribe","args":"tradeBin1m:XRPZ18"}
{"op":"subscribe","args":"tradeBin5m:XRPZ18"}
{"op":"subscribe","args":"tradeBin1h:XRPZ18"}
{"op":"subscribe","args":"instrument:XRPZ18"}
{"op":"subscribe","args":"order:*"}
{"op":"subscribe","args":"position:*"}
User requested an account-locked subscription but no authorization was provided.
{"message":"Bitmex: error\"User requested an account-locked subscription but no authorization was provided.\"","level":"error","timestamp":"2018-12-25T10:28:06.636Z"}
User requested an account-locked subscription but no authorization was provided.
{"message":"Bitmex: error\"User requested an account-locked subscription but no authorization was provided.\"","level":"error","timestamp":"2018-12-25T10:28:06.651Z"}
{"message":"Bitfinex: error: Error: auth failed: apikey: digest invalid (FAILED)","level":"error","timestamp":"2018-12-25T10:28:12.239Z"}
{"message":"Mailer: {\"errno\":\"ECONNREFUSED\",\"code\":\"ECONNECTION\",\"syscall\":\"connect\",\"address\":\"125.235.4.59\",\"port\":465,\"command\":\"CONN\"}","level":"error","timestamp":"2018-12-25T10:28:26.624Z"}
Trade module: warmup done; starting ticks
(node:2504) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at instances.symbols.filter (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:91)
    at Array.filter (<anonymous>)
    at TickListener.onTick (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:32)
    at EventEmitter.eventEmitter.on (/home/r00t/crypto-trading-bot/modules/trade.js:132:29)
    at EventEmitter.emit (events.js:182:13)
    at Timeout.setInterval [as _onTimeout] (/home/r00t/crypto-trading-bot/modules/trade.js:81:30)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:2504) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at instances.symbols.filter (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:91)
    at Array.filter (<anonymous>)
    at TickListener.onTick (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:32)
    at EventEmitter.eventEmitter.on (/home/r00t/crypto-trading-bot/modules/trade.js:132:29)
    at EventEmitter.emit (events.js:182:13)
    at Timeout.setInterval [as _onTimeout] (/home/r00t/crypto-trading-bot/modules/trade.js:81:30)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:2504) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined
    at new Hmac (internal/crypto/hash.js:88:11)
    at Object.createHmac (crypto.js:133:10)
    at BitmexTestnet.syncPositionViaRestApi (/home/r00t/crypto-trading-bot/exchange/bitmex.js:685:32)
    at Timeout.f [as _onTimeout] (/home/r00t/crypto-trading-bot/exchange/bitmex.js:91:20)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
(node:2504) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined
    at new Hmac (internal/crypto/hash.js:88:11)
    at Object.createHmac (crypto.js:133:10)
    at BitmexTestnet.syncOrdersViaRestApi (/home/r00t/crypto-trading-bot/exchange/bitmex.js:728:32)
    at Timeout.f [as _onTimeout] (/home/r00t/crypto-trading-bot/exchange/bitmex.js:92:20)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
(node:2504) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at instances.symbols.filter (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:91)
    at Array.filter (<anonymous>)
    at TickListener.onTick (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:32)
    at EventEmitter.eventEmitter.on (/home/r00t/crypto-trading-bot/modules/trade.js:132:29)
    at EventEmitter.emit (events.js:182:13)
    at Timeout.setInterval [as _onTimeout] (/home/r00t/crypto-trading-bot/modules/trade.js:81:30)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)
(node:2504) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at instances.symbols.filter (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:91)
    at Array.filter (<anonymous>)
    at TickListener.onTick (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:32)
    at EventEmitter.eventEmitter.on (/home/r00t/crypto-trading-bot/modules/trade.js:132:29)
    at EventEmitter.emit (events.js:182:13)
    at Timeout.setInterval [as _onTimeout] (/home/r00t/crypto-trading-bot/modules/trade.js:81:30)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)
(node:2504) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at instances.symbols.filter (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:91)
    at Array.filter (<anonymous>)
    at TickListener.onTick (/home/r00t/crypto-trading-bot/modules/listener/tick_listener.js:98:32)
    at EventEmitter.eventEmitter.on (/home/r00t/crypto-trading-bot/modules/trade.js:132:29)
    at EventEmitter.emit (events.js:182:13)
    at Timeout.setInterval [as _onTimeout] (/home/r00t/crypto-trading-bot/modules/trade.js:81:30)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2504) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 9)

Backtesting issue

Hello,

Dashboard seems to work properly but the backtesting give me an error depending indicator and timeframe that I use. Also when its work I get the result page but without any chart(maybe because no signal)

image
image
image

Anyone can help me plz ?

Resampling not working correctly

Hi there,
I have noticed the following:
Example Case Resampling 10m period (resampling from 5m) on Bitmex (implemented analog to the example for 15m)

Each time a new candle is created (every 10m), the new candle in the database table "candlesticks" will have the close value of the previous(!) 5m candle and not the actual close of the 10m period (or the second 5m candle).
This then causes follow up problems with incorrect indicators etc.
It looks to me like that the program does not have the latest 5m candles available during runtime when the resampling methods is called.

When I restart the program, it updates the candlesticks 10m period table with the lates and correct value.
Any idea what could cause this issue?

Edit: I am assuming this is related to for example Bitmex.js line around 230ff

                    setTimeout(async () => {
                        if (resamples[symbol['symbol']] && resamples[symbol['symbol']][period] && resamples[symbol['symbol']][period].length > 0) {
                            for (let periodTo of resamples[symbol['symbol']][period]) {
                                await me.candlestickResample.resample(this.getName(), symbol['symbol'], period, periodTo, true)
                            }
                        }
                    }, 1000);```

If profit target reached, stop order not deleted

  {
        'name': 'risk_reward_ratio',
        'target_percent': 6,
        'stop_percent': 3,
    }

Bitmex exchange. Bot will not know that target was reached and take profit order was executed on exchenge. Stop loss order will hang forever.

Feature Request: Running multiple instances with different conf and instance.js?

Hey, I think it would be great if it would be possible to start bot instances with two parameters (conf.js and instance.js). What do you think? Then it would be possible to let one installation run with multiple instances at once (for example when executing different strategies with the same pairs on the same exchange, then via multiple accounts).

Or is that already possible? I was not able to start the bot with these parameters :)

stop loss orders opened in a loop

If there is a open position and the watchdog is enabled, it does not check for the existence of a stop loss, it puts a new stop loss order over and over and over until the exchange throws a "too many stop loss positions"

Order Retry with Partial Fill already happened failes

Hi there, first of all, thank you very much for making your work open source! I really appreciated it! :-) Is there any option to send you some beers in ETH form?

I just noticed the following issue on BitMEX Testnet. A buy order with 50 contracts got filled with 5 contracts, but then the following order/price update for the rest failed due to being on the wrong side of the order book. when the software then tried to recreate the order it failed with the following message "Invalid order side: undefined"
Why undefined? The order itself says side:"Buy" ? See my attached screenshot.

I also noticed the new order did not take into account that from the previous order already 5 contracts had been filled? Is that correct?

image

Bot stalls after internet disconnection for 2-3 minutes

Hey,

just noticed that the bot stalls/does not update candles anymore etc. after the internet disconnected for a short time (for example 1-2 minutes).
The bot is still visiting the strategy, but it is only working with outdated data. The candles etc. do not get updated anymore.
Here is a screenshot from the log, you can see it still connects to Bitmex, but the candles don't seem to get updated anymore after that disconnection.

image

Do you have an idea what the issue could be/how this could be fixed?

Backtesting : percentage of profits and losses

Hello,
Very impressive work! (I've just discovered this project)

I think a little but useful improvement to the backtesting feature is to show the percentage of profit & losses of the total signals thrown (excluding eventual leverage to take it simple).
I'll study a bit the project and I think I'll made a pull request for this ..if already not done ;)

Thanks

Fix this error?

Can you guide me to fix this error?

r00t@ubuntu:~/crypto-trading-bot$ node index.js trade
undefined:41
    },
    ^

SyntaxError: Unexpected token } in JSON at position 1079
    at JSON.parse (<anonymous>)
    at Object.boot (/home/r00t/crypto-trading-bot/modules/services.js:94:23)
    at Object.<anonymous> (/home/r00t/crypto-trading-bot/index.js:10:10)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:282:19)

Improvement: trailing stop orders

Hello,

I have in mind a possible interesting strategy ..but it would work only creating also trailing stop orders (in bitmex), I hope it will be in a present or future road map ;)

Thanks

Resampling after Backfill?

Thank you again for this great software and for making it open source! Thats greatly appreciated!!
I have noticed that the system does not resample after a backfill, causing in my case the system not having enough candlesticks in the database for my indicator.
Per what I saw the resampling only happens during official trading, and only for the last 750 results from the exchange (Bitmex in my case).
Backfill currently is only possible for Bitmex with the binsizes from Bitmex, no resampling values possible.

Maybe it would be a good enhancement to have the resampling run after the backfill as well, or am I making a mistake here?

Installation Manual

Hello,

for not so good Linux users it will be very nice if you can provide a short install manual for Ubunto or other OS like bash / win.
I hang on a maybe simple problem like

Node index.js trade
and get
module.js:550
throw err;

BR Udo

TypeError: PQueue is not a constructor

Hey there,
with the newest commits I am getting the following error when starting the bot after the first tick arrives. The error repeats with every new tick:

(node:2141) UnhandledPromiseRejectionWarning: TypeError: PQueue is not a constructor at TickListener.onTick (/Users/XXX/bot/modules/listener/tick_listener.js:123:23) at EventEmitter.eventEmitter.on (/Users/XXX/bot/modules/trade.js:123:29) at EventEmitter.emit (events.js:182:13) at Timeout.setInterval [as _onTimeout] (/Users/XXX/bot/modules/trade.js:80:30) at listOnTimeout (timers.js:324:15) at processTimers (timers.js:268:5) (node:2141) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Any idea what change could cause this?

Rate limit exceeded error message

I am getting this error after 1 or 2 minutes after I start it

Webserver listening on: 0.0.0.0:8080 WebSocket [INFO]: Connected. Bitmex: Connection opened. WebSocket [INFO]: Connected. Bitmex: Connection opened. {"op":"subscribe","args":"tradeBin1m:XBTUSD"} {"op":"subscribe","args":"tradeBin5m:XBTUSD"} {"op":"subscribe","args":"tradeBin1h:XBTUSD"} {"op":"subscribe","args":"instrument:XBTUSD"} {"op":"subscribe","args":"tradeBin1m:XBTUSD"} {"op":"subscribe","args":"tradeBin5m:XBTUSD"} {"op":"subscribe","args":"tradeBin1h:XBTUSD"} {"op":"subscribe","args":"instrument:XBTUSD"} {"op":"subscribe","args":"tradeBin1m:ETHUSD"} {"op":"subscribe","args":"tradeBin5m:ETHUSD"} {"op":"subscribe","args":"tradeBin1h:ETHUSD"} {"op":"subscribe","args":"instrument:ETHUSD"} {"op":"subscribe","args":"tradeBin1m:XBTM19"} {"op":"subscribe","args":"tradeBin5m:XBTM19"} {"op":"subscribe","args":"tradeBin1h:XBTM19"} {"op":"subscribe","args":"instrument:XBTM19"} {"op":"subscribe","args":"tradeBin1m:ETHM19"} {"op":"subscribe","args":"tradeBin5m:ETHM19"} {"op":"subscribe","args":"tradeBin1h:ETHM19"} {"op":"subscribe","args":"instrument:ETHM19"} {"op":"subscribe","args":"tradeBin1m:ADAM19"} {"op":"subscribe","args":"tradeBin5m:ADAM19"} {"op":"subscribe","args":"tradeBin1h:ADAM19"} {"op":"subscribe","args":"instrument:ADAM19"} {"op":"subscribe","args":"tradeBin1m:TRXM19"} {"op":"subscribe","args":"tradeBin5m:TRXM19"} {"op":"subscribe","args":"tradeBin1h:TRXM19"} {"op":"subscribe","args":"instrument:TRXM19"} {"op":"subscribe","args":"tradeBin1m:XRPM19"} {"op":"subscribe","args":"tradeBin5m:XRPM19"} {"op":"subscribe","args":"tradeBin1h:XRPM19"} {"op":"subscribe","args":"instrument:XRPM19"} Bitmex: Candle backfill error: {"error":{"message":"Rate limit exceeded, retry in 1 seconds.","name":"RateLimitError"}} {"message":"Bitmex Candle backfill error: {\"error\":{\"message\":\"Rate limit exceeded, retry in 1 seconds.\",\"name\":\"RateLimitError\"}}","level":"error","timestamp":"2019-05-29T12:14:13.507Z"} Bitmex: Candle backfill error: {"error":{"message":"Rate limit exceeded, retry in 1 seconds.","name":"RateLimitError"}} {"message":"Bitmex Candle backfill error: {\"error\":{\"message\":\"Rate limit exceeded, retry in 1 seconds.\",\"name\":\"RateLimitError\"}}","level":"error","timestamp":"2019-05-29T12:14:15.875Z"} Trade module: warmup done; starting ticks Nodejs Environment detected (node:18424) Warning: N-API is an experimental feature and could change at any time.

Limit Order gets created multiple times in some situations

Hey there,

I have just noticed the following since updating to the latest commits.

It seems that my limits orders sometimes get created multiple times! I think this could be related to the message 'Unknown order cleanup'. This is a wrong message as actually the order has filled in that moment per what I saw so far. I am assuming the system takes this error message and creates another buy order?
Strange, I didn't saw this behavior before the latest commits, but I am not 100% sure.

Here is a bit of log from that situation. Hopefully that helps.

Thanks a lot for your work here!!

`
THE ORIGINAL BUY ORDER:

Bitmex 2, [27.05.19 17:20]
Bitmex: Order updated:{"body":"{"orderID":"6c20dXXX","clOrdID":"734XXX","clOrdLinkID":"","account":XXX,"symbol":"ETHUSD","side":"Buy","simpleOrderQty":null,"orderQty":100,"price":268.65,"displayQty":null,"stopPx":null,"pegOffsetValue":null,"pegPriceType":"","currency":"USD","settlCurrency":"XBt","ordType":"Limit","timeInForce":"GoodTillCancel","execInst":"ParticipateDoNotInitiate","contingencyType":"","exDestination":"XBME","ordStatus":"New","triggered":"","workingIndicator":true,"ordRejReason":"","simpleLeavesQty":null,"leavesQty":100,"simpleCumQty":null,"cumQty":0,"avgPx":null,"multiLegReportingType":"SingleSecurity","text":"Amended price: Powered by your awesome crypto-bot watchdog\nPowered by your awesome crypto-bot watchdog","transactTime":"2019-05-27T21:20:26.761Z","timestamp":"2019-05-27T21:20:26.761Z"}"}

Bitmex 2, [27.05.19 17:20]
OrderAdjust: Order adjusted with orderbook price: ["6c20dXXX",268.55,268.65,"bitmex","ETHUSD"]

Bitmex 2, [27.05.19 17:20]
OrderAdjust: No price update needed:["6c20dXXX",268.65,268.65,"bitmex","ETHUSD"]

SUDDENLY THE NEW ORDER (if my Strat would have created it, we would see an additional log entry):
Bitmex 2, [27.05.19 17:20]
Pair State: Create position open order: ["bitmex","ETHUSD","long",{}]

Bitmex 2, [27.05.19 17:20]
Order created: ["b64cXXX","bitmex","ETHUSD",{"id":694XXX,"symbol":"ETHUSD","side":"long","price":268.6,"amount":100,"type":"limit","options":{"adjust_price":true,"post_only":true}},{"id":"b64cXXX","symbol":"ETHUSD","status":"open","price":268.6,"amount":100,"retry":false,"ourId":"694XXX","side":"buy","type":"limit","createdAt":"2019-05-27T21:20:49.306Z","updatedAt":"2019-05-27T21:20:49.420Z","raw":{"orderID":"b64cXXX","clOrdID":"694XXX","clOrdLinkID":"","account":XXX,"symbol":"ETHUSD","side":"Buy","simpleOrderQty":null,"orderQty":100,"price":268.6,"displayQty":null,"stopPx":null,"pegOffsetValue":null,"pegPriceType":"","currency":"USD","settlCurrency":"XBt","ordType":"Limit","timeInForce":"GoodTillCancel","execInst":"ParticipateDoNotInitiate","contingencyType":"","exDestination":"XBME","ordStatus":"New","triggered":"","workingIndicator":true,"ordRejReason":"","simpleLeavesQty":null,"leavesQty":100,"simpleCumQty":null,"cumQty":0,"avgPx":null,"multiLegReportingType":"SingleSecurity","text":"Powered by your awesome crypto-bot watchdog","transactTime":"2019-05-27T21:20:49.306Z","timestamp":"2019-05-27T21:20:49.306Z"},"options":{}}]

Bitmex 2, [27.05.19 17:20]
OrderAdjust: Unknown order cleanup: ["6c20dXXX","bitmex",null]

Bitmex 2, [27.05.19 17:20]
OrderAdjust: No price update needed:["b64cXXX",268.6,268.6,"bitmex","ETHUSD"]

ANOTHER ORDER:
Bitmex 2, [27.05.19 17:20]
Pair State: Create position open order: ["bitmex","ETHUSD","long",{}]

Bitmex 2, [27.05.19 17:20]
Bitmex: Order created:{"body":"{"orderID":"63f06XXX","clOrdID":"142XXX","clOrdLinkID":"","account":XXX,"symbol":"ETHUSD","side":"Buy","simpleOrderQty":null,"orderQty":100,"price":268.6,"displayQty":null,"stopPx":null,"pegOffsetValue":null,"pegPriceType":"","currency":"USD","settlCurrency":"XBt","ordType":"Limit","timeInForce":"GoodTillCancel","execInst":"ParticipateDoNotInitiate","contingencyType":"","exDestination":"XBME","ordStatus":"New","triggered":"","workingIndicator":true,"ordRejReason":"","simpleLeavesQty":null,"leavesQty":100,"simpleCumQty":null,"cumQty":0,"avgPx":null,"multiLegReportingType":"SingleSecurity","text":"Powered by your awesome crypto-bot watchdog","transactTime":"2019-05-27T21:20:58.564Z","timestamp":"2019-05-27T21:20:58.564Z"}"}

Bitmex 2, [27.05.19 17:20]
Order created: ["b64c3XXX","bitmex","ETHUSD",{"id":694XXX,"symbol":"ETHUSD","side":"long","price":268.6,"amount":100,"type":"limit","options":{"adjust_price":true,"post_only":true}},{"id":"b64c3XXX","symbol":"ETHUSD","status":"open","price":268.6,"amount":100,"retry":false,"ourId":"694XXX","side":"buy","type":"limit","createdAt":"2019-05-27T21:20:49.306Z","updatedAt":"2019-05-27T21:20:49.420Z","raw":{"orderID":"b64c3XXX","clOrdID":"694XXX","clOrdLinkID":"","account":XXX,"symbol":"ETHUSD","side":"Buy","simpleOrderQty":null,"orderQty":100,"price":268.6,"displayQty":null,"stopPx":null,"pegOffsetValue":null,"pegPriceType":"","currency":"USD","settlCurrency":"XBt","ordType":"Limit","timeInForce":"GoodTillCancel","execInst":"ParticipateDoNotInitiate","contingencyType":"","exDestination":"XBME","ordStatus":"New","triggered":"","workingIndicator":true,"ordRejReason":"","simpleLeavesQty":null,"leavesQty":100,"simpleCumQty":null,"cumQty":0,"avgPx":null,"multiLegReportingType":"SingleSecurity","text":"Powered by your awesome crypto-bot watchdog","transactTime":"2019-05-27T21:20:49.306Z","timestamp":"2019-05-27T21:20:49.306Z"},"options":{}}]

Bitmex 2, [27.05.19 17:20]
OrderAdjust: Unknown order cleanup: ["6c20dXXX","bitmex",null]

Bitmex 2, [27.05.19 17:20]
OrderAdjust: No price update needed:["b64cXXX",268.6,268.6,"bitmex","ETHUSD"]

Bitmex 2, [27.05.19 17:20]
Pair State: Create position open order: ["bitmex","ETHUSD","long",{}]

Bitmex 2, [27.05.19 17:20]
Bitmex: Order created:{"body":"{"orderID":"63f06XXX","clOrdID":"142XXX","clOrdLinkID":"","account":XXX,"symbol":"ETHUSD","side":"Buy","simpleOrderQty":null,"orderQty":100,"price":268.6,"displayQty":null,"stopPx":null,"pegOffsetValue":null,"pegPriceType":"","currency":"USD","settlCurrency":"XBt","ordType":"Limit","timeInForce":"GoodTillCancel","execInst":"ParticipateDoNotInitiate","contingencyType":"","exDestination":"XBME","ordStatus":"New","triggered":"","workingIndicator":true,"ordRejReason":"","simpleLeavesQty":null,"leavesQty":100,"simpleCumQty":null,"cumQty":0,"avgPx":null,"multiLegReportingType":"SingleSecurity","text":"Powered by your awesome crypto-bot watchdog","transactTime":"2019-05-27T21:20:58.564Z","timestamp":"2019-05-27T21:20:58.564Z"}"}`

bitmex 15m trading bin

In order to use this with Bitmex the code needs to re-construct/resample 15m timeframe from 1m bins.

Error: Unknown table for BitMEX subscription: tradeBin15m.
Available tables are announcement,connected,chat,publicNotifications,instrument,settlement,funding,insurance,liquidation,orderBookL2,orderBookL2_25,orderBook10,quote,trade,quoteBin1m,quoteBin5m,quoteBin1h,quoteBin1d,tradeBin1m,tradeBin5m,tradeBin1h,tradeBin1d,privateNotifications,account,wallet,affiliate,margin,position,transact,order,execution.

Installation errors OSX

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/computer/crypto-trading-bot/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

@tensorflow/[email protected] install /Users/computer/crypto-trading-bot/node_modules/@tensorflow/tfjs-node
node scripts/install.js

  • Downloading libtensorflow
    [==============================] 634557/bps 100% 0.0s
  • Building TensorFlow Node.js bindings
    /Users/computer/crypto-trading-bot/node_modules/@tensorflow/tfjs-node/scripts/install.js:154
    throw new Error('node-gyp rebuild failed with: ' + err);
    ^

Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:381:11)
gyp ERR! stack at Socket.emit (events.js:182:13)
gyp ERR! stack at Pipe._handle.close (net.js:610:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/computer/crypto-trading-bot/node_modules/@tensorflow/tfjs-node
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

at cp.exec (/Users/computer/crypto-trading-bot/node_modules/@tensorflow/tfjs-node/scripts/install.js:154:13)
at ChildProcess.exithandler (child_process.js:301:5)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Socket.stream.socket.on (internal/child_process.js:381:11)
at Socket.emit (events.js:182:13)
at Pipe._handle.close (net.js:610:12)

npm WARN crypto-trading-bot No repository field.
npm WARN crypto-trading-bot No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @tensorflow/[email protected] install: node scripts/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @tensorflow/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/computer/.npm/_logs/2019-04-18T16_00_27_210Z-debug.log

Binance

Hey,

How much effort do you think is needed to get this working with Binance?

TwigException

Error parsing twig template /home/windy/Desktop/crypto-trading-bot/templates/base.html.twig: TwigException: Can't access a key k on an null or undefined object.

Error on tick_listener.js (?)

Maybe it's just a configuration problem.
Anyway I had some errors on console like these:
(node:4052) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
at instances.symbols.filter (/home/gabri/sources/git/crypto-trading-bot/modules/listener/tick_listener.js:98:91)...
So the problem, in my case, is that some symbol.trade.strategies seems not defined in some cases, I haven't investigate too much, anyway a simple fix for this exception is to add this on the lambda filter: "&& symbol.trade.strategies" before "symbol.trade.strategies.length > 0".

Thanks

PS: my instance.js is equals to instance.js.dist on repository
I'm just testing with bitmex_testnet

install

hi.. i got this problem while npm install

25 verbose stack Error: /home/pi/crypto-trading-bot/node_modules/binance-api-node: Appears to be a git repo or submodule.
25 verbose stack at /usr/local/lib/node_modules/npm/node_modules/npm-install-checks/index.js:137:15
25 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
25 verbose stack at FSReqWrap.oncomplete (fs.js:154:5)
26 verbose cwd /home/pi/crypto-trading-bot
27 verbose Linux 4.14.98-v7+
28 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
29 verbose node v10.15.3
30 verbose npm v6.4.1
31 error path /home/pi/crypto-trading-bot/node_modules/binance-api-node
32 error code EISGIT
33 error git /home/pi/crypto-trading-bot/node_modules/binance-api-node: Appears to be a git repo or submodule.
34 error git /home/pi/crypto-trading-bot/node_modules/binance-api-node
35 error git Refusing to remove it. Update manually,
35 error git or move it out of the way first.
36 verbose exit [ 1, true ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.