From 7ee2b6fef39d9a931b13241c2b6affbc7e2645fb Mon Sep 17 00:00:00 2001 From: davidlondono Date: Thu, 31 Aug 2017 15:58:40 -0500 Subject: [PATCH 01/19] Added Discord link for bots community I created this community so every one can share their knowledge :D --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32de1d6c3..bd62bfbbe 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ ![Gordon Gekko](http://mikevanrossum.nl/static/gekko.jpg) +### Discord community for crypto bots + +
+ + *The most valuable commodity I know of is information.* -Gordon Gekko @@ -20,4 +25,4 @@ See [the installing Gekko doc](https://gekko.wizb.it/docs/installation/installin ## Final -If Gekko helped you in any way, you can always leave me a tip at (BTC) 13r1jyivitShUiv9FJvjLH7Nh1ZZptumwW \ No newline at end of file +If Gekko helped you in any way, you can always leave me a tip at (BTC) 13r1jyivitShUiv9FJvjLH7Nh1ZZptumwW From 020227b038daf3331650d1d38ea798b4975e133b Mon Sep 17 00:00:00 2001 From: Rob Ellis Date: Sat, 2 Sep 2017 13:28:17 -0700 Subject: [PATCH 02/19] update url in CONTRIBUTING to front-end --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e5b82ec7..d394b3fc5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,7 +40,7 @@ If you cannot find an existing issue that describes your bug or feature, submit - If you want to Gekko react to anything from the market, you can most likely put this functionality into a plugin. See [this document](https://github.com/askmike/gekko/blob/develop/docs/internals/plugins.md) for details. - If you want to add trading strategies / indicators, please see [this document](https://github.com/askmike/gekko/blob/develop/docs/trading_bot/creating_a_trading_method.md). - If you just want to work on Gekko, you can use the open issues with the tag `open-for-pulls` for inspiration. -- If you want to work on the web interface (Gekko UI), please see [this frontend doc](https://github.com/askmike/gekko/blob/develop/docs/gekko_ui/frontend.md) on the Vue.js frontend. +- If you want to work on the web interface (Gekko UI), please see [this frontend doc](https://github.com/askmike/gekko/blob/develop/docs/internals/gekko_ui.md) on the Vue.js frontend. Things to take into consideration when submitting a pull request: From d52f78636e03ad35b1667b2d2f3ddf0be77f2ad6 Mon Sep 17 00:00:00 2001 From: Rob Ellis Date: Sat, 2 Sep 2017 14:46:37 -0700 Subject: [PATCH 03/19] Add empty state to backfull no data. This felt clunky on first run --- .../global/configbuilder/datasetpicker.vue | 76 ++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/web/vue/src/components/global/configbuilder/datasetpicker.vue b/web/vue/src/components/global/configbuilder/datasetpicker.vue index 529531f8b..e240ab584 100644 --- a/web/vue/src/components/global/configbuilder/datasetpicker.vue +++ b/web/vue/src/components/global/configbuilder/datasetpicker.vue @@ -6,41 +6,47 @@ div .txt--center.my2(v-if='datasetScanstate === "scanning"') spinner .my2(v-if='datasetScanstate === "scanned"') - table.full - thead - tr - th - th exchange - th currency - th asset - th from - th to - th duration - tbody - tr(v-for='(set, i) in datasets') - td.radio - input(type='radio', name='dataset', :value='i', v-model='setIndex', v-bind:id='set.id') - td - label(v-bind:for='set.id') {{ set.exchange }} - td - label(v-bind:for='set.id') {{ set.currency }} - td - label(v-bind:for='set.id') {{ set.asset }} - td - label(v-bind:for='set.id') {{ fmt(set.from) }} - td - label(v-bind:for='set.id') {{ fmt(set.to) }} - td - label(v-bind:for='set.id') {{ humanizeDuration(set.to.diff(set.from)) }} - em - a(href='#', v-on:click.prevent='openRange', v-if='!rangeVisible') Adjust range - template(v-if='rangeVisible') - div - label(for='customFrom') From: - input(v-model='customFrom') - div - label(for='customTo') To: - input(v-model='customTo') + + div(v-if='datasets.length != 0') + table.full + thead + tr + th + th exchange + th currency + th asset + th from + th to + th duration + tbody + tr(v-for='(set, i) in datasets') + td.radio + input(type='radio', name='dataset', :value='i', v-model='setIndex', v-bind:id='set.id') + td + label(v-bind:for='set.id') {{ set.exchange }} + td + label(v-bind:for='set.id') {{ set.currency }} + td + label(v-bind:for='set.id') {{ set.asset }} + td + label(v-bind:for='set.id') {{ fmt(set.from) }} + td + label(v-bind:for='set.id') {{ fmt(set.to) }} + td + label(v-bind:for='set.id') {{ humanizeDuration(set.to.diff(set.from)) }} + + em + a(href='#', v-on:click.prevent='openRange', v-if='!rangeVisible') Adjust range + template(v-if='rangeVisible') + div + label(for='customFrom') From: + input(v-model='customFrom') + div + label(for='customTo') To: + input(v-model='customTo') + + em(v-else) No Data found + a(href='#/data/importer') Lets add some From 4a2e81d2f478737f4a79375743128adf057fb7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jules=20goull=C3=A9e?= Date: Tue, 5 Sep 2017 15:43:44 +0200 Subject: [PATCH 04/19] kraken reduce precision --- exchanges/kraken.js | 143 +++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 68 deletions(-) diff --git a/exchanges/kraken.js b/exchanges/kraken.js index c7c12f77d..df7313544 100644 --- a/exchanges/kraken.js +++ b/exchanges/kraken.js @@ -203,20 +203,27 @@ Trader.prototype.getTicker = function(callback) { this.kraken.api('Ticker', {pair: this.pair}, _.bind(set, this)); }; - -var roundAmount = function(amount) { +Trader.prototype.roundAmount = function(amount) { // Prevent "You incorrectly entered one of fields." // because of more than 8 decimals. - amount *= 100000000; + // Specific precision by pair https://blog.kraken.com/post/1278/announcement-reducing-price-precision-round-2 + + var precision = 100000000; + var market = this.getCapabilities().markets.find(function(market){ return market.pair[0] === this.currency && market.pair[1] === this.asset }); + + if(Number.isInteger(market.precision)) + precision = 10 * market.precision; + + amount *= precision; amount = Math.floor(amount); - amount /= 100000000; + amount /= precision; return amount; }; Trader.prototype.addOrder = function(tradeType, amount, price, callback) { var args = _.toArray(arguments); - amount = roundAmount(amount); + amount = this.roundAmount(amount); log.debug(tradeType.toUpperCase(), amount, this.asset, '@', price, this.currency); var set = function(err, data) { @@ -325,66 +332,66 @@ Trader.getCapabilities = function () { assets: ['XBT', 'LTC', 'GNO', 'ICN', 'MLN', 'REP', 'XDG', 'XLM', 'XMR', 'XRP', 'ZEC', 'ETH', 'BCH', 'DASH', 'EOS', 'ETC'], markets: [ //Tradeable againt ETH - { pair: ['XBT', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['CAD', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XBT', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['CAD', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['EUR', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, { pair: ['GBP', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['JPY', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['USD', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EOS', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETC', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['GNO', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ICN', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['MLN', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['REP', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['JPY', 'ETH'], minimalOrder: { amount: 1, unit: 'asset' }, precision: 0 }, + { pair: ['USD', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['EOS', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['ETC', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['GNO', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 4 }, + { pair: ['ICN', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['MLN', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['REP', 'ETH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, //Tradeable against LTC - { pair: ['XBT', 'LTC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'LTC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['USD', 'LTC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XBT', 'LTC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['EUR', 'LTC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['USD', 'LTC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, //Tradeable against BCH - { pair: ['USD', 'BCH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'BCH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'BCH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['USD', 'BCH'], minimalOrder: { amount: 0.1, unit: 'asset' }, precision: 1 }, + { pair: ['EUR', 'BCH'], minimalOrder: { amount: 0.1, unit: 'asset' }, precision: 1 }, + { pair: ['XBT', 'BCH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, //Tradeable against DASH - { pair: ['USD', 'DASH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'DASH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'DASH'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['USD', 'DASH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['EUR', 'DASH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['XBT', 'DASH'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, //Tradeable against EOS { pair: ['USD', 'EOS'], minimalOrder: { amount: 0.01, unit: 'asset' } }, { pair: ['EUR', 'EOS'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'EOS'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETH', 'EOS'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XBT', 'EOS'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 7 }, + { pair: ['ETH', 'EOS'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, //Tradeable against ETC - { pair: ['USD', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETH', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['USD', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 3 }, + { pair: ['EUR', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 3 }, + { pair: ['XBT', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['ETH', 'ETC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, //Tradeable against GNO { pair: ['USD', 'GNO'], minimalOrder: { amount: 0.01, unit: 'asset' } }, { pair: ['EUR', 'GNO'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'GNO'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETH', 'GNO'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XBT', 'GNO'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['ETH', 'GNO'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 4 }, //Tradeable against ICN - { pair: ['XBT', 'ICN'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETH', 'ICN'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XBT', 'ICN'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 7 }, + { pair: ['ETH', 'ICN'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, //Tradeable against MLN - { pair: ['XBT', 'MLN'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETH', 'MLN'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XBT', 'MLN'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['ETH', 'MLN'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, //Tradeable against REP { pair: ['USD', 'REP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'REP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'REP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETH', 'REP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['EUR', 'REP'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 3 }, + { pair: ['XBT', 'REP'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['ETH', 'REP'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, //Tradeable against XDG @@ -393,50 +400,50 @@ Trader.getCapabilities = function () { //Tradeable against XLM { pair: ['USD', 'XLM'], minimalOrder: { amount: 0.01, unit: 'asset' } }, { pair: ['EUR', 'XLM'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'XLM'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XBT', 'XLM'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 8 }, //Tradeable against XMR - { pair: ['USD', 'XMR'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'XMR'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'XMR'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['USD', 'XMR'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['EUR', 'XMR'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['XBT', 'XMR'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, //Tradeable against XRP - { pair: ['USD', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['USD', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['EUR', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['XBT', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 8 }, { pair: ['CAD', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, { pair: ['JPY', 'XRP'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - //Tradeable against XMR - { pair: ['USD', 'ZEC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'ZEC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XBT', 'ZEC'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + //Tradeable against ZEC + { pair: ['USD', 'ZEC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['EUR', 'ZEC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 2 }, + { pair: ['XBT', 'ZEC'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, //Tradeable against XBT - { pair: ['BCH', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['LTC', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['BCH', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['LTC', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, { pair: ['XDG', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, { pair: ['XLM', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, { pair: ['XRP', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['CAD', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EUR', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['CAD', 'XBT'], minimalOrder: { amount: 0.1, unit: 'asset' }, precision: 1 }, + { pair: ['EUR', 'XBT'], minimalOrder: { amount: 0.1, unit: 'asset' }, precision: 1 }, { pair: ['GBP', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['JPY', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['USD', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['DASH', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['EOS', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETC', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ETH', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['GNO', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ICN', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['MLN', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['JPY', 'XBT'], minimalOrder: { amount: 1, unit: 'asset' }, precision: 0 }, + { pair: ['USD', 'XBT'], minimalOrder: { amount: 0.1, unit: 'asset' }, precision: 1 }, + { pair: ['DASH', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['EOS', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 7 }, + { pair: ['ETC', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['ETH', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['GNO', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, + { pair: ['ICN', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 7 }, + { pair: ['MLN', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, { pair: ['REP', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, { pair: ['XDG', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XLM', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XMR', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['XRP', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, - { pair: ['ZEC', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' } }, + { pair: ['XLM', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 8 }, + { pair: ['XMR', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 6 }, + { pair: ['XRP', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 8 }, + { pair: ['ZEC', 'XBT'], minimalOrder: { amount: 0.01, unit: 'asset' }, precision: 5 }, ], requires: ['key', 'secret'], From 7d6f47e684b1e15964ac4a0c769cfa86908ca0ad Mon Sep 17 00:00:00 2001 From: Howard Wallis Date: Thu, 7 Sep 2017 16:32:14 +0100 Subject: [PATCH 05/19] Fix typo where -> were --- web/vue/src/components/data/data.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/vue/src/components/data/data.vue b/web/vue/src/components/data/data.vue index 0de48e6c3..45acdde5b 100644 --- a/web/vue/src/components/data/data.vue +++ b/web/vue/src/components/data/data.vue @@ -9,7 +9,7 @@ spinner .my2(v-if='datasetScanstate === "scanned"') .bg--orange.p1.warning.my1(v-if='unscannableMakets.length') - p.clickable(v-if='!viewUnscannable', v-on:click.prevent='toggleUnscannable') Some markets where unscannable, click here for details. + p.clickable(v-if='!viewUnscannable', v-on:click.prevent='toggleUnscannable') Some markets were unscannable, click here for details. template(v-if='viewUnscannable') p Unable to find datasets in the following markets: .mx2(v-for='market in unscannableMakets') From 56f909cf1d9c9ab68e656d0357da903207a3594c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81re=CC=81mie=20Blaser?= Date: Thu, 7 Sep 2017 21:04:17 +0200 Subject: [PATCH 06/19] color coded profit & loss in roundtrip table --- .../backtester/result/roundtripTable.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/web/vue/src/components/backtester/result/roundtripTable.vue b/web/vue/src/components/backtester/result/roundtripTable.vue index d4ab0e11c..699711c36 100644 --- a/web/vue/src/components/backtester/result/roundtripTable.vue +++ b/web/vue/src/components/backtester/result/roundtripTable.vue @@ -17,8 +17,12 @@ td {{ diff(rt.duration) }} td {{ round(rt.entryBalance) }} td {{ round(rt.exitBalance) }} - td {{ round(rt.pnl) }} - td {{ round(rt.profit) }} + template(v-if="Math.sign(rt.pnl)===-1") + td.loss {{ Math.sign(rt.pnl)*rt.pnl.toFixed(2) }} + td.loss {{ rt.profit.toFixed(2) }}% + template(v-else) + td.profit {{ rt.pnl.toFixed(2) }} + td.profit {{ rt.profit.toFixed(2) }}% div(v-if='!roundtrips.length') p Not enough data to display @@ -55,6 +59,15 @@ export default { padding: 8px 12px; } +.roundtrips table td.loss { + color: red; + text-align: right; +} +.roundtrips table td.profit { + color: green; + text-align: right; +} + .roundtrips table tr:nth-child(2n) { background-color: #f6f8fa; } From e92806233a16f43790c1fe523186ccaf3a087eb9 Mon Sep 17 00:00:00 2001 From: Sebastien Bramille Date: Tue, 5 Sep 2017 16:50:09 +0100 Subject: [PATCH 07/19] Inject config into the strategy --- plugins/tradingAdvisor/baseTradingMethod.js | 5 +++-- plugins/tradingAdvisor/tradingAdvisor.js | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/tradingAdvisor/baseTradingMethod.js b/plugins/tradingAdvisor/baseTradingMethod.js index 752449402..6c2c9156a 100644 --- a/plugins/tradingAdvisor/baseTradingMethod.js +++ b/plugins/tradingAdvisor/baseTradingMethod.js @@ -75,14 +75,15 @@ var Indicators = { var allowedIndicators = _.keys(Indicators); var allowedTalibIndicators = _.keys(talib); -var Base = function() { +var Base = function(settings) { _.bindAll(this); // properties this.age = 0; this.processedTicks = 0; this.setup = false; - + this.settings = settings; + this.tradingAdvisor = config.tradingAdvisor; // defaults this.requiredHistory = 0; this.priceValue = 'close'; diff --git a/plugins/tradingAdvisor/tradingAdvisor.js b/plugins/tradingAdvisor/tradingAdvisor.js index b263a0f08..a57144b68 100644 --- a/plugins/tradingAdvisor/tradingAdvisor.js +++ b/plugins/tradingAdvisor/tradingAdvisor.js @@ -55,12 +55,16 @@ Actor.prototype.setupTradingMethod = function() { Consultant.prototype[name] = fn; }); - this.method = new Consultant; + if(config[this.methodName]) { + var tradingSettings = config[this.methodName]; + } + + this.method = new Consultant(tradingSettings); this.method .on('advice', this.relayAdvice); this.batcher - .on('candle', this.processCustomCandle) + .on('candle', this.processCustomCandle); } // HANDLERS From cdb38c5970daca627624c312c6fa6dd77e058563 Mon Sep 17 00:00:00 2001 From: Sebastien Bramille Date: Tue, 5 Sep 2017 16:51:30 +0100 Subject: [PATCH 08/19] Update strategies --- strategies/CCI.js | 19 +++++++------------ strategies/DEMA.js | 12 ++++-------- strategies/MACD.js | 22 +++++++++------------- strategies/PPO.js | 28 ++++++++++++---------------- strategies/RSI.js | 21 +++++++++------------ strategies/StochRSI.js | 21 +++++++++------------ strategies/TSI.js | 19 ++++++++----------- strategies/UO.js | 19 ++++++++----------- strategies/talib-macd.js | 15 ++++++--------- strategies/varPPO.js | 10 +++++----- 10 files changed, 77 insertions(+), 109 deletions(-) diff --git a/strategies/CCI.js b/strategies/CCI.js index 2a3cae6b2..c9e831328 100644 --- a/strategies/CCI.js +++ b/strategies/CCI.js @@ -2,11 +2,6 @@ var _ = require('lodash'); var log = require('../core/log.js'); -// configuration -var config = require('../core/util.js').getConfig(); -var settings = config.CCI; -var pposettings = config.PPO; - // let's create our own method var method = {}; @@ -22,15 +17,15 @@ method.init = function() { persisted: false, adviced: false }; - this.historySize = config.tradingAdvisor.historySize; + this.historySize = this.tradingAdvisor.historySize; this.ppoadv = 'none'; - this.uplevel = settings.thresholds.up; - this.downlevel = settings.thresholds.down; - this.persisted = settings.thresholds.persistence; + this.uplevel = this.settings.thresholds.up; + this.downlevel = this.settings.thresholds.down; + this.persisted = this.settings.thresholds.persistence; // log.debug("CCI started with:\nup:\t", this.uplevel, "\ndown:\t", this.downlevel, "\npersistence:\t", this.persisted); // define the indicators we need - this.addIndicator('cci', 'CCI', settings); + this.addIndicator('cci', 'CCI', this.settings); } // what happens on every new candle? @@ -59,7 +54,7 @@ method.log = function() { } /* - * + * */ method.check = function(candle) { @@ -120,7 +115,7 @@ method.check = function(candle) { } this.advice(); } - + } else { this.advice(); } diff --git a/strategies/DEMA.js b/strategies/DEMA.js index 3ab89e479..95362af66 100644 --- a/strategies/DEMA.js +++ b/strategies/DEMA.js @@ -2,10 +2,6 @@ var _ = require('lodash'); var log = require('../core/log.js'); -// configuration -var config = require('../core/util.js').getConfig(); -var settings = config.DEMA; - // let's create our own method var method = {}; @@ -14,10 +10,10 @@ method.init = function() { this.name = 'DEMA'; this.currentTrend; - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need - this.addIndicator('dema', 'DEMA', settings); + this.addIndicator('dema', 'DEMA', this.settings); } // what happens on every new candle? @@ -44,7 +40,7 @@ method.check = function(candle) { var message = '@ ' + price.toFixed(8) + ' (' + diff.toFixed(5) + ')'; - if(diff > settings.thresholds.up) { + if(diff > this.settings.thresholds.up) { log.debug('we are currently in uptrend', message); if(this.currentTrend !== 'up') { @@ -53,7 +49,7 @@ method.check = function(candle) { } else this.advice(); - } else if(diff < settings.thresholds.down) { + } else if(diff < this.settings.thresholds.down) { log.debug('we are currently in a downtrend', message); if(this.currentTrend !== 'down') { diff --git a/strategies/MACD.js b/strategies/MACD.js index 463caffd1..c41a3c34b 100644 --- a/strategies/MACD.js +++ b/strategies/MACD.js @@ -1,5 +1,5 @@ /* - + MACD - DJM 31/12/2013 (updated a couple of times since, check git history) @@ -10,10 +10,6 @@ var _ = require('lodash'); var log = require('../core/log.js'); -// configuration -var config = require('../core/util.js').getConfig(); -var settings = config.MACD; - // let's create our own method var method = {}; @@ -33,10 +29,10 @@ method.init = function() { // how many candles do we need as a base // before we can start giving advice? - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need - this.addIndicator('macd', 'MACD', settings); + this.addIndicator('macd', 'MACD', this.settings); } // what happens on every new candle? @@ -64,7 +60,7 @@ method.log = function() { method.check = function() { var macddiff = this.indicators.macd.result; - if(macddiff > settings.thresholds.up) { + if(macddiff > this.settings.thresholds.up) { // new trend detected if(this.trend.direction !== 'up') @@ -80,7 +76,7 @@ method.check = function() { log.debug('In uptrend since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -89,7 +85,7 @@ method.check = function() { } else this.advice(); - } else if(macddiff < settings.thresholds.down) { + } else if(macddiff < this.settings.thresholds.down) { // new trend detected if(this.trend.direction !== 'down') @@ -105,7 +101,7 @@ method.check = function() { log.debug('In downtrend since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -120,9 +116,9 @@ method.check = function() { // we're not in an up nor in a downtrend // but for now we ignore sideways trends - // + // // read more @link: - // + // // https://github.com/askmike/gekko/issues/171 // this.trend = { diff --git a/strategies/PPO.js b/strategies/PPO.js index df5c76368..6d77176cf 100644 --- a/strategies/PPO.js +++ b/strategies/PPO.js @@ -1,5 +1,5 @@ /* - + PPO - cykedev 15/01/2014 (updated a couple of times since, check git history) @@ -10,10 +10,6 @@ var _ = require('lodash'); var log = require('../core/log'); -// configuration -var config = require('../core/util').getConfig(); -var settings = config.PPO; - // let's create our own method var method = {}; @@ -26,10 +22,10 @@ method.init = function() { adviced: false }; - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need - this.addIndicator('ppo', 'PPO', settings); + this.addIndicator('ppo', 'PPO', this.settings); } // what happens on every new candle? @@ -37,7 +33,7 @@ method.update = function(candle) { // nothing! } -// for debugging purposes log the last +// for debugging purposes log the last // calculated parameters. method.log = function() { var digits = 8; @@ -57,7 +53,7 @@ method.log = function() { log.debug('\t', 'machist:', (macd - macdSignal).toFixed(digits)); log.debug('\t', 'ppo:', result.toFixed(digits)); log.debug('\t', 'pposignal:', ppoSignal.toFixed(digits)); - log.debug('\t', 'ppohist:', (result - ppoSignal).toFixed(digits)); + log.debug('\t', 'ppohist:', (result - ppoSignal).toFixed(digits)); } method.check = function(candle) { @@ -75,7 +71,7 @@ method.check = function(candle) { // if it is it should move there var ppoHist = result - ppoSignal; - if(ppoHist > settings.thresholds.up) { + if(ppoHist > this.settings.thresholds.up) { // new trend detected if(this.trend.direction !== 'up') @@ -90,7 +86,7 @@ method.check = function(candle) { log.debug('In uptrend since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -98,8 +94,8 @@ method.check = function(candle) { this.advice('long'); } else this.advice(); - - } else if(ppoHist < settings.thresholds.down) { + + } else if(ppoHist < this.settings.thresholds.down) { // new trend detected if(this.trend.direction !== 'down') @@ -114,7 +110,7 @@ method.check = function(candle) { log.debug('In downtrend since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -130,9 +126,9 @@ method.check = function(candle) { // we're not in an up nor in a downtrend // but for now we ignore sideways trends - // + // // read more @link: - // + // // https://github.com/askmike/gekko/issues/171 // this.trend = { diff --git a/strategies/RSI.js b/strategies/RSI.js index 6b2f9bbef..6e30bffd0 100644 --- a/strategies/RSI.js +++ b/strategies/RSI.js @@ -1,5 +1,5 @@ /* - + RSI - cykedev 14/02/2014 (updated a couple of times since, check git history) @@ -9,9 +9,6 @@ var _ = require('lodash'); var log = require('../core/log.js'); -var config = require('../core/util.js').getConfig(); -var settings = config.RSI; - var RSI = require('./indicators/RSI.js'); // let's create our own method @@ -28,13 +25,13 @@ method.init = function() { adviced: false }; - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need - this.addIndicator('rsi', 'RSI', settings); + this.addIndicator('rsi', 'RSI', this.settings); } -// for debugging purposes log the last +// for debugging purposes log the last // calculated parameters. method.log = function(candle) { var digits = 8; @@ -49,7 +46,7 @@ method.check = function() { var rsi = this.indicators.rsi; var rsiVal = rsi.rsi; - if(rsiVal > settings.thresholds.high) { + if(rsiVal > this.settings.thresholds.high) { // new trend detected if(this.trend.direction !== 'high') @@ -64,7 +61,7 @@ method.check = function() { log.debug('In high since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -72,8 +69,8 @@ method.check = function() { this.advice('short'); } else this.advice(); - - } else if(rsiVal < settings.thresholds.low) { + + } else if(rsiVal < this.settings.thresholds.low) { // new trend detected if(this.trend.direction !== 'low') @@ -88,7 +85,7 @@ method.check = function() { log.debug('In low since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { diff --git a/strategies/StochRSI.js b/strategies/StochRSI.js index 66a2b0d1c..bcafc2847 100644 --- a/strategies/StochRSI.js +++ b/strategies/StochRSI.js @@ -1,5 +1,5 @@ /* - + StochRSI - SamThomp 11/06/2014 (updated by askmike) @ 30/07/2016 @@ -9,9 +9,6 @@ var _ = require('lodash'); var log = require('../core/log.js'); -var config = require('../core/util.js').getConfig(); -var settings = config.StochRSI; - var RSI = require('./indicators/RSI.js'); // let's create our own method @@ -19,7 +16,7 @@ var method = {}; // prepare everything our method needs method.init = function() { - this.interval = settings.interval; + this.interval = this.settings.interval; this.trend = { direction: 'none', @@ -51,7 +48,7 @@ method.update = function(candle) { this.stochRSI = ((this.rsi - this.lowestRSI) / (this.highestRSI - this.lowestRSI)) * 100; } -// for debugging purposes log the last +// for debugging purposes log the last // calculated parameters. method.log = function() { var digits = 8; @@ -64,7 +61,7 @@ method.log = function() { } method.check = function() { - if(this.stochRSI > settings.thresholds.high) { + if(this.stochRSI > this.settings.thresholds.high) { // new trend detected if(this.trend.direction !== 'high') this.trend = { @@ -78,7 +75,7 @@ method.check = function() { log.debug('In high since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -86,8 +83,8 @@ method.check = function() { this.advice('short'); } else this.advice(); - - } else if(this.stochRSI < settings.thresholds.low) { + + } else if(this.stochRSI < this.settings.thresholds.low) { // new trend detected if(this.trend.direction !== 'low') @@ -102,7 +99,7 @@ method.check = function() { log.debug('In low since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -121,4 +118,4 @@ method.check = function() { } -module.exports = method; \ No newline at end of file +module.exports = method; diff --git a/strategies/TSI.js b/strategies/TSI.js index f8ee64f3e..6089bb0cc 100644 --- a/strategies/TSI.js +++ b/strategies/TSI.js @@ -2,9 +2,6 @@ var _ = require('lodash'); var log = require('../core/log.js'); -var config = require('../core/util.js').getConfig(); -var settings = config.TSI; - var TSI = require('./indicators/TSI.js'); // let's create our own method @@ -21,13 +18,13 @@ method.init = function() { adviced: false }; - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need - this.addIndicator('tsi', 'TSI', settings); + this.addIndicator('tsi', 'TSI', this.settings); } -// for debugging purposes log the last +// for debugging purposes log the last // calculated parameters. method.log = function(candle) { var digits = 8; @@ -42,7 +39,7 @@ method.check = function() { var tsi = this.indicators.tsi; var tsiVal = tsi.tsi; - if(tsiVal > settings.thresholds.high) { + if(tsiVal > this.settings.thresholds.high) { // new trend detected if(this.trend.direction !== 'high') @@ -57,7 +54,7 @@ method.check = function() { log.debug('In high since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -65,8 +62,8 @@ method.check = function() { this.advice('short'); } else this.advice(); - - } else if(tsiVal < settings.thresholds.low) { + + } else if(tsiVal < this.settings.thresholds.low) { // new trend detected if(this.trend.direction !== 'low') @@ -81,7 +78,7 @@ method.check = function() { log.debug('In low since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { diff --git a/strategies/UO.js b/strategies/UO.js index 69bb1035c..b1efdef4a 100644 --- a/strategies/UO.js +++ b/strategies/UO.js @@ -2,9 +2,6 @@ var _ = require('lodash'); var log = require('../core/log.js'); -var config = require('../core/util.js').getConfig(); -var settings = config.UO; - var UO = require('./indicators/UO.js'); // let's create our own method @@ -21,13 +18,13 @@ method.init = function() { adviced: false }; - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need - this.addIndicator('uo', 'UO', settings); + this.addIndicator('uo', 'UO', this.settings); } -// for debugging purposes log the last +// for debugging purposes log the last // calculated parameters. method.log = function(candle) { var digits = 8; @@ -42,7 +39,7 @@ method.check = function() { var uo = this.indicators.uo; var uoVal = uo.uo; - if(uoVal > settings.thresholds.high) { + if(uoVal > this.settings.thresholds.high) { // new trend detected if(this.trend.direction !== 'high') @@ -57,7 +54,7 @@ method.check = function() { log.debug('In high since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { @@ -65,8 +62,8 @@ method.check = function() { this.advice('short'); } else this.advice(); - - } else if(uoVal < settings.thresholds.low) { + + } else if(uoVal < this.settings.thresholds.low) { // new trend detected if(this.trend.direction !== 'low') @@ -81,7 +78,7 @@ method.check = function() { log.debug('In low since', this.trend.duration, 'candle(s)'); - if(this.trend.duration >= settings.thresholds.persistence) + if(this.trend.duration >= this.settings.thresholds.persistence) this.trend.persisted = true; if(this.trend.persisted && !this.trend.adviced) { diff --git a/strategies/talib-macd.js b/strategies/talib-macd.js index 38d59d0b6..f0c3099d6 100644 --- a/strategies/talib-macd.js +++ b/strategies/talib-macd.js @@ -1,12 +1,9 @@ // If you want to use your own trading methods you can // write them here. For more information on everything you // can use please refer to this document: -// +// // https://github.com/askmike/gekko/blob/stable/docs/trading_methods.md -var config = require('../core/util.js').getConfig(); -var settings = config['talib-macd']; - // Let's create our own method var method = {}; @@ -21,9 +18,9 @@ method.init = function() { // how many candles do we need as a base // before we can start giving advice? - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; - var customMACDSettings = settings.parameters; + var customMACDSettings = this.settings.parameters; // define the indicators we need this.addTalibIndicator('mymacd', 'macd', customMACDSettings); @@ -47,15 +44,15 @@ method.check = function(candle) { var result = this.talibIndicators.mymacd.result; var macddiff = result['outMACD'] - result['outMACDSignal']; - if(settings.thresholds.down > macddiff && this.trend !== 'short') { + if(this.settings.thresholds.down > macddiff && this.trend !== 'short') { this.trend = 'short'; this.advice('short'); - } else if(settings.thresholds.up < macddiff && this.trend !== 'long'){ + } else if(this.settings.thresholds.up < macddiff && this.trend !== 'long'){ this.trend = 'long'; this.advice('long'); } } -module.exports = method; \ No newline at end of file +module.exports = method; diff --git a/strategies/varPPO.js b/strategies/varPPO.js index 33ecc21ce..4bcb479e8 100644 --- a/strategies/varPPO.js +++ b/strategies/varPPO.js @@ -21,7 +21,7 @@ method.init = function() { adviced: false }; - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need this.addIndicator('ppo', 'PPO', config.PPO); @@ -33,7 +33,7 @@ method.update = function(candle) { // nothing! } -// for debugging purposes log the last +// for debugging purposes log the last // calculated parameters. method.log = function(candle) { var digits = 8; @@ -86,7 +86,7 @@ method.check = function() { this.advice('long'); } else this.advice(); - + } else if(value > thresholds.high) { // new trend detected @@ -118,9 +118,9 @@ method.check = function() { // we're not in an up nor in a downtrend // but for now we ignore sideways trends - // + // // read more @link: - // + // // https://github.com/askmike/gekko/issues/171 // this.trend = { From 136e4566f93a49eb4fd3b7cc081691fbce9ee79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BRAMILLE=20S=C3=A9bastien?= Date: Tue, 5 Sep 2017 21:09:59 +0100 Subject: [PATCH 09/19] Update creating_a_strategy.md --- docs/strategies/creating_a_strategy.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/strategies/creating_a_strategy.md b/docs/strategies/creating_a_strategy.md index 36497f868..12fe1dd4f 100644 --- a/docs/strategies/creating_a_strategy.md +++ b/docs/strategies/creating_a_strategy.md @@ -187,13 +187,11 @@ You can create configurable parameters for your method which allows you to adjus And in your method you can use them again (for example to pass to an indicator): - // in the init: - var config = require('../core/util.js').getConfig(); - this.settings = config.custom; - // anywhere in your code: this.settings.my_custom_setting; // is now 10 +___The name of your configuration must be the same as the name of the strategy___ + ### Tool libraries Gekko uses a few general purpose libraries a lot internally, you can use those in your methods as well. Most notable libraries are [lodash](http://lodash.com/) (similar as underscore) and [async](https://github.com/caolan/async). From 551c33337625928d09598bde056191a97348d329 Mon Sep 17 00:00:00 2001 From: cbwang2016 Date: Sat, 9 Sep 2017 13:08:41 +0800 Subject: [PATCH 10/19] Fixed a bug in talib.js in the ULTOSC method --- core/talib.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/talib.js b/core/talib.js index aa6b48cf9..fb49d752a 100644 --- a/core/talib.js +++ b/core/talib.js @@ -1273,7 +1273,7 @@ methods.typprice = { } methods.ultosc = { - requires: ['optInTimePeriod'], + requires: ['optInTimePeriod1', 'optInTimePeriod2', 'optInTimePeriod3'], create: (params) => { verifyParams('ultosc', params); @@ -1285,7 +1285,7 @@ methods.ultosc = { startIdx: 0, endIdx: data.high.length - 1, optInTimePeriod1: params.optInTimePeriod1, - optInTimePeriod2: params.params.optInTimePeriod1, + optInTimePeriod2: params.optInTimePeriod2, optInTimePeriod3: params.optInTimePeriod3 }); } From 58b12a7f2e549d07b850c71a605e6bb22ca67f4b Mon Sep 17 00:00:00 2001 From: stackedsax Date: Fri, 8 Sep 2017 19:30:38 -0700 Subject: [PATCH 11/19] Fix what I believe is a typo in the parameter list for the example UO strategy --- config/strategies/UO.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/strategies/UO.toml b/config/strategies/UO.toml index 56b4408d2..f8fd3f1fc 100644 --- a/config/strategies/UO.toml +++ b/config/strategies/UO.toml @@ -12,5 +12,5 @@ period = 28 [thresholds] low = 30 -hight = 70 -persistence = 1 \ No newline at end of file +high = 70 +persistence = 1 From 07e4df19ba35f0c61ffec4860c8c54c633a3788f Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Fri, 15 Sep 2017 15:31:50 +0100 Subject: [PATCH 12/19] remove debug console --- web/vue/src/components/backtester/backtestConfigBuilder.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/vue/src/components/backtester/backtestConfigBuilder.vue b/web/vue/src/components/backtester/backtestConfigBuilder.vue index 76f740a70..ffdb03c88 100644 --- a/web/vue/src/components/backtester/backtestConfigBuilder.vue +++ b/web/vue/src/components/backtester/backtestConfigBuilder.vue @@ -71,8 +71,6 @@ export default { { performanceAnalyzer: this.performanceAnalyzer } ); - console.log(config); - config.valid = this.validConfig(config); return config; From 405ecb6dafc0b4353ad4d27405d48e3c2b26c130 Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Fri, 15 Sep 2017 16:57:05 +0200 Subject: [PATCH 13/19] force uppercase market to make sure we can set market --- plugins/paperTrader/paperTrader.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/paperTrader/paperTrader.js b/plugins/paperTrader/paperTrader.js index 1b3cda588..1bbb720c9 100644 --- a/plugins/paperTrader/paperTrader.js +++ b/plugins/paperTrader/paperTrader.js @@ -1,5 +1,4 @@ const _ = require('lodash'); -const moment = require('moment'); const util = require('../../core/util'); const ENV = util.gekkoEnv(); From 1bc58f70b370b34142f5bbfd272b9e357b739cb5 Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Fri, 15 Sep 2017 17:06:21 +0200 Subject: [PATCH 14/19] fix reuiredHistory in stochRSI, fix #1117 --- strategies/StochRSI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strategies/StochRSI.js b/strategies/StochRSI.js index bcafc2847..08542491d 100644 --- a/strategies/StochRSI.js +++ b/strategies/StochRSI.js @@ -25,7 +25,7 @@ method.init = function() { adviced: false }; - this.requiredHistory = config.tradingAdvisor.historySize; + this.requiredHistory = this.tradingAdvisor.historySize; // define the indicators we need this.addIndicator('rsi', 'RSI', { interval: this.interval }); From c9bf5fa46d77f674973b7bb3996807e589c1f5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BRAMILLE=20S=C3=A9bastien?= Date: Sun, 10 Sep 2017 00:12:39 +0200 Subject: [PATCH 15/19] [BugFix] Talib MACDFIX option does not matches the requires one --- core/talib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/talib.js b/core/talib.js index fb49d752a..a3d7b31cc 100644 --- a/core/talib.js +++ b/core/talib.js @@ -588,7 +588,7 @@ methods.macdext = { } methods.macdfix = { - requires: ['SignalPeriod'], + requires: ['optInSignalPeriod'], create: (params) => { verifyParams('macdfix', params); From 87edc9594fa6f04e073e83129d618ac8f2a1f79e Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Fri, 15 Sep 2017 18:14:03 +0200 Subject: [PATCH 16/19] force uppercase market to make sure we can set market --- plugins/trader/portfolioManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/trader/portfolioManager.js b/plugins/trader/portfolioManager.js index b22ccbb38..f8f884d02 100644 --- a/plugins/trader/portfolioManager.js +++ b/plugins/trader/portfolioManager.js @@ -38,7 +38,7 @@ var Manager = function(conf) { this.action; this.marketConfig = _.find(this.exchangeMeta.markets, function(p) { - return p.pair[0] === conf.currency && p.pair[1] === conf.asset; + return _.first(p.pair) === conf.currency.toUpperCase() && _.last(p.pair) === conf.asset.toUpperCase(); }); this.minimalOrder = this.marketConfig.minimalOrder; From 21f7b2a70625af582ad51cde519dce65d8815541 Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Fri, 15 Sep 2017 18:26:40 +0200 Subject: [PATCH 17/19] use arrow functions, fix binding issue. See #1114 --- exchanges/bitfinex.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/exchanges/bitfinex.js b/exchanges/bitfinex.js index ec6c090c8..480fa05b6 100644 --- a/exchanges/bitfinex.js +++ b/exchanges/bitfinex.js @@ -45,7 +45,7 @@ Trader.prototype.retry = function(method, args) { Trader.prototype.getPortfolio = function(callback) { var args = _.toArray(arguments); - this.bitfinex.wallet_balances(function (err, data, body) { + this.bitfinex.wallet_balances((err, data, body) => { if(err && err.message === '401') { let e = 'Bitfinex replied with an unauthorized error. '; @@ -84,13 +84,13 @@ Trader.prototype.getPortfolio = function(callback) { ]; callback(err, portfolio); - }.bind(this)); + }); } Trader.prototype.getTicker = function(callback) { var args = _.toArray(arguments); // the function that will handle the API callback - var process = function(err, data, body) { + var process = (err, data, body) => { if (err) return this.retry(this.getTicker(args)); @@ -98,7 +98,7 @@ Trader.prototype.getTicker = function(callback) { // data, the callback is still the same since // we are inside the same javascript scope. callback(err, {bid: +data.bid, ask: +data.ask}) - }.bind(this); + }; this.bitfinex.ticker(this.pair, process); } @@ -120,7 +120,7 @@ Trader.prototype.submit_order = function(type, amount, price, callback) { this.name.toLowerCase(), type, 'exchange limit', - function (err, data, body) { + (err, data, body) => { if (err) { log.error('unable to ' + type, err, body); return this.retry(this.submit_order, args); @@ -152,7 +152,7 @@ Trader.prototype.checkOrder = function(order_id, callback) { Trader.prototype.getOrder = function(order, callback) { var args = _.toArray(arguments); - var get = function(err, data) { + var get = (err, data) => { if(err || !data) return this.retry(this.getOrder, arguments); @@ -161,7 +161,7 @@ Trader.prototype.getOrder = function(order, callback) { var date = moment.unix(data.timestamp); callback(undefined, {price, amount, date}); - }.bind(this); + }; this.bitfinex.order_status(order, get); } @@ -169,7 +169,7 @@ Trader.prototype.getOrder = function(order, callback) { Trader.prototype.cancelOrder = function(order_id, callback) { var args = _.toArray(arguments); - this.bitfinex.cancel_order(order_id, function (err, data, body) { + this.bitfinex.cancel_order(order_id, (err, data, body) => { if (err || !data) { // bitfinex way of telling it was already cancelled.. if(err.message === 'Order could not be cancelled.') @@ -180,7 +180,7 @@ Trader.prototype.cancelOrder = function(order_id, callback) { } return callback(); - }.bind(this)); + }); } Trader.prototype.getTrades = function(since, callback, descending) { @@ -190,7 +190,7 @@ Trader.prototype.getTrades = function(since, callback, descending) { if(since) path += '?limit_trades=2000'; - this.bitfinex.trades(path, function(err, data) { + this.bitfinex.trades(path, (err, data) => { if (err) return this.retry(this.getTrades, args); @@ -204,7 +204,7 @@ Trader.prototype.getTrades = function(since, callback, descending) { }); callback(null, descending ? trades : trades.reverse()); - }.bind(this)); + }); } Trader.getCapabilities = function () { From a899e1c7d0135df322bf9938bd6d62813352fd38 Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Sun, 17 Sep 2017 23:11:26 +0200 Subject: [PATCH 18/19] pass config key/pw to bittrex, fix #1054 --- exchanges/bittrex.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/exchanges/bittrex.js b/exchanges/bittrex.js index f48098b66..6414e5c94 100644 --- a/exchanges/bittrex.js +++ b/exchanges/bittrex.js @@ -3,7 +3,6 @@ var util = require('../core/util.js'); var _ = require('lodash'); var moment = require('moment'); var log = require('../core/log'); -var apiKeyManager = require('../web/apiKeyManager.js'); // Helper methods function joinCurrencies(currencyA, currencyB){ @@ -13,13 +12,7 @@ function joinCurrencies(currencyA, currencyB){ var Trader = function(config) { _.bindAll(this); - // not nice but works to use a web module here to grab the keys - var keys = apiKeyManager._getApiKeyPair('bittrex'); - - if(_.isObject(keys)) { - config.key = keys.key; - config.secret = keys.secret; - } else { + if(!config.key) { // no api key defined -> we need to set a dummy key, otherwise the Bittrex module will not work even for public requests config.key = 'dummyApiKey'; config.secret = 'dummyApiKey'; From 20599af2bb5e382b70efb9fdd37d53c7cfe32134 Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Mon, 18 Sep 2017 13:27:14 +0200 Subject: [PATCH 19/19] v0.5.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98b2aea55..992332164 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gekko", - "version": "0.5.6", + "version": "0.5.7", "description": "A bitcoin trading bot for auto trading at various exchanges", "keywords": [ "trading",