From ce4ff40940e40362755eff459cbe31edd655b5f0 Mon Sep 17 00:00:00 2001 From: Mike van Rossum Date: Tue, 1 Nov 2016 15:13:05 +0000 Subject: [PATCH] add remaining toml method configs --- config/strategies/CCI.toml | 10 ++++++++++ config/strategies/DEMA.toml | 6 ++++++ config/strategies/PPO.toml | 8 ++++++++ config/strategies/StochRSI.toml | 6 ++++++ config/strategies/TSI.toml | 7 +++++++ config/strategies/UO.toml | 16 ++++++++++++++++ config/strategies/talib-macd.toml | 8 ++++++++ config/strategies/varPPO.toml | 9 +++++++++ core/markets/importer.js | 2 +- importers/exchanges/poloniex.js | 3 +-- methods/CCI.js | 18 +++++------------- methods/indicators/CCI.js | 2 +- 12 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 config/strategies/CCI.toml create mode 100644 config/strategies/DEMA.toml create mode 100644 config/strategies/PPO.toml create mode 100644 config/strategies/StochRSI.toml create mode 100644 config/strategies/TSI.toml create mode 100644 config/strategies/UO.toml create mode 100644 config/strategies/talib-macd.toml create mode 100644 config/strategies/varPPO.toml diff --git a/config/strategies/CCI.toml b/config/strategies/CCI.toml new file mode 100644 index 000000000..eb21d8870 --- /dev/null +++ b/config/strategies/CCI.toml @@ -0,0 +1,10 @@ +# constant multiplier. 0.015 gets to around 70% fit +constant = 0.015 + +# history size, make same or smaller than history +history = 90 + +[thresholds] +up = 100 +down = -100 +persistence = 0 \ No newline at end of file diff --git a/config/strategies/DEMA.toml b/config/strategies/DEMA.toml new file mode 100644 index 000000000..d60549806 --- /dev/null +++ b/config/strategies/DEMA.toml @@ -0,0 +1,6 @@ +short = 10 +long = 21 + +[thresholds] +down = -0.025 +up = 0.025 \ No newline at end of file diff --git a/config/strategies/PPO.toml b/config/strategies/PPO.toml new file mode 100644 index 000000000..0492f10e2 --- /dev/null +++ b/config/strategies/PPO.toml @@ -0,0 +1,8 @@ +short = 12 +long = 26 +signal = 9 + +[thresholds] +down = -0.025 +up = 0.025 +persistence = 2 \ No newline at end of file diff --git a/config/strategies/StochRSI.toml b/config/strategies/StochRSI.toml new file mode 100644 index 000000000..b899b8c49 --- /dev/null +++ b/config/strategies/StochRSI.toml @@ -0,0 +1,6 @@ +interval = 3 + +[thresholds] +low = 20 +high = 80 +persistence = 3 \ No newline at end of file diff --git a/config/strategies/TSI.toml b/config/strategies/TSI.toml new file mode 100644 index 000000000..1d0cf4365 --- /dev/null +++ b/config/strategies/TSI.toml @@ -0,0 +1,7 @@ +short = 13 +long = 25 + +[thresholds] +low = -25 +high = 25 +persistence = 1 \ No newline at end of file diff --git a/config/strategies/UO.toml b/config/strategies/UO.toml new file mode 100644 index 000000000..56b4408d2 --- /dev/null +++ b/config/strategies/UO.toml @@ -0,0 +1,16 @@ +[first] +weight = 4 +period = 7 + +[second] +weight = 2 +period = 14 + +[third] +weight = 1 +period = 28 + +[thresholds] +low = 30 +hight = 70 +persistence = 1 \ No newline at end of file diff --git a/config/strategies/talib-macd.toml b/config/strategies/talib-macd.toml new file mode 100644 index 000000000..3bb3ab8b4 --- /dev/null +++ b/config/strategies/talib-macd.toml @@ -0,0 +1,8 @@ +[parameters] +optInFastPeriod = 10 +optInSlowPeriod = 21 +optInSignalPeriod = 9 + +[thresholds] +down = -0.025 +up = 0.025 \ No newline at end of file diff --git a/config/strategies/varPPO.toml b/config/strategies/varPPO.toml new file mode 100644 index 000000000..fd746b6f1 --- /dev/null +++ b/config/strategies/varPPO.toml @@ -0,0 +1,9 @@ +momentum = TSI # RSI, TSI or UO + +[thresholds] +weightLow = 120 +weightHigh = -120 + +# How many candle intervals should a trend persist +# before we consider it real? +persistence = 0 \ No newline at end of file diff --git a/core/markets/importer.js b/core/markets/importer.js index 0d365e425..d346fb8be 100644 --- a/core/markets/importer.js +++ b/core/markets/importer.js @@ -12,7 +12,7 @@ var from = moment.utc(daterange.from); if(daterange.to) { var to = moment.utc(daterange.to); -} else{ +} else { var to = moment().utc(); log.debug( 'No end date specified for importing, setting to', diff --git a/importers/exchanges/poloniex.js b/importers/exchanges/poloniex.js index a8fd71785..22e4063dd 100644 --- a/importers/exchanges/poloniex.js +++ b/importers/exchanges/poloniex.js @@ -61,7 +61,7 @@ var done = false; var fetcher = new Fetcher(config.watch); var fetch = () => { - log.debug( + log.info( 'Requesting data from', iterator.from.format('YYYY-MM-DD HH:mm:ss') + ',', 'to', @@ -71,7 +71,6 @@ var fetch = () => { } var handleFetch = trades => { - iterator.from.add(batchSize, 'minutes').subtract(overlapSize, 'minutes'); iterator.to.add(batchSize, 'minutes').subtract(overlapSize, 'minutes'); diff --git a/methods/CCI.js b/methods/CCI.js index 3b58e4f01..3812e19d9 100644 --- a/methods/CCI.js +++ b/methods/CCI.js @@ -7,16 +7,9 @@ var config = require('../core/util.js').getConfig(); var settings = config.CCI; var pposettings = config.PPO; - // let's create our own method var method = {}; -// teach our trading method events -var Util = require('util'); -//var EventEmitter = require('events').EventEmitter; -//Util.inherits(TradingMethod, EventEmitter); - - // prepare everything our method needs method.init = function() { this.currentTrend; @@ -31,13 +24,13 @@ method.init = function() { }; this.historySize = config.tradingAdvisor.historySize; this.ppoadv = 'none'; - this.uplevel = config.CCI.thresholds.up; - this.downlevel = config.CCI.thresholds.down; - this.persisted = config.CCI.thresholds.persistence; + this.uplevel = settings.thresholds.up; + this.downlevel = settings.thresholds.down; + this.persisted = 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', config.CCI); + this.addIndicator('cci', 'CCI', settings); } // what happens on every new candle? @@ -70,10 +63,8 @@ method.log = function() { */ method.check = function() { - var price = this.lastPrice; - this.age++; var cci = this.indicators.cci; @@ -91,6 +82,7 @@ method.check = function() { this.trend.adviced = false; if (this.persisted == 0) { this.trend.adviced = true; + console.log(2); this.advice('short'); } } else if (cci.result >= this.uplevel) { diff --git a/methods/indicators/CCI.js b/methods/indicators/CCI.js index 20f6183c3..c0124f9fc 100644 --- a/methods/indicators/CCI.js +++ b/methods/indicators/CCI.js @@ -8,7 +8,7 @@ var Indicator = function(settings) { this.tp = 0.0; this.TP = new LRC(settings.history); this.result = false; - this.hist = Array(); // needed for mean? + this.hist = []; // needed for mean? this.mean = 0.0; this.size = 0; this.constant = settings.constant;