Giter Club home page Giter Club logo

ctubio / krypto-trading-bot Goto Github PK

View Code? Open in Web Editor NEW
3.3K 237.0 808.0 14.93 MB

Self-hosted crypto trading bot (automated high frequency market making) written in C++

Home Page: https://127.0.0.1:3000

License: Other

Shell 1.19% TypeScript 26.67% C++ 59.64% HTML 0.13% Makefile 5.02% Assembly 0.69% Dockerfile 0.11% C 6.54%
bitcoin cryptocurrency trading-bot trading-platform trading-strategies bob-marley trading trade bot-platform market-maker

krypto-trading-bot's Introduction

self reminder:
patience is the mother of science


*** REFUGEES WELCOME! ***
     *** FATAL ROUTES? ***

Release Platform g0t0 Counter Code Size Software License Software License

K is a family of (very customizable) very low latency market making trading bots with a fully featured web interface.
It can place and cancel orders on one of the several compatible exchanges in less than a few milliseconds per order on a decent machine.

If you don't want to configure or hardcode your own trading strategies in your own machine,
you can run strategies from someone else at kryll.io (or at any other trading community out there).

If you don't want to run a bot at all,
you can fund liquidity pools at tinyman.org (or at any other defi out there).

Build Status Coverage Status Quality Status Open Issues Last Commit Downloads Last Releases

Our bots run on unix-like systems. Persistence is achieved through a built-in server-less SQLite C++ interface.
Data transfers are directly done from your machine to the exchange using the latest CURL and OpenSSL versions.
Installation in a dedicated Debian, Raspberry, Red Hat, CentOS or macOS instance without Docker is recommended.

Web UI Preview

The web UI is compatible with most web browsers/resolutions, but Brave or Firefox at 1600px are recommended. Doesn't require configuration of any web server (unless installed behind your own reverse proxy).

Compatible Exchanges

with Post-Only Orders support without Post-Only
with Maker and Taker fees Coinbase (fees)
REST + WebSocket + FIX

Binance (fees)
REST + WebSocket

Kraken (fees)
REST + WebSocket²

KuCoin (fees)
REST + WebSocket

Bitfinex (fees)
Ethfinex (fees)
REST + WebSocket

Gate.io (fees)
REST + WebSocket

HitBTC (fees)
Bequant (fees)
REST + WebSocket²

Poloniex (fees)
REST + WebSocket
none
without Maker fees BitMEX (fees)
REST + WebSocket
none

All currency pairs are supported (use --list argument to see all currently tradable pairs on a given exchange).

README

Docker Installation

See etc/Dockerfile file.

Windows Installation

Before starting with a manual installation, ensure your target machine has Windows 7 or greater and MSYS2 installed.

Use MSYS2 Terminal to install make (with command pacman -S make), and then proceed as usual with the installation.

Manual GIT Installation

  1. Ensure you agree to install collaborative non-free software (see Unlock section).

  2. Ensure your target machine has git and make installed.

  3. Download it wherever you want (feel free to customize the suggested folder name K) and execute the installer:

 $ git clone ssh://[email protected]/ctubio/Krypto-trading-bot K
 $ cd K
 $ make install
  1. Open and edit the config file K.sh in your favorite text editor:
 $ vim K.sh

To upgrade anytime see Upgrade to the latest commit section.

Manual ZIP Installation

  1. Ensure you agree to install collaborative non-free software (see Unlock section).

  2. Ensure your target machine has curl and make installed.

  3. Download it wherever you want (feel free to customize the suggested folder name K) and execute the installer:

 $ mkdir K
 $ cd K
 $ curl -O krypto.ninja/Makefile
 $ make install
  1. Open and edit the config file K.sh in your favorite text editor:
 $ vim K.sh

To upgrade anytime to the latest release just run make reinstall.

Configuration After Manual Installation

See etc/K.sh.dist file or better your own copy of K.sh file located in the top level path.

It just contains a few variables with examples. The very end of the file contains the code that starts the bot.

Once your config file is ready, you can execute it to start the bot:

 $ ./K.sh

Alternatively use make start to run K.sh in the background using screen (to see the output, attach the screen with make screen [or run all at once with make start screen]).

Feel free to run make stop or make restart anytime, and don't forget to read the fucking manual.

Troubleshooting:

  • If there is no wallet data on a given exchange, double-check the currency symbols with --list argument.

Optional:

  • See at least once ./K.sh --help to trade or make help to develop.

  • Use your own HTTP Basic Authentication credentials with --user and --pass arguments.

  • Use your own SSL certificate with --ssl-crt and --ssl-key arguments.
    Otherwise, the insecure built-in certificate is fully featured, but you may need to authorise it in your browser.
    If you want to generate your own certificate see SSL for internal usage.
    In case you really want to use plain HTTP, use --without-ssl argument.

Upgrade to the latest commit

If you upgrade while having any instance running in the background, you will need to manually restart it using make restart or make restartall to start using the latest version.

Upgrade under Manual ZIP Installation:

Please run make reinstall to download the upgraded source and executable files.

Upgrade under Manual GIT Installation:

Feel free anytime to check if there are new upgrades with make diff.

Once you decide that it is time to upgrade, execute make upgrade (or directly make reinstall to skip the validation of new commits).

If you only use git to pull the latest source files from the remote branch, you will still need to upgrade or recompile your executable files.

To not upgrade but instead recompile your own modified source files, use make lib K or just make (see Build notes).

Multiple instances party time

Please note, an "instance" is in fact a *.sh config file; using a single machine with a single installation, you can run as many instances as *.sh files you have (limited by the available free RAM).

You can list the current running instances with make list.

If you haven't defined a config file, make start, make screen, make stop and make restart will use the default config file K.sh.

To run multiple instances using a collection of config files:

  1. Create a new config file with cp etc/K.sh.dist X.sh && chmod +x X.sh (use X.sh or any name but keep .sh extension).

  2. Edit the new config file vim X.sh

  3. Run the new instance with ./X.sh or to run in the background, use K=X.sh make start. To attach to the new instance's screen, use K=X.sh make screen. To stop the new instance, use K=X.sh make stop and to restart it, use K=X.sh make restart. The environment variable K specifies the filename of the config file that you want to use.

  4. Open in the web browser the different pages of the ports of the different running instances, or display the UI of all instances together in a single page using the MATRYOSHKA link in the footer (that can be predefined using the optional argument --matryoshka=URL).

After multiple config files are setup, to control them all together instead of one by one, the commands make startall, make stopall and make restartall are also available, just remember that config files with a filename starting with underscore symbol "_" will be skipped.

Application Usage

  1. Open your web browser to connect to port 3000 (or your configured port number) of the machine running K. Using localhost or one of the public or private IPs of your machine (if you're running on Docker, use the IP address returned by boot2docker ip).

  2. Read up on how to use K and market making in the manual.

  3. Use the web UI to change the quoting parameters. Click the big "BTC/USD" button to start making markets. Click it again to stop. When the button is green, the bot is actively placing orders.

Web UI

Once K is up and running, visit port 3000 (or your configured port number) to access the UI (i.e. https://localhost:3000). There are inputs for quoting parameters, grids to display market orders, market trades, your trades, your order history, your positions, and a big button with the currency pair you are trading. When you're ready, click that button green to begin sending out quotes. The UI uses angularjs hydrated with websockets observed with reactivexjs.

Databases

Each currency pair of each exchange will use a different sqlite database file with WAL mode enabled.

All database files are located at /var/lib/K/db/K-*.db*, outside the download folder to survive wild rm -rf path/to/K or reinstalls.

You can copy any group of *.db* files to another machine when migrating or as a backup.

If a database does not exist, the application will create it on boot; otherwise, it will use the existing one.

To explore each database you can use https://github.com/sqlitebrowser/sqlitebrowser or a similar tool.

To set a different database filename or to set an in-memory database, use --database=FILE argument (see --help).

Even if using an in-memory database, the quoting parameters are always loaded from and saved into the file database.

Charts

The metrics are not saved anywhere, it is just UI data collected with a visibility retention of n hours (where n is the value of profit quoting parameter), to display over time:

  • Market Fair Value with High and Low Prices
  • Trades Complete
  • Target Position for BTC currency (TBP)
  • Target Position for Fiat currency
  • STDEV and EWMA values for Quote Protection and APR
  • Amount available in wallet for buy
  • Amount held in open trades for buy
  • Amount available in wallet for sell
  • Amount held in open trades for sell
  • Total amount available and held at both sides in BTC currency
  • Total amount available and held at both sides in Fiat currency

Cloud Hosting

If you ask me, is a very nice web hosting company (awesome support team, awesome servers). Feel free to use this referral link to get a discount subtracted from my referral earnings (i'm a user since 2008).

Build notes

Make sure your build machine has node installed, also ensure make lib provides all dependencies without errors.

To rebuild the application, see make help and choose a target (just make may be what you are looking for).

Test units are executed before the application exits, only if the application was compiled with KUNITS=1 make.

Otherwise, just make without the environment var KUNITS produces an application that simply exits on exit.

A quick test runner therefore is ./K.sh --version or the alias make test or all at once with KUNITS=1 make K test.

To pipe the output to stdout, execute the application in the foreground with --naked argument.

For more information consider to follow the white rabbit, but its dangerous to go alone, take this:

c sandbox: wandbox.org

js sandbox: jsfiddle.net

ws sandbox: app.gosandy.io

Release v0.6.x Changelog

Added Hello World bot, Portfolios bot, Scaling bot and Stable bot.

Added Binance, Kraken, KuCoin, Gate.io and BitMEX API.

Release v0.5.x Changelog

Updated exchange integrations as simple libcurl wrappers.

Release v0.4.x Changelog

Added main KryptoNinja class derived from all other classes and ready to be extended.

Added C++ OOP everywhere.

Added test units.

Added --interface=IP argument to bind outgoing traffic to a specific network interface.

Added Ethfinex and FCoin API.

Added build-in document root to stop reading files from disk.

Added build chain for win32.

Updated OKEx websocket to binary data.

Added build chain for OSX v10.13.

Release v0.3.x Changelog

Updated HitBTC API v2.

Added ZIP installation steps for non-git-lovers.

Added HamelinRat quoting mode and Trend safety thanks to b-seite and serzhiio contributions.

Added command-line arguments.

Updated quoting engine and gateways without nodejs.

Added Makefile to replace npm scripts.

Added PNG files as configuration files.

Added built-in C++ WWW Server to replace expressjs and socketio.

Added built-in SQLite C++ interface to replace external mongodb server.

Added Poloniex API.

Release v0.2.x Changelog

Updated application name to K because of Kira.

Added nodejs7, typescript2, angular4 and reactivexjs.

Added cleanup of bandwidth, source code, dependencies and installation steps.

Added many quoting parameters thanks to Camille92 genius suggestions.

Added support for multiple instances/config files with nested matryoshka UI.

Added npm scripts, david-dm, travis-ci, coveralls and codacy.

Added historical charts to replace grafana.

Added C++ math functions.

Updated OKCoin API (since https://www.okcoin.com/t-354.html).

Updated Bitfinex API v2.

Added Coinbase FIX API.

Added Korbit API.

Added new quoting styles PingPong, Boomerang, AK-47.

Added cleanup of database records, memory usage and log recording.

Added audio notices, realtime wallet display, and grafana integration.

Added https, dark theme and new UI elements.

Added a bit of love to Kira.

Release v0.1.0 Changelog

see the upstream project michaelgrosner/tribeca.

Unlock

The bot is unlocked for collaborators and contributors (feel free to make acceptable Pull Requests for already opened issues or for anything you consider useful, and let me know the BTC Payment Address for the bot that you wish to unlock in the description of the PR, and I will credit it for you).

While locked, the orderbook will be in realtime 121 seconds, and later it will be updated only once every 121 seconds.

Anonymous users can also unlock any API Key by paying 0.00121000 BTC to the address displayed on exit.

Once unlocked you may use different bots or currency pairs or reinstall on a different machine with the same unlocked API Key. However, if you want to use more than one exchange, you will need to pay again to unlock the API Key for each exchange.

Otherwise if you choose to not support further development by ctubio, just keep running some old commit and do not upgrade (any commit prior to v0.3.0 was completely unlocked).

Please don't open issues asking how much % less the bot generates with --free-version; it is relative to your trading strategy, the market conditions, and the bot's performance.

Donations

nope, this project doesn't have maintenance costs. but you can donate to your favorite developer today!
(or tomorrow!)

or see the upstream project michaelgrosner/tribeca.

or donate your time with programming or financial suggestions in the IRC channel #krypto.ninja at irc.libera.chat on port 6697 (SSL), or 6667 (plain); or feel free to make any question, but questions technically are not donations.

General Discussion

IRC is awesome!

but if you dislike it, consider to create a new discussion permanently readable by everybody.

Very Special Thanks to:

Help

If you need installation or usage support, please create a new discussion.

Issues

To request new features open a new issue and explain your improvement as you consider.

To report errors open a new issue only after collecting all possible relevant log messages.

Pull Requests are welcome, but adhere to the Contributor License Agreement:

  • Your biological and technological distinctiveness will be added to our own. Resistance is futile.

like yesterday, since 0day and ∞

bcn

every new day we sing:

If love is so nice, tell me why are you so sad?
If love is so nice, tell me, oh tell me why are you hurt so bad?
One Love! get ready!

Now feel this drumbeat as it beats within,
playin' a riddim, resisting against the system:



We have already enough policemen,
if you like adventures choose to be a brave firefighter.








Violence should not be the answer to those who
are asking for freedom.













+ 99999

krypto-trading-bot's People

Contributors

86chenjie avatar ahalekelly avatar ak9250 avatar b-seite avatar benmarten avatar boogey100 avatar camille92 avatar corfucinas avatar ctubio avatar dasbasti avatar diogosalazar avatar donaldforest avatar gitter-badger avatar jangrewe avatar jokot3 avatar kojojacob avatar michaelgrosner avatar mikadily avatar nazariyv avatar nonkreon avatar notvitaliy avatar overlordq avatar pascal66 avatar ricardohbin avatar samhug avatar serzhiio avatar shanejonas avatar waldyrious avatar xloem avatar zachaller 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

krypto-trading-bot's Issues

Can't reinstall ?

Hi Carles,

I'm moving to CentOS machines and to the Alibaba servers I was telling you about but I can't get anything to work :S.

Here is a list of the problems:
node-gyp and rebuild don't install automatically, but a npm install -g fixes it.

Then I have problems with stunnel:

It doesn't get installed so I get: after a npm start:

> [email protected] test-stunnel /root/K
> test -z "$SKIP_STUNNEL$(ps axu | grep stunnel | grep -v grep)" && exec stunnel dist/K-stunnel.conf || :

sh: line 0: exec: stunnel: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] test-stunnel: `test -z "$SKIP_STUNNEL$(ps axu | grep stunnel | grep -v grep)" && exec stunnel dist/K-stunnel.conf || :`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] test-stunnel 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!     /root/.npm/_logs/2017-06-21T18_33_35_898Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `npm run test-compile && forever start --uid $npm_package_config_config -a -l /dev/null K.js $npm_package_config_config && exec npm run test-stunnel`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start 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!     /root/.npm/_logs/2017-06-21T18_33_35_944Z-debug.log

If I install it with npm it doesn't change anything, but if I install it with yum I get:

> test -z "$SKIP_STUNNEL$(ps axu | grep stunnel | grep -v grep)" && exec stunnel dist/K-stunnel.conf || :

Clients allowed=31999
stunnel 4.56 on x86_64-redhat-linux-gnu platform
Compiled/running with OpenSSL 1.0.1e-fips 11 Feb 2013
Threading:PTHREAD Sockets:POLL,IPv6 SSL:ENGINE,OCSP,FIPS Auth:LIBWRAP
Reading configuration from file dist/K-stunnel.conf
FIPS mode is enabled
Compression not enabled
PRNG seeded successfully
Initializing service [gdax_stream]
Error loading verify certificates from /usr/local/etc/stunnel/fix.gdax.com.pem
error queue: B084002: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
error queue: 2006D080: error:2006D080:BIO routines:BIO_new_file:no such file
SSL_CTX_load_verify_locations: 2001002: error:02001002:system library:fopen:No such file or directory
Service [gdax_stream]: Failed to initialize SSL context
str_stats: 10 block(s), 1153 data byte(s), 580 control byte(s)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test-stunnel: `test -z "$SKIP_STUNNEL$(ps axu | grep stunnel | grep -v grep)" && exec stunnel dist/K-stunnel.conf || :`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test-stunnel 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!     /root/.npm/_logs/2017-06-21T18_30_54_750Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `npm run test-compile && forever start --uid $npm_package_config_config -a -l /dev/null K.js $npm_package_config_config && exec npm run test-stunnel`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start 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!     /root/.npm/_logs/2017-06-21T18_30_54_795Z-debug.log

Any idea about what I can do ?

Thank you very much,

Camille

Bitfinex SyntaxError: Unexpected token < in JSON at position 0

.:CarlitoGrey:. 19:42:50.908 main Unhandled promise rejection! SyntaxError: Unexpected token < in JSON at position 0
.:CarlitoGrey:. at Object.parse (native)
.:CarlitoGrey:. at Request.err [as _callback] (/home/####/K2/app/server/gateways/bitfinex.js:392:41)

Latency

High latency on trades, how is this value being calculated as it seems a little high. Just moving over here from tribeca where the (hidden) computationalLatency was around 0-1ms. Hosted near GDAX so I'm sure it's not the connection.

image

Unhandled rejection! if exchange is offline or api saturated

Running on Mac OSX after having no luck on linux (debian & ubuntu).
But getting the following error:

Unhandled rejection! TypeError: symbolDetails[Symbol.iterator] is not a function at Object.<anonymous> (/Users/adam/Dropbox/Work/Crypto/krypto/app/server/gateways/bitfinex.js:474:21)

any ideas?

Sometimes it's good to be a taker -> "Sniper"/scalper option

Hello everyone,

Here is a new idea for an improvement that imho can add a few extra % to Tribeca's profit.

There are two times when it can be interesting to be a taker, the first one is when your asset moves quicker than the fee you would pay remaining a 'taker' + the spread.
The idea is that it's not rational to keep your asset to save 0.2% in fees when it's falling by 3 or 4% that or to not jump in when it's going up very quickly.
This case is discussed in the Safeties issue https://github.com/ctubio/tribeca/issues/32 so no need to come back here too much.

The second case is when there are big "hollows" in the market.
Thanks to @ctubio great work with the bw? option Tribeca never creates hollow but it's not the case of other traders around.

I believe we can use that to our advantage in precise situations. It needs a bit of explanation so know when it works and when it doesn't so here I go.
I explain first the general idea, in a second time the conditions to respect and in a third time some ideas about implementation.

General explanation:

This situation happens when the best bid or best offer on the market is far away from the 2nd best bid or best ask.
The idea is to match this order being a taker and resell it just below the 2nd best ask and vice versa.

Here is an example on ZEC/USD:
capture d ecran 2017-05-24 a 13 00 36
You can see that between the order at 272 and the one at 275.35 there is a big hollow of 1.23% exactly.

If we can match the order and sell it at 275.35 we can make a good profit of:
1.23 (size of the hollow) - 0.2 (buy taker fee) - 0.1 (sell maker fee) = 0.93%

Very interesting for just playing a bit with the market!

Conditions for it to work and implementation:

Now that we have seen the general functioning we have to remember that it is not interesting all the time and that we need to comply certain conditions to take the risk.

  1. the orders we're matching should be smaller or equal our orderSize:
    If we don't match this condition, we just buy/sell and are not sure to ever be able to sell higher/lower.

  2. Our position + the order we want to match should respect pdiv + tbp

  3. Following 2) If APR is on or pdiv + tbp is not respected we should just be able to do it on the depleted side.

  4. It might be interesting to check for volatility with STDEV if the "hollow" is big enough (ie. hollow > to STDEV)

Some implementation ideas:

What we need to do here is to calculate the % between the best.bid and the second best bid and the best ask and the second best ask. (Excluding ourselves!)

Then check if the conditions are met (described above) and verifying that the hollow is superior at the target put by the user.
We can discuss the conditions maybe it's interesting to someone to buy even if the order is bigger than its order size because it hopes that someone else will try to get that order as well.

When we need to send a limit order (not post only) of the size and at the price of the order.
I really think a limit order is way better than a market order here because if someone outrun us we would not send the order out to the unknown. Time is going to be crucial for that to work so it will not be surprising if we have to fight for those orders against other bots.

Tell me what you think in my opinion it can really boost Tribeca and even 'trick' other bots while increasing width.
I believe I'm not ultra clear on this post so please ask if you have questions.

Ps: I think it goes well with the name 'sniper' because we hide for a long time and "shoot" the first order if all the conditions are met.

IOTA @Bitfinex not working ?

Hi Carles,

I did not have time to try those markets before but apparently, they don't work.

Do you experience the same issue?

Best,

Camille

Will not start with gdax

When starting this gets thrown

14:31:43.247 coinbase FIX Initiator Start
14:31:43.260 coinbase FIX Logon Connected
14:31:43.363 main Unhandled exception! TypeError: Cannot read property 'mask' of undefined
    at Sender.frameAndSend (/home/zaller/Krypto-trading-bot/node_modules/gdax/node_modules/ws/lib/Sender.js:206:17)
    at /home/zaller/Krypto-trading-bot/node_modules/gdax/node_modules/ws/lib/Sender.js:126:12
    at /home/zaller/Krypto-trading-bot/node_modules/gdax/node_modules/ws/lib/PerMessageDeflate.js:313:5
    at afterWrite (_stream_writable.js:430:3)
    at onwrite (_stream_writable.js:421:7)
    at afterTransform (_stream_transform.js:102:3)
    at TransformState.afterTransform (_stream_transform.js:75:12)
    at Zlib.callback (zlib.js:471:7)
14:31:43.370 main All exiting event handlers have fired, exiting application.
14:31:43.370 main Exiting with code 0

Hello SQLite

Where?
database storage

What?
now the app uses internally sqlite instead of an external mongodb; after npm run latest the previous mongodb database will not be used, therefore all previous data will be lost.

do not upgrade until you are prepared to loose your database (you may want to write down your settings).
after upgrade feel free to stop and remove or purge mongodb from your system.

When?
since 71cc8e0

Why?
sqlite is smaller and faster than mongodb in single-user non-concurrent applications, have less useless features and is less painfull to install/maintain/migrate/backup.

Nonce error when connecting to poloniex

app exchange: Poloniex/ETH/BTC
app version: latest

Hi, just find a bug when connecting to poloniex.
There is no information of trade history or my balance.
Seems that when requesting information, time does not fit the server.
Docker log:

04:09:19.588 poloniex Error returnTradeHistory Nonce must be greater than 1498190957748. You provided 1498190954412.
04:09:38.667 poloniex Error returnCompleteBalances Nonce must be greater than 1498190977751. You provided 1498190974287.

Might be a little modification in
line 15: nonce?: number in /src/server/gateways/poloniex.ts ?

Thanks.

Question: What's is the roadmap for K?

Hi Carles,

More of a general question here, what's your roadmap for K?

And how can I help? Do you need funds and how much? Can I help by helping for strategies/ways of implementing?

Best,

Camille

Orders go off in UI - not reflected in GDAX

I am running the bot on Windows via docker - I am able to connect and everything appears to working correctly. Some buys and asks cycled through and showed up in the order log. However, my gdax doesn't reflect any such order, nor does it show any open orders.

Safeties

@Camille92 said at #28:

The goal of this safety is to be protected by sudden rise or drops in the price. It works with a simple formula: If x% drop (or rise) in y minutes : market sell (or buy) your position + change TBP to 0 (or 1).

Example: If I set the limit to be 2% in 5 minutes if the price moves up by those number, I market buy to enjoy the ride.

Target base position has to be changed when the safety is triggered so that tribeca doesn't start to sell and/or activate APR right after buying.
The difficult part is to find a trigger for when to start to reuse normal APR instead of the "safety" one.
I have two ideas for that the first one is to switch back to normal when EWMA 100 starts ro rise (or go down). The second one is to use a timer counting to 10 or 20 minutes.

2 small improvements

Camille said: Hello Carles,

If you don't find that annoying that I'm always posting new stuff, I'm coming this week with a little list of small improvements that, IMHO can make life easier using Tribeca and raise some profits.

(If you don't mind I kind of find it funny to try to come each week with one big or a few small ideas to make Tribeca better)

Confort improvement:

1) Ak-47 bullets in % if width % is activated [WONT FIX]
I think this one is just following the logic of "all % option" and bullets of Ak-47 is the last one not % compatible.

2) "Auto-cleaning of K orders": [FIXED]
I don't know if you have the same issue but if I don't check Tribeca for some time then it takes a while to load (if it loads) because there are too many orders waiting there.
I guess a tick box that would get rid of the closed orders can be a good idea (maybe keeping the last 100 and getting rid of the oldest), well tell me what you think about that

3) Labeling each line of Tribeca for its function: [FIXED]
Tribeca has different strategies in it, I think it might be a bit more explicit for everyone to clearly divide the rows in the UI, so you understand what you're doing when you're touching to a row.
First one: "Market Making"
Second one: " Technical Analysis"
Third one: "Protections"
Fourth one (I hope :p): "Safeties"

Performance improvement:

1) Option Pdiv = 0 if TargetPosition > Sensibility [DONE SIMILAR]

The goal is twofold, first to stop the "leaking" of profit when Tribeca is in the good direction with the market but will anyway sell or buy just because is going to try to do some market making.
Sometimes it's just good to buy and hold or just stay away from the market.

Second, is to allow a bigger Pdiv for "normal market", because I'm afraid of that "leak", over time I reduced the size of Pdiv to about 5%. However, in normal market condition (when TBP is central) it is more interesting to have a bigger Pdiv. With this option, one can easily have a big Pdiv and still be sure that if the market goes strongly in one direction there will be no "leak".

I'm not sure if it should be linked to the sensibility we have already or to a separate one but I really think it's a good idea in general. If we have a separate sensibility we can choose to put that higher that TPB sensibility to only in BIG market movement you're locking Pdiv.
Ie: TBP sensibility 0.5 but Pdiv lock sensitibility = 1.

2) Ewma width: [PENDING]

We all the recent improvements (Stdev and EWMA_LMS) I think this one should be quite easy to implement.
I think it should take the general design of Stdev with periods in seconds and a factor. However here what we calculate is the ewma of the width.

The concept is just not to post an order with a small width if the width has been bigger before.

minAsk = FV + (ewma_width(periods)*ewma_width_factor) / 2
minBid = FV - (ewma_width(periods)*ewma_width_factor) / 2

I think this should work well with a small value and in complement with Stdev Fair or Top ideally because they don't take into account the width but just the evolution of the price :).

Tell me what you think about all of that!

I know it might be the most important things but I think it cool to always come with new ideas :)

GDAX exception

Hi, just set up a new install this morning and I'm getting the following error after a few seconds of connecting to the GDAX exchange.

I have tried pulling v3.0 of the ws lib as I thought it may be the same as the closed issue, however this didn't resolve the error.

10:33:15.546 coinbase FIX Initiator Start
10:33:16.862 coinbase FIX Logon Connected
10:33:16.872 main Event loop delay 800ms
10:33:16.872 stdev Unable to compute value
10:33:16.895 tbp recalculated 0.12240369842414277
10:33:31.358 main Unhandled exception! TypeError: Cannot read property 'sub' of undefined
at Orderbook.prototype.match (/home/######/K/node_modules/gdax/lib/orderbook.js:142:28)
at OrderbookSync.prototype.processMessage (/home/######/K/node_modules/gdax/lib/orderbook_sync.js:127:14)
at OrderbookSync.prototype.onMessage (/home/######/K/node_modules/gdax/lib/orderbook_sync.js:51:12)
at emitOne (events.js:96:13)
at WebSocket.emit (events.js:188:7)
at Receiver._receiver.onmessage (/home/######/K/node_modules/gdax/node_modules/ws/lib/WebSocket.js:146:47)
at Receiver.dataMessage (/home/######/K/node_modules/gdax/node_modules/ws/lib/Receiver.js:389:14)
at Receiver.getData (/home/######/K/node_modules/gdax/node_modules/ws/lib/Receiver.js:330:12)
at Receiver.startLoop (/home/######/K/node_modules/gdax/node_modules/ws/lib/Receiver.js:165:16)
at Receiver.add (/home/######/K/node_modules/gdax/node_modules/ws/lib/Receiver.js:139:10)
at TLSSocket._ultron.on (/home/######/K/node_modules/gdax/node_modules/ws/lib/WebSocket.js:142:22)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
at TLSWrap.onread (net.js:547:20)

Friendly tip to be ready for Poloniex!

Hi Carles,

I've seen you're working on Poloniex!

Haha it should be fun and bring a lot of potential profits, but a shitshow to set up! (45 markets !!!!!!)

So I stumbled on that the other day and you might be interested in it (or anyone).

At Alibaba Cloud they now offer a $30 a YEAR quite decent VPS!

So if you or anyone is interested here is my reference link -> https://account-intl.aliyun.com/register/intl_register.htm?biz_params=%7B%22intl%22%3A%22%7B%5C%22referralCode%5C%22%3A%5C%22yy0yuh%5C%22%7D%22%7D

$20 for me and 300 dollars of credit if you register here (I don't know the details).

Have a good weekend and don't hesitate to close / modify this post if you don't find it relevant,

Best,
Camille

Cost basis based logging

Hi all,
is there any logging available or any useful query against the DB that can show the cost basis based on FIFO?
the reason is obviously for tax reporting purposes, I understand GDAX which i trade will provide something but I'd like to be ready from my side just in case.

Docker error, invalid container name (K)

Following the docker steps I get the following error.

 # docker run -p 3000:3000 --link K-mongo:mongo --name K -d k
 docker: Error response from daemon: Invalid container name (K), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed.
 See 'docker run --help'.

GUI blank screen on Safari

I can not use the GUI on iOS. The only thing after login is a blank screen with a ? In the title.
It worked several days ago like a charm on iPhone an iPad but after a npm run latest I see nothing like a white page.

The bot is working normally with auto start and trades like before.

I reinstalled the cert but nothing changed.
Even without a cert-folder there is no difference, still a white screen

I am running the latest commit on Ubuntu 16.4

Tested with Safari and Firefox on iOS 9 & 10

Any ideas?

New markets at Bitfinex starting 1st July : EOS/USD EOS/BTC EOS/ETH

Just to be ready when they arrive!

Ps: I just passed the 7.5 Million traded there and reached the 0 market maker fee!
I'm so happy and if you can achieve the same you have a BIG advantage against everyone so it's a few weeks with limited profits or loss but (hopefully) now it's going to be awesome !

Bug alt markets on Gdax

Hi Carles,

I'm struggling to get the Alt markets (LTCBTC LTCEUR ETHBTC ETHEUR) to work on Gdax.

Everything is fine, I get my info and the market info is updated just no order is sent to the market.

Or if it's sent then it's not updated.

Do you manage to reproduce the same?

quoting seems odd

Hi,

I've finally resolved my local issues and am trading. I'm noticing a few things and not sure if its expected or not. One thing right now: the fair value is displayed as 2611.9 (BBO). My width is 0.9. However the bid is posted at 2610 not 2611. Attached is screenshot. If 0.9 is pct then it should be 0.009*2611.9 = 23.5, which is even further away.

image

Also, I was going to do some analysis of market data vs where quotes were placed, check latency, analyse profits on trades etc. Is there a report already built ? If not I will start investigating it.

cheers

E11000 duplicate key error index: tribeca.mkt.$_id_

persister { MongoError: E11000 duplicate key error index: tribeca.mkt.$_id_  dup                                                                key: { : ObjectId('5951167bc9df0331fa366c80') }
    at Function.MongoError.create (/home/admin/K/node_modules/mongodb-core/lib/e                                                               rror.js:31:11)
    at toError (/home/admin/K/node_modules/mongodb/lib/utils.js:139:22)
    at /home/admin/K/node_modules/mongodb/lib/collection.js:669:23
    at handleCallback (/home/admin/K/node_modules/mongodb/lib/utils.js:120:56)
    at resultHandler (/home/admin/K/node_modules/mongodb/lib/bulk/ordered.js:421                                                               :14)
    at getLastErrorCallback (/home/admin/K/node_modules/mongodb-core/lib/wirepro                                                               tocol/2_4_support.js:466:18)
    at /home/admin/K/node_modules/mongodb-core/lib/connection/pool.js:469:18
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
  name: 'MongoError',
  message: 'E11000 duplicate key error index: tribeca.mkt.$_id_  dup key: { : Ob                                                               jectId(\'5951167bc9df0331fa366c80\') }',
  driver: true,
  code: 11000,
  index: 0,
  errmsg: 'E11000 duplicate key error index: tribeca.mkt.$_id_  dup key: { : Obj                                                               ectId(\'5951167bc9df0331fa366c80\') }',
  getOperation: [Function],
  toJSON: [Function],
  toString: [Function] } Unable to insert mkt [ MarketStats {
    fv: 2218.65,
    bid: 2218.06,
    ask: 2219.27,
    time: 2017-06-26T14:12:59.120Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c80 },
  MarketStats {
    fv: 2218.65,
    bid: 2218.06,
    ask: 2219.27,
    time: 2017-06-26T14:13:00.120Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c81 },
  MarketStats {
    fv: 2218.65,
    bid: 2218.06,
    ask: 2219.27,
    time: 2017-06-26T14:13:01.120Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c82 },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:02.258Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c83 },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:03.357Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c84 },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:05.538Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c85 },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:07.279Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c86 },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:08.989Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c87 },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:12.755Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 5951167bc9df0331fa366c88 },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:15.927Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 59511688c9df0331fa366c8a },
  MarketStats {
    fv: 2218.78,
    bid: 2218.06,
    ask: 2219.51,
    time: 2017-06-26T14:13:18.297Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 59511688c9df0331fa366c8b },
  MarketStats {
    fv: 2218.83,
    bid: 2218.06,
    ask: 2219.6,
    time: 2017-06-26T14:13:24.578Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 59511688c9df0331fa366c8c },
  MarketStats {
    fv: 2219.06,
    bid: 2218.06,
    ask: 2220.07,
    time: 2017-06-26T14:13:27.088Z,
    exchange: 3,
    pair: CurrencyPair { base: 0, quote: 2 },
    _id: 59511688c9df0331fa366c8d },
  MarketStats {
    fv: 2219.06,
    bid: 2218.06,
    ask: 2220.07,
    time: 2017-06-26T14:13:28.807Z } ]
14:13:30.614 main Event loop delay 1300ms
14:13:33.299 main Event loop delay 2200ms
14:13:38.369 main Event loop delay 4600ms
14:13:39.044 main Event loop delay 200ms
14:13:43.257 main Event loop delay 3700ms
14:13:49.484 main Unhandled promise rejection! { MongoError: Invalid Operation,                                                                No operations in bulk
    at Function.MongoError.create (/home/admin/K/node_modules/mongodb-core/lib/e                                                               rror.js:31:11)
    at toError (/home/admin/K/node_modules/mongodb/lib/utils.js:139:22)
    at OrderedBulkOperation.execute (/home/admin/K/node_modules/mongodb/lib/bulk                                                               /ordered.js:503:11)
    at bulkWrite (/home/admin/K/node_modules/mongodb/lib/collection.js:664:8)
    at Collection.insertMany (/home/admin/K/node_modules/mongodb/lib/collection.                                                               js:534:44)
    at collection.(anonymous function).then.coll (/home/admin/K/app/server/persi                                                               ster.js:113:34)
    at tryCatcher (/home/admin/K/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/admin/K/node_modules/bluebird/js                                                               /release/promise.js:512:31)
    at Promise._settlePromise (/home/admin/K/node_modules/bluebird/js/release/pr                                                               omise.js:569:18)
    at Promise._settlePromiseCtx (/home/admin/K/node_modules/bluebird/js/release                                                               /promise.js:606:10)
    at Async._drainQueue (/home/admin/K/node_modules/bluebird/js/release/async.j                                                               s:138:12)
    at Async._drainQueues (/home/admin/K/node_modules/bluebird/js/release/async.                                                               js:143:10)
    at Immediate.Async.drainQueues (/home/admin/K/node_modules/bluebird/js/relea                                                               se/async.js:17:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)
  name: 'MongoError',
  message: 'Invalid Operation, No operations in bulk',
  driver: true } Promise {
  _bitField: 18087936,
  _fulfillmentHandler0:
   { MongoError: Invalid Operation, No operations in bulk
       at Function.MongoError.create (/home/admin/K/node_modules/mongodb-core/li                                                               b/error.js:31:11)
       at toError (/home/admin/K/node_modules/mongodb/lib/utils.js:139:22)
       at OrderedBulkOperation.execute (/home/admin/K/node_modules/mongodb/lib/b                                                               ulk/ordered.js:503:11)
       at bulkWrite (/home/admin/K/node_modules/mongodb/lib/collection.js:664:8)
       at Collection.insertMany (/home/admin/K/node_modules/mongodb/lib/collecti                                                               on.js:534:44)
       at collection.(anonymous function).then.coll (/home/admin/K/app/server/pe                                                               rsister.js:113:34)
       at tryCatcher (/home/admin/K/node_modules/bluebird/js/release/util.js:16:                                                               23)
       at Promise._settlePromiseFromHandler (/home/admin/K/node_modules/bluebird                                                               /js/release/promise.js:512:31)
       at Promise._settlePromise (/home/admin/K/node_modules/bluebird/js/release                                                               /promise.js:569:18)
       at Promise._settlePromiseCtx (/home/admin/K/node_modules/bluebird/js/rele                                                               ase/promise.js:606:10)
       at Async._drainQueue (/home/admin/K/node_modules/bluebird/js/release/asyn                                                               c.js:138:12)
       at Async._drainQueues (/home/admin/K/node_modules/bluebird/js/release/asy                                                               nc.js:143:10)
       at Immediate.Async.drainQueues (/home/admin/K/node_modules/bluebird/js/re                                                               lease/async.js:17:14)
       at runCallback (timers.js:672:20)
       at tryOnImmediate (timers.js:645:5)
       at processImmediate [as _immediateCallback] (timers.js:617:5)
     name: 'MongoError',
     message: 'Invalid Operation, No operations in bulk',
     driver: true },
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined }

Installing error ?

Hi Carles,

I bump into that issue when I run the install (with --unsafe-perm):

Error: Cannot find module 'lodash.isplainobject' (While processing preset: "/K/node_modules/babel-preset-babili/lib/index.js") while parsing file: /K/app/pub/js/client/main.js
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/K/node_modules/babel-preset-babili/lib/index.js:7:21)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
up to date in 20.446s

It seems that the bot works (order sent) but I can't access the web UI. :S

Missed opportunities

Hello All,
I've been testing the bot for about a week in LTC-USD market, I played with every settings to get familiar with it. The good news with this bot is at least you don't lose the money. but at the same time it won't grow it either.

The issue here that the bot misses a lot of good sell/buy opportunities, for example the price dropped from 51.30 to 50:30 and the bot kept dropping the quoted price and move it away until the price finally started to rise again and instead of buying at 50.30, it bought it 50:89!

I tried with the lowest width possible, different Stdev settings, BB on and off, different TBP/PDiv, but they are all the same at the end

From my week observation with whatever settings I choose, the bot start buying when the price is in decline or about to decline.
And selling quickly when the price start to rise fractionally above the buy price.
So the margin at the end is very slim.
I just get out break even every time and I feel like working for the exchange! I don't know but apparently the bot work in reverse.

Looking at the chart manually, I easy made 10$ in one hour using two direct trades on the exchange, with the bot I really have to wait longer and the return is not big at the end

I'm not asking for a strategy, (read quite a few) I but want to know how to make bot more smart/efficient to such price drops and falls.
any general tips/tricks? sometime it missies an opportunity every hour or so for easy .5$ profit.

I really did my homework and read a lot about trading strategies but the point above is just killing me, other wise this will be an awesome bot.

I really want to send some chocolate milk but to do that the cow must produce some milk first and then i'll add the chocolate :-)

Thanks.

Improvement: New mode: Double Barrel

Hello Carles,

This improvement goes in between AK-47 and putting multiple markets in one instance.

I used to use a lot 'AK-47' but I find it too rigid and I did not find it very useful to have more than 2 bullets.

The goal here is to have 2 bullets but that act separately ie: their calculation does not depend on the other. This can allow having a "tight" small bullet and a larger that is not going to be hit very often.

For instance one with a width setting of 0.1% and another with 0.3% in case there is a big movement.

Or one using ewma? and the other one not, one with Stdev and the other one with stdev + BB.

One with stdev at 60 periods and the other one at 600.

In the end, the ultimate goal is to be able to have 2 strategies at once (ideally but you're free to do what you want) one shorter term and one longer term.

(FV, APR mode, SOP, Pdiv, TBP calculation will still be shared.)

What do you think about it? Would that be doable resource wise?
Can we send both orders at the same time to not overload the API?

Commit "Updated tbp loaded on boot from database to resolve #27." breaks K

Hi Carles,

I ran a few tests to this Updated tbp loaded on boot from database to resolve #27. breaks K and gives something like that on boot.

4:28:22.082 main Unhandled rejection! TypeError: Cannot read property 'value' of undefined
    at new FairValueEngine (/K/app/server/fair-value.js:22:67)
    at Object.<anonymous> (/K/app/server/main.js:204:22)
    at Generator.next (<anonymous>)
    at fulfilled (/K/app/server/main.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:109:7) Promise {
  <rejected> TypeError: Cannot read property 'value' of undefined
    at new FairValueEngine (/K/app/server/fair-value.js:22:67)
    at Object.<anonymous> (/K/app/server/main.js:204:22)
    at Generator.next (<anonymous>)
    at fulfilled (/K/app/server/main.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:109:7) }

Bot crash each time an order is closed

Hi Carles,

Thank you for changing MongoDB for SQLite, I've already seen improvements in the CPU usage :)

However, I noticed a (bit annoying) bug with the current version. Each time an order is "closed" (K) the bot crashes.

Here is the log I got about it!

09:43:40.828 bitfinex TypeError: x.time.getTime is not a function
    at cleanTrades.tradesMemory.filter (/K/app/server/broker.js:243:102)
    at Array.filter (native)
    at Evt.OrderBroker.updateOrderState [as _singleCallback] (/K/app/server/broker.js:243:57)
    at Evt.trigger (/K/app/server/utils.js:28:22)
    at orders.forEach.order (/K/app/server/gateways/bitfinex.js:257:34)
    at Array.forEach (native)
    at BitfinexOrderEntryGateway.onOrderAck (/K/app/server/gateways/bitfinex.js:256:20)
    at BitfinexOrderEntryGateway._socket.setHandler (/K/app/server/gateways/bitfinex.js:292:22)
    at WebSocketClient.BitfinexWebsocket.onMessage [as internalOnMessage] (/K/app/server/gateways/bitfinex.js:116:21)
    at native.client.group.onMessage (/K/node_modules/uws/uws.js:57:15) Error parsing msg [0,"oc",[2916630745,0,729420161,"tBTCUSD",1498729420306,1498729420736,0,0.03639052,"EXCHANGE LIMIT",null,null,null,0,"EXECUTED @ 2505.9(0.04)",null,null,2505.9,2505.9,0,0,null,null,null,0,0,0]]
09:43:40.829 main Unhandled exception! TypeError: x.time.getTime is not a function
    at cleanTrades.tradesMemory.filter (/K/app/server/broker.js:243:102)
    at Array.filter (native)
    at Evt.OrderBroker.updateOrderState [as _singleCallback] (/K/app/server/broker.js:243:57)
    at Evt.trigger (/K/app/server/utils.js:28:22)
    at orders.forEach.order (/K/app/server/gateways/bitfinex.js:257:34)
    at Array.forEach (native)
    at BitfinexOrderEntryGateway.onOrderAck (/K/app/server/gateways/bitfinex.js:256:20)
    at BitfinexOrderEntryGateway._socket.setHandler (/K/app/server/gateways/bitfinex.js:292:22)
    at WebSocketClient.BitfinexWebsocket.onMessage [as internalOnMessage] (/K/app/server/gateways/bitfinex.js:116:21)
    at native.client.group.onMessage (/K/node_modules/uws/uws.js:57:15)
09:43:40.830 main Attempting to cancel all open orders, please wait..
09:43:42.830 main Exit code 0

High CPU Usage

This is seen alongside high main loop wait times and high order latency (>1s).

image

High CPU load

Perhaps it´s just a question: I noticed that after on our of running my GDAX Bot gets a quiet high CPU load, even if i stop trading.
When i start K the CPU load of node is around 5%. (latest commit on ubuntu 16.04)
Then 1 our later it rises up to a maximum of 50-70% and in the same time the trading latency rises up from 1-5ms to 50-100ms. The average load is around 40-50%
perhaps it´s normal behavior but i can't imagine that the bot has so much to do.

thanks for an Answer or help

(Small improvement) wBBO + depth

Hi Carles,

Just for a small improvement this time, we talked about a way of calculating FV including the weight of not only the first orders but a few.

Here is the simple formula:
We first calculate the total size of the orders in the book (maybe all the orders, maybe something preset by the user):
VolBidSize = VolumeOrder1 + VolumeOrder2 + VolumeOrder3 ...
VolAskSize = VolumeOrder1 + VolumeOrder2 + VolumeOrder3 ...
TotalVolume = VolBidSize + VolAskSize

Then we do a simple weighted average:
wBB0 = (BestBidPrice * VolBidSize + BestAskPrice* VolAskSize) / TotalVolume

This should give a result always between the 2 BestPrice.

Another solution is to go simply for:
Weighted AskPrice =VolumeOrderAsk1 * PriceOrderAsk1 + VolumeOrderAsk2 * PriceOrderAsk2 + VolumeOrderAsk3 * PriceOrderAsk3 ...

WeightedBidPrice = VolumeOrderBid1 * PriceOrderBid1 + VolumeOrderBid2 * PriceOrderBid2 + VolumeOrderBid3 * PriceOrderBid3 ...

wBBO = WeightedBidPrice + WeightedAskPrice / TotalVolume

But this can get results out of the two best offered prices and I don't know if it's something we want.

Timeout Exception?

14:44:47.831 main Unhandled exception! TypeError: Parameter "url" must be a string, not undefined
at Url.parse (url.js:81:11)
at Object.urlParse [as parse] (url.js:75:5)
at WebSocket.initAsClient (/home/######/K/node_modules/ws/lib/WebSocket.js:530:25)
at new WebSocket (/home/######/K/node_modules/ws/lib/WebSocket.js:70:20)
at Timeout.prototype.connect [as _onTimeout] (/home/######/K/node_modules/gdax/lib/clients/websocket.js:37:19)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)

DEVELOPER WANTED

Hi
was wondering if anyone provides paid services for installing krypto-trading-bot and creating trading bots?

Looking forward hearing from you all.

warm regards
vasilis

socket.io error connect fair-value.js cannot read property of undefined

What would be causing this:
13:14:45.664 main Requiring authentication to web client
13:14:45.707 main Listening to admins on port 3000
13:14:45.717 broker Exchange details { exchange: 'OkCoin',
pair: 'BTC/USD',
minTick: 0.01,
minSize: 0.01,
makeFee: 0.001,
takeFee: 0.002,
hasSelfTradePrevention: false }
13:14:45.731 main Unhandled rejection! TypeError: Cannot read property 'value' of undefined
at new FairValueEngine (/opt/finbots/K/Krypto-trading-bot/app/server/fair-value.js:22:67)
at Object. (/opt/finbots/K/Krypto-trading-bot/app/server/main.js:204:22)
at next (native)
at fulfilled (/opt/finbots/K/Krypto-trading-bot/app/server/main.js:4:58)
at process._tickCallback (internal/process/next_tick.js:109:7)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3 Promise {
TypeError: Cannot read property 'value' of undefined
at new FairValueEngine (/opt/finbots/K/Krypto-trading-bot/app/server/fair-value.js:22:67)
at Object. (/opt/finbots/K/Krypto-trading-bot/app/server/main.js:204:22)
at next (native)
at fulfilled (/opt/finbots/K/Krypto-trading-bot/app/server/main.js:4:58)
at process._tickCallback (internal/process/next_tick.js:109:7)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3 }
13:14:45.762 main Error THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END
13:14:47.462 okcoin Successfully connected to addChannel: ok_sub_spotusd_btc_depth_20
13:14:47.465 okcoin Successfully connected to addChannel: ok_sub_spotusd_btc_trades
13:14:47.467 okcoin Successfully connected to login
13:14:47.762 main Exit code 0
error: Forever detected script exited with code: 0
error: Script restart attempt #1
13:14:48.996 main Requiring authentication to web client
13:14:49.047 main Listening to admins on port 3000
13:14:49.067 broker Exchange details { exchange: 'OkCoin',

Thank you for your answer.

Can't boot: Missing module:

Ubuntu 16.04,

Logs:

module.js:472
    throw err;
    ^

Error: Cannot find module 'bson'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ubuntu/K/node_modules/mongodb-core/index.js:1:74)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ubuntu/K/node_modules/mongodb/index.js:2:12)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

Unable to compute tbp [ qp | pos ] = [ true | false ]

Hi! I'm running on Mac OS and the bot starts fine, the WebGUi is up but it says 'Disconnected" on bidSize, bidPrice, askSize, askPrice.
Also, when I start it node K.js, after a few minutes I get this error : Unable to compute tbp [ qp | pos ] = [ true | false ]

thanks!

DisabledQuotes ? Bitfinex

Hi Carles,

After sometime trading on Bitfinex I get that:

capture d ecran 2017-06-28 a 17 46 31

And it stops trading. Any idea why?

Am I hitting the limit on Bitfinex? (I trade on al markets)

And can K do something about ? Like trying to reconnect :)

Best Camille

Small Improvement / bug correction: TBP on boot seems wrong

Hello Carles,

A very small issue (but that can sometimes have rather big consequences) is that on boot /reboot etc and before K checks mongod to see if ewma are recorded to determine TBP (t+1mn) , it will show medium TBP.

The problem is that if you have permissive trade /seg settings, you can end up selling or buying everything during that 1mn period.

So to fix the issue, would that be possible to check the database if there are EWMA recorded and use them as the starting point on boot instead of waiting 1mn ?

What do you think ?

Best Camille

(BUG) GDAX FIX not working

Hello Carles,

I ran an update this morning and could not boot the GDAX botss.

Here is the log I get:

07:19:50.843 coinbase FIX Initiator Start
07:19:50.858 coinbase FIX Logon Connected
07:19:50.905 active Changed quoting mode to true
07:19:50.911 main Unhandled exception! TypeError: Cannot read property 'mask' of undefined
    at Sender.frameAndSend (/home/ubuntu/K/node_modules/gdax/node_modules/ws/lib/Sender.js:206:17)
    at /home/ubuntu/K/node_modules/gdax/node_modules/ws/lib/Sender.js:126:12
    at /home/ubuntu/K/node_modules/gdax/node_modules/ws/lib/PerMessageDeflate.js:313:5
    at afterWrite (_stream_writable.js:383:3)
    at onwrite (_stream_writable.js:374:7)
    at afterTransform (_stream_transform.js:79:3)
    at TransformState.afterTransform (_stream_transform.js:54:12)
    at Zlib.callback (zlib.js:625:5)
07:19:50.913 main All exiting event handlers have fired, exiting application.
07:19:50.913 main Exiting with code 0

GDAX invalid API key

let me first thank you guys for publishing this bot! However, I spent 2 nights getting it to work but to no avail. I keep getting the error message: "invalid API key" when trying to use the bot with GDAX. I double checked the passphrase, key and secret (with and without ==) but no luck. Also tried 2 different requested API keys for GDAX. Trying to trade ETH/EUR.

Maybe it has to do with Stunnel, however from the readme I gathered that no specific actions has to be taken for launching stunnel. I have installed stunnel on my host (windows 10) pc.

Hopefully someone can help me, thanks in advance!

Full log below:

warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
05:20:51.402 main Requiring authentication to web client
05:20:51.436 main Listening to admins on port 3000
05:20:52.065 broker Exchange details { exchange: 'Coinbase',
pair: 'ETH/EUR',
minTick: 0.01,
minSize: 0.01,
makeFee: 0,
takeFee: 0,
hasSelfTradePrevention: true }
05:20:52.084 coinbase FIX Initiator Start
05:20:52.087 coinbase FIX Logon Disconnected
05:20:52.521 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' }
05:20:52.631 main Unhandled exception! Failed to load orderbook: 404
05:20:52.632 main Attempting to cancel all open orders, please wait..
05:20:52.639 main Unhandled exception! { Error: socket hang up
at createHangUpError (_http_client.js:302:15)
at TLSSocket.socketOnEnd (_http_client.js:394:23)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' }
05:20:52.640 main Attempting to cancel all open orders, please wait..
05:20:52.641 main Attempting to cancel all open orders, please wait..
05:20:52.640 main Unhandled exception! TypeError: Cannot read property 'aborted' of null
at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:191:7)
at TLSSocket.socketCloseListener (_http_client.js:334:9)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:191:7)
at _handle.close (net.js:511:12)
at TCP.done [as _onclose] (_tls_wrap.js:332:7)
05:20:53.074 stdev Unable to compute value
05:20:54.076 stdev Unable to compute value
05:20:54.632 main Exit code 0
error: Forever detected script exited with code: 0
error: Script restart attempt #1
05:20:55.136 main Requiring authentication to web client
05:20:55.155 main Listening to admins on port 3000
05:20:55.755 broker Exchange details { exchange: 'Coinbase',
pair: 'ETH/EUR',
minTick: 0.01,
minSize: 0.01,
makeFee: 0,
takeFee: 0,
hasSelfTradePrevention: true }
05:20:55.776 coinbase FIX Initiator Start
05:20:55.777 coinbase FIX Logon Disconnected
05:20:56.211 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' }
05:20:56.331 main Unhandled exception! Failed to load orderbook: 404
05:20:56.332 main Attempting to cancel all open orders, please wait..
05:20:56.360 main Attempting to cancel all open orders, please wait..
05:20:56.359 main Unhandled exception! { Error: socket hang up
at createHangUpError (_http_client.js:302:15)
at TLSSocket.socketOnEnd (_http_client.js:394:23)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' }
05:20:56.363 main Attempting to cancel all open orders, please wait..
05:20:56.361 main Unhandled exception! TypeError: Cannot read property 'aborted' of null
at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:191:7)
at TLSSocket.socketCloseListener (_http_client.js:334:9)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:191:7)
at _handle.close (net.js:511:12)
at TCP.done [as _onclose] (_tls_wrap.js:332:7)
05:20:56.765 stdev Unable to compute value
05:20:57.766 stdev Unable to compute value
05:20:58.332 main Exit code 0
error: Forever detected script exited with code: 0
error: Script restart attempt #2
05:20:58.831 main Requiring authentication to web client
05:20:58.848 main Listening to admins on port 3000
05:20:59.501 broker Exchange details { exchange: 'Coinbase',
pair: 'ETH/EUR',
minTick: 0.01,
minSize: 0.01,
makeFee: 0,
takeFee: 0,
hasSelfTradePrevention: true }
05:20:59.521 coinbase FIX Initiator Start
05:20:59.522 coinbase FIX Logon Disconnected
05:21:00.112 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' }
05:21:00.180 main Unhandled exception! Failed to load orderbook: 404
05:21:00.181 main Attempting to cancel all open orders, please wait..
05:21:00.182 main Unhandled exception! { Error: socket hang up
at createHangUpError (_http_client.js:302:15)
at TLSSocket.socketOnEnd (_http_client.js:394:23)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' }
05:21:00.184 main Attempting to cancel all open orders, please wait..
05:21:00.186 main Attempting to cancel all open orders, please wait..
05:21:00.185 main Unhandled exception! TypeError: Cannot read property 'aborted' of null
at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:191:7)
at TLSSocket.socketCloseListener (_http_client.js:334:9)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:191:7)
at _handle.close (net.js:511:12)
at TCP.done [as _onclose] (_tls_wrap.js:332:7)
05:21:00.510 stdev Unable to compute value
05:21:01.510 stdev Unable to compute value
05:21:02.182 main Exit code 0
error: Forever detected script exited with code: 0
error: Script restart attempt #3
05:21:02.677 main Requiring authentication to web client
05:21:02.695 main Listening to admins on port 3000
05:21:03.471 broker Exchange details { exchange: 'Coinbase',
pair: 'ETH/EUR',
minTick: 0.01,
minSize: 0.01,
makeFee: 0,
takeFee: 0,
hasSelfTradePrevention: true }
05:21:03.490 coinbase FIX Initiator Start
05:21:03.492 coinbase FIX Logon Disconnected
05:21:04.068 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' }
05:21:04.245 main Unhandled exception! Failed to load orderbook: 404
05:21:04.246 main Attempting to cancel all open orders, please wait..
05:21:04.262 main Attempting to cancel all open orders, please wait..
05:21:04.261 main Unhandled exception! { Error: socket hang up
at createHangUpError (_http_client.js:302:15)
at TLSSocket.socketOnEnd (_http_client.js:394:23)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' }
05:21:04.265 main Attempting to cancel all open orders, please wait..
05:21:04.262 main Unhandled exception! TypeError: Cannot read property 'aborted' of null
at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:191:7)
at TLSSocket.socketCloseListener (_http_client.js:334:9)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:191:7)
at _handle.close (net.js:511:12)
at TCP.done [as _onclose] (_tls_wrap.js:332:7)
05:21:04.480 stdev Unable to compute value
05:21:05.481 stdev Unable to compute value
05:21:06.247 main Exit code 0
error: Forever detected script exited with code: 0
error: Script restart attempt #4

Dockerfile:
RUN apt-get install -y git sudo

Feel free to choose the branch you want to build:

RUN git clone -b master https://github.com/ctubio/Krypto-trading-bot.git K

WORKDIR K

Remove the ssl certificate (GUI accessible over plain HTTP, not recommended):

RUN npm install --unsafe-perm

EXPOSE 3000 5000

General config properties. Replace with your own exchange account information:

ENV BotIdentifier autodev_bot
ENV EXCHANGE coinbase
ENV TradedPair ETH/EUR
ENV WebClientUsername xxxxx
ENV WebClientPassword xxxx
ENV WebClientListenPort 3000
ENV MatryoshkaUrl https://

Set options only for your desired EXCHANGE:

Coinbase GDAX

ENV CoinbaseRestUrl https://api-public.sandbox.gdax.com
ENV CoinbaseWebsocketUrl wss://ws-feed-public.sandbox.gdax.com
ENV CoinbasePassphrase xxxxxx
ENV CoinbaseApiKey xxxxxxx
ENV CoinbaseSecret xxxxxxx
ENV CoinbaseOrderDestination Coinbase

OkCoin

ENV OkCoinWsUrl wss://real.okcoin.com:10440/websocket/okcoinapi
ENV OkCoinHttpUrl https://www.okcoin.com/api/v1/
ENV OkCoinApiKey NULL
ENV OkCoinSecretKey NULL
ENV OkCoinOrderDestination OkCoin

Bitfinex

ENV BitfinexHttpUrl https://api.bitfinex.com/v1
ENV BitfinexWebsocketUrl wss://api.bitfinex.com/ws/2
ENV BitfinexKey NULL
ENV BitfinexSecret NULL
ENV BitfinexOrderDestination Bitfinex

Poloniex

ENV PoloniexHttpUrl https://poloniex.com
ENV PoloniexWebsocketUrl wss://api.poloniex.com
ENV PoloniexApiKey NULL
ENV PoloniexSecretKey NULL
ENV PoloniexOrderDestination Poloniex

Korbit

ENV KorbitHttpUrl https://api.korbit.co.kr/v1
ENV KorbitApiKey NULL
ENV KorbitSecretKey NULL
ENV KorbitUsername NULL
ENV KorbitPassword NULL
ENV KorbitOrderDestination Korbit

HitBtc

ENV HitBtcPullUrl http://demo-api.hitbtc.com
ENV HitBtcOrderEntryUrl ws://demo-api.hitbtc.com:8080
ENV HitBtcMarketDataUrl ws://demo-api.hitbtc.com:80
ENV HitBtcSocketIoUrl https://demo-api.hitbtc.com:8081
ENV HitBtcApiKey NULL
ENV HitBtcSecret NULL
ENV HitBtcOrderDestination HitBtc

Quoting Parameters

ENV delayUI 3

CMD ["node_modules/.bin/forever", "K.js"]

Coinbase : FIX Logon Disconnected

At some point in the last few hours the bot is unable to connect to trade on the coinbase exchange. In the GUI I get the "Connecting to Exchange..."

When I fire it up in the foreground on my server I get

08:34:11.164 coinbase FIX Logon Disconnected

And that repeats every 20 seconds or so. I've changed the API keys, interestingly if I give it an incorrect key it errors on wrong key so the auth is working. Not sure if the issue is only related to me or others are experiencing it.

Just done a npm run latest and no difference.

Disconnected.

Hi,

after editing my conf file, I started the bot but I always get this message on the webpage:

Disconnected.
README - MANUAL - SOURCE - changeTheme(DARK) - - - - 0 - MATRYOSHKA - CREATE ISSUE - IRC

What is the problem? :/

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.