Skip to content

Commit

Permalink
Merge pull request #2 from ctubio/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
serzhiio committed Nov 1, 2017
2 parents f6e6bca + ad2562f commit 57a4ae3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
16 changes: 10 additions & 6 deletions MANUAL.md
Expand Up @@ -67,7 +67,7 @@ Navigate to the Web UI as described in the install process. You should see a scr

In the web UI, there are three rows of panels with cryptic looking names and editable textboxes. Those are the quoting parameters, the knobs which we can turn to affect how K.js will trade.

* `%` - If enabled, the values of `bidSize`, `askSize`, `tbp` and `pDiv` will be a percentage related to the total funds (available + held in both sides); useful when the very same funds are used in multiple markets, so the quantity of the funds is highly variable, then may be useful to work with percentages.
* `%` - If enabled, the values of `bidSize`, `askSize`, `tbp`, `pDiv` and `range` will be a percentage related to the total funds (available + held in both sides); useful when the very same funds are used in multiple markets, so the quantity of the funds is highly variable, then may be useful to work with percentages.

* `mode` - Sets the quoting mode

Expand All @@ -81,15 +81,17 @@ In the web UI, there are three rows of panels with cryptic looking names and edi

* `Inverse Top` - Same as `Inverse Join` but make our orders jump to the very top of the order book.

* `PingPong` - Same as `Top` but always respect the calculated `widthPong` from the last sold or bought `size`, if any.
* `HamelinRat` - Follow the Colossus of the market. Unlike other modes, it does not calculate the quote spread based on fair value, instead it looks for the biggest order in the market levels and places the quote right before it.

* `Boomerang` - Same as `PingPong` but the calculated `widthPong` for new Pongs is based on any best matching previous sold or bought `size`, if any.
* `Depth` - Use `width` as `depth`. Unlike other modes, it does not calculate the quote spread based on fair value, instead it walks over all current open orders in the book and places the quote right after `depth` quantity, at both sides.

* `AK-47` - Same as `Boomerang` but allows multiple orders at the same time in both sides. To avoid old trades, on every new trade K.js will cancel all previous trades if those are worst.
* `safety`- Sets a quoting Safety

* `HamelinRat` - Follow the Colossus of the market. Unlike other modes, it does not calculate the quote spread based on fair value, instead it looks for the biggest order in the market levels and places the quote right before it.
* `PingPong` - Always respect the calculated `widthPong` from the last sold or bought `size`, if any.

* `Depth` - Use `width` as `depth`. Unlike other modes, it does not calculate the quote spread based on fair value, instead it walks over all current open orders in the book and places the quote right after `depth` quantity, at both sides.
* `Boomerang` - Same as `PingPong` but the calculated `widthPong` for new Pongs is based on any best matching previous sold or bought `size`, if any.

* `AK-47` - Same as `Boomerang` but allows multiple orders at the same time in both sides. To avoid old trades, on every new trade K.js will cancel all previous trades if those are worst.

* `bullets` - Maximum amount of trades placed in each side (only affects `AK-47`).

Expand Down Expand Up @@ -169,6 +171,8 @@ In the web UI, there are three rows of panels with cryptic looking names and edi

* `SizeWidth` - Same as `Size` but also will aggressively make use of smaller `width` values (respecting always aggressive `pongAt` option and `widthPong`).

* `aprFactor` - Defines the value with which the `size` is multiplicated when `apr` is in functional state.

* `sop` - Super opportunities, if enabled and if the market width is x3 times bigger than the `width` set, it multiplies (x2 or x3) the `trades` and/or the `size`, in both sides at the same time.

* `trades` - Often, only buying or selling many times in a short timeframe indicates that there is going to be a price swing. `trades` and `/sec` are highly related: If you successfully complete more orders than `trades` in `/sec` seconds, K.js will stop sending more buy orders until either `/sec` seconds has passed, or you have sold enough at a higher cost to make all those buy orders profitable. The number of trades is reported by side in the UI; "BuyTS", "SellTS", and "TotTS". If "BuyTS" goes above `trades`, K.js will stop sending buy orders, and the same for sells. For example, if `trades` is 2 and `/sec` is 1800 (half an hour):
Expand Down
20 changes: 10 additions & 10 deletions Makefile
Expand Up @@ -15,7 +15,7 @@ V_UWS := 0.14.4
V_UV := 1.15.0
V_SQL := 3200100
V_QF := v.1.14.4
KLIB = eccdeb4f954249f122feed7b7eb9b83bc040ae4d
KZIP = 15e004d5b7125494d0d294438237f4f45367b2db
KARGS = -Wextra -std=c++11 -O3 -I$(KLOCAL)/include \
src/server/K.cxx -pthread -rdynamic -DUSE_LIBUV \
-DK_STAMP='"$(shell date --rfc-3339=seconds | cut -f1 -d+)"' \
Expand Down Expand Up @@ -171,7 +171,7 @@ quickfix: build-$(CHOST)
&& cd ../src && CXX=$(CXX) make && make install )

build:
curl -L https://github.com/ctubio/Krypto-trading-bot/releases/download/$(KGIT)/$(KLIB)-$(CHOST).tar.gz \
curl -L https://github.com/ctubio/Krypto-trading-bot/releases/download/$(KGIT)/$(KZIP)-$(CHOST).tar.gz \
| tar xz && chmod +x build-*/local/lib/K-$(CHOST).a build-*/local/bin/K-$(CHOST)

clean:
Expand Down Expand Up @@ -317,23 +317,23 @@ png-check: etc/${PNG}.png
@test -n "`identify -verbose etc/${PNG}.png | grep 'K\.conf'`" && echo Configuration injected into etc/${PNG}.png OK, feel free to remove etc/${PNG}.json anytime. || echo nope, injection failed.

check:
@echo $(KLIB)
@echo $(KZIP)
@shasum $(KLOCAL)/bin/K-$(CHOST) | cut -d ' ' -f1

checkOK:
@sed -i "s/^\(KLIB = \).*$$/\1`shasum $(KLOCAL)/bin/K-$(CHOST) | cut -d ' ' -f1`/" Makefile
@sed -i "s/^\(KZIP = \).*$$/\1`shasum $(KLOCAL)/bin/K-$(CHOST) | cut -d ' ' -f1`/" Makefile
@$(MAKE) check -s

release:
ifdef KALL
unset KALL && echo -n $(CARCH) | xargs -I % -d ' ' $(MAKE) CHOST=% $@
else
@tar -cvzf $(KLIB)-$(CHOST).tar.gz \
LICENSE COPYING THANKS README.md MANUAL.md src etc $(KLOCAL)/bin/K-$(CHOST) $(KLOCAL)/var $(KLOCAL)/lib/K-$(CHOST).a \
Makefile && curl -s -n -H "Content-Type:application/octet-stream" -H "Authorization: token ${KRELEASE}" \
--data-binary "@$(PWD)/$(KLIB)-$(CHOST).tar.gz" \
"https://uploads.github.com/repos/ctubio/Krypto-trading-bot/releases/$(KHUB)/assets?name=$(KLIB)-$(CHOST).tar.gz" \
&& rm $(KLIB)-$(CHOST).tar.gz && echo && echo DONE $(KLIB)-$(CHOST).tar.gz
@tar -cvzf $(KZIP)-$(CHOST).tar.gz \
LICENSE COPYING THANKS README.md MANUAL.md src etc $(KLOCAL)/bin/K-$(CHOST) $(KLOCAL)/var $(KLOCAL)/lib/K-$(CHOST).a \
Makefile && curl -s -n -H "Content-Type:application/octet-stream" -H "Authorization: token ${KRELEASE}" \
--data-binary "@$(PWD)/$(KZIP)-$(CHOST).tar.gz" \
"https://uploads.github.com/repos/ctubio/Krypto-trading-bot/releases/$(KHUB)/assets?name=$(KZIP)-$(CHOST).tar.gz" \
&& rm $(KZIP)-$(CHOST).tar.gz && echo && echo DONE $(KZIP)-$(CHOST).tar.gz
endif

md5: src
Expand Down
6 changes: 2 additions & 4 deletions README.md
Expand Up @@ -15,10 +15,8 @@
[![Last Commit](https://img.shields.io/github/last-commit/ctubio/Krypto-trading-bot.svg?maxAge=2592000)](https://github.com/ctubio/Krypto-trading-bot)
[![Dependency Status](https://img.shields.io/david/ctubio/Krypto-trading-bot.svg)](https://david-dm.org/ctubio/Krypto-trading-bot)
[![Open Issues](https://img.shields.io/github/issues/ctubio/Krypto-trading-bot.svg)](https://github.com/ctubio/Krypto-trading-bot/issues)
[![Open Issues](https://img.shields.io/github/issues/ctubio/tribeca.svg)](https://github.com/ctubio/tribeca/issues)<!--[![Total Downloads](https://img.shields.io/npm/dt/hacktimer.svg)](https://github.com/ctubio/Krypto-trading-bot)
[![Week Downloads](https://img.shields.io/npm/dw/hacktimer.svg)](https://github.com/ctubio/Krypto-trading-bot)
[![Month Downloads](https://img.shields.io/npm/dm/hacktimer.svg)](https://github.com/ctubio/Krypto-trading-bot)
[![Day Downloads](https://img.shields.io/npm/dy/hacktimer.svg)](https://github.com/ctubio/Krypto-trading-bot)-->
[![Open Issues](https://img.shields.io/github/issues/ctubio/tribeca.svg)](https://github.com/ctubio/tribeca/issues)
[![Downloads Last 21 Commits](https://img.shields.io/github/downloads/ctubio/Krypto-trading-bot/latest/total.svg?maxAge=2592000&label=downloads%20last%2021%20commits)](https://github.com/ctubio/Krypto-trading-bot)

Runs on unix-like systems. Persistence is achieved using a built-in server-less SQLite C++ interface. Installation via Docker is supported, but manual installation in a dedicated [Debian](https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/) (or [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)) or [CentOS](https://wiki.centos.org/Download) instance is recommended.

Expand Down
6 changes: 3 additions & 3 deletions etc/K.sh.dist
Expand Up @@ -2,9 +2,9 @@
# █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
# ▓ ████ ███ Usage? use current filename of THIS file: █
# ▒ ████ ███ $ ./K.sh --help █
# ▓███▀█▄ Feel free to copy/rename/edit THIS file.
# ▒ ▒▓██ ███ Feel free to uncomment examples, but
# ▓ ░▒▓█ ███ do not define multiple times a variable.
# ▓███▀█▄ !Feel free to copy/rename/edit THIS file. █
# ▒ ▒▓██ ███ !Feel free to uncomment any examples, but █
# ▓ ░▒▓█ ███ do not define multiple times a variable. █
# █ configurable! executable! K.sh initialization file █
# █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▄▄██▄▌ ▌▐ ▐▄██▄▄▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
# █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄▀▀▀▀▀▌▄ ▄▐▀▀▀▀▀▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
Expand Down
2 changes: 1 addition & 1 deletion src/server/mg.h
Expand Up @@ -208,7 +208,7 @@ namespace K {
calcEwma(&mgEwmaSM, qp.quotingEwmaSMPeriods);
calcEwma(&mgEwmaSU, qp.quotingEwmaSUPeriods);
if(mgEwmaSM && mgEwmaSU)
mgEwmaSMUDiff = ( ( mgEwmaSU * 100 ) / mgEwmaSM ) - 100;
mgEwmaSMUDiff = ((mgEwmaSU * 100) / mgEwmaSM) - 100;
ev_mgEwmaSMUProtection();
};
static void filter(mLevels k) {
Expand Down
16 changes: 8 additions & 8 deletions src/server/qe.h
Expand Up @@ -287,7 +287,7 @@ namespace K {
} else rawQuote->isBidPong = false;
};
static void applyWaitingPing(mQuote *rawQuote, double buySize, double sellSize, double totalQuotePosition, double totalBasePosition, double safetyBuyPing, double safetySellPong) {
if ((qp.safety == mQuotingSafety::Boomerang or qp.safety == mQuotingSafety::PingPong or QP::matchPings())
if ((qp.safety == mQuotingSafety::PingPong or QP::matchPings())
and !safetyBuyPing and (qp.pingAt == mPingAt::StopPings or qp.pingAt == mPingAt::BidSide or qp.pingAt == mPingAt::DepletedAskSide
or (totalQuotePosition>buySize and (qp.pingAt == mPingAt::DepletedSide or qp.pingAt == mPingAt::DepletedBidSide))
)) {
Expand All @@ -297,7 +297,7 @@ namespace K {
rawQuote->ask.price = 0;
rawQuote->ask.size = 0;
}
if ((qp.safety == mQuotingSafety::Boomerang or qp.safety == mQuotingSafety::PingPong or QP::matchPings())
if ((qp.safety == mQuotingSafety::PingPong or QP::matchPings())
and !safetySellPong and (qp.pingAt == mPingAt::StopPings or qp.pingAt == mPingAt::AskSide or qp.pingAt == mPingAt::DepletedBidSide
or (totalBasePosition>sellSize and (qp.pingAt == mPingAt::DepletedSide or qp.pingAt == mPingAt::DepletedAskSide))
)) {
Expand Down Expand Up @@ -472,17 +472,17 @@ namespace K {
static mQuote calcJoinMarket(double widthPing, double buySize, double sellSize) {
mQuote k = quoteAtTopOfMarket();
k.bid.price = fmin(mgFairValue - widthPing / 2.0, k.bid.price);
k.ask.price = fmin(mgFairValue + widthPing / 2.0, k.ask.price);
k.ask.price = fmax(mgFairValue + widthPing / 2.0, k.ask.price);
k.bid.size = buySize;
k.ask.size = sellSize;
return k;
};
static mQuote calcTopOfMarket(double widthPing, double buySize, double sellSize) {
mQuote k = quoteAtTopOfMarket();
if (k.bid.size > 0.2) k.bid.price = k.bid.price + gw->minTick;
if (k.ask.size > 0.2) k.ask.price = k.ask.price - gw->minTick;
k.bid.price = k.bid.price + gw->minTick;
k.ask.price = k.ask.price - gw->minTick;
k.bid.price = fmin(mgFairValue - widthPing / 2.0, k.bid.price);
k.ask.price = fmin(mgFairValue + widthPing / 2.0, k.ask.price);
k.ask.price = fmax(mgFairValue + widthPing / 2.0, k.ask.price);
k.bid.size = buySize;
k.ask.size = sellSize;
return k;
Expand All @@ -509,8 +509,8 @@ namespace K {
k.ask.price = k.ask.price + widthPing;
k.bid.price = k.bid.price - widthPing;
}
if (k.bid.size > .2) k.bid.price = k.bid.price + gw->minTick;
if (k.ask.size > .2) k.ask.price = k.ask.price - gw->minTick;
k.bid.price = k.bid.price + gw->minTick;
k.ask.price = k.ask.price - gw->minTick;
if (mktWidth < (2.0 * widthPing / 3.0)) {
k.ask.price = k.ask.price + widthPing / 4.0;
k.bid.price = k.bid.price - widthPing / 4.0;
Expand Down
1 change: 1 addition & 0 deletions src/server/qp.h
Expand Up @@ -167,6 +167,7 @@ namespace K {
if (j.end() != j.find("delayUI")) k.delayUI = j.at("delayUI").get<int>();
if ((int)k.mode > 6) k.mode = (mQuotingMode)0; // remove after everybody have the new mode/safety in their databases (2018)
if (k.mode == mQuotingMode::Depth) k.widthPercentage = false;
if (k.mode == mQuotingMode::HamelinRat) k.safety = mQuotingSafety::Off;
};
class QP: public Klass {
protected:
Expand Down

0 comments on commit 57a4ae3

Please sign in to comment.