Skip to content

Commit

Permalink
part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
xFFFFF committed Apr 4, 2018
1 parent e0a1ab4 commit b0560c4
Show file tree
Hide file tree
Showing 29 changed files with 2,085 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
[submodule "gekko-strat-hl"]
path = gekko-strat-hl
url = https://github.com/mounirlabaied/gekko-strat-hl
[submodule "gekko"]
path = gekko
url = https://github.com/zzmike76/gekko
1 change: 1 addition & 0 deletions CUSTOM_RSI/CUSTOM_RSI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Source: https://raw.githubusercontent.com/trainerbill/gekko/develop/strategies/CUSTOM-RSI.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
var log = require('../core/log.js');
const Joi = require('joi');
// If you want to use your own trading methods you can
Expand Down
1 change: 1 addition & 0 deletions DEMACrossover/DEMACrossover.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Source: https://raw.githubusercontent.com/vrfurl/gekko/stable/strategies/DEMACrossover.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
// helpers
var _ = require('lodash');
var log = require('../core/log.js');
Expand Down
2 changes: 1 addition & 1 deletion DI/DI.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Source: https://raw.githubusercontent.com/gcobs0834/gekko/develop/strategies/DI.js

// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
// let's create our own method
var method = {};

Expand Down
1 change: 1 addition & 0 deletions EMACrossover/EMACrossover.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Source: https://raw.githubusercontent.com/vrfurl/gekko/stable/strategies/EMACrossover.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
// helpers
var _ = require('lodash');
var log = require('../core/log.js');
Expand Down
1 change: 1 addition & 0 deletions EMADIV/EMADIV.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Source: https://raw.githubusercontent.com/imperator6/gekko/stable/strategies/EMADIV.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
// helpers
var _ = require('lodash');
var log = require('../core/log.js');
Expand Down
1 change: 1 addition & 0 deletions EMADIV2/EMADIV2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Source: https://raw.githubusercontent.com/imperator6/gekko/stable/strategies/EMADIV2.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
// helpers
var _ = require('lodash');
var log = require('../core/log.js');
Expand Down
1 change: 1 addition & 0 deletions EMA_OR_PRICE_DIV/EMA_OR_PRICE_DIV.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Source: https://raw.githubusercontent.com/imperator6/gekko/stable/strategies/EMA_OR_PRICE_DIV.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
// helpers
var _ = require('lodash');
var log = require('../core/log.js');
Expand Down
1 change: 1 addition & 0 deletions FIXPRICE/FIXPRICE.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Source: https://raw.githubusercontent.com/imperator6/gekko/stable/strategies/FIXPRICE.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies
// helpers
var _ = require('lodash');
var log = require('../core/log.js');
Expand Down
2 changes: 2 additions & 0 deletions MACD_1520024643/MACD_1520024643.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Source: https://raw.githubusercontent.com/jazzbre/gekko/stable/strategies/MACD.js
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies

/*
MACD - DJM 31/12/2013
Expand Down
196 changes: 196 additions & 0 deletions NEO/NEO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies

// Source: https://raw.githubusercontent.com/gcobs0834/gekko/develop/strategies/NEO.js
/*
RSI Bull and Bear
Use different RSI-strategies depending on a longer trend
3 feb 2017
(CC-BY-SA 4.0) Tommie Hansen
https://creativecommons.org/licenses/by-sa/4.0/
*/

// req's
var log = require ('../core/log.js');
var config = require ('../core/util.js').getConfig();

// strategy
var strat = {

/* INIT */
init: function()
{
this.name = 'RSI Bull and Bear';
this.requiredHistory = config.tradingAdvisor.historySize;
this.resetTrend();

// debug? set to flase to disable all logging (improves performance)
this.debug = false;

// add indicators
this.addTulipIndicator('maSlow', 'sma', { optInTimePeriod: this.settings.SMA_long });
this.addTulipIndicator('maFast', 'sma', { optInTimePeriod: this.settings.SMA_short });
this.addTulipIndicator('BULL_RSI', 'rsi', { optInTimePeriod: this.settings.BULL_RSI });
this.addTulipIndicator('IDLE_RSI', 'rsi', { optInTimePeriod: this.settings.IDLE_RSI });
this.addTulipIndicator('BEAR_RSI', 'rsi', { optInTimePeriod: this.settings.BEAR_RSI });
this.addTulipIndicator('ROC_val', 'roc', { optInTimePeriod: this.settings.ROC });

// debug stuff
this.startTime = new Date();
this.stat = {
bear: { min: 100, max: 0 },
bull: { min: 100, max: 0 },
idle: { min: 100, max: 0 }
};


}, // init()


/* RESET TREND */
resetTrend: function()
{
var trend = {
duration: 0,
direction: 'none',
longPos: false,
};

this.trend = trend;
},

/* get lowest/highest for backtest-period */
lowHigh: function( rsi, type )
{
let cur;
if( type == 'bear' ) {
cur = this.stat.bear;
if( rsi < cur.min ) this.stat.bear.min = rsi; // set new
if( rsi > cur.max ) this.stat.bear.max = rsi;
}
else if( type == 'idle') {
cur = this.stat.idle;
if( rsi < cur.min ) this.stat.idle.min = rsi; // set new
if( rsi > cur.max ) this.stat.idle.max = rsi;
}

else {
cur = this.stat.bull;
if( rsi < cur.min ) this.stat.bull.min = rsi; // set new
if( rsi > cur.max ) this.stat.bull.max = rsi;
}
},


/* CHECK */
check: function()
{
if( this.candle.close.length < this.requiredHistory ) { return; } // check if candle length is correct

// get all indicators
let ind = this.tulipIndicators,
maSlow = ind.maSlow.result.result,
maFast = ind.maFast.result.result,
rsi,
ROC_val = ind.ROC_val.result.result;

// BEAR TREND
if( maFast < maSlow )
{
rsi = ind.BEAR_RSI.result.result;
if( rsi > this.settings.BEAR_RSI_high ) this.short();
else if( rsi < this.settings.BEAR_RSI_low ) this.long();
if(this.debug) this.lowHigh( rsi, 'bear' );
//log.debug('BEAR-trend');
}

// BULL TREND
else
{
// IDLE-BULL OR REAL-BULL TREND ??
if( ROC_val <= this.settings.ROC_lvl )
{
// BULL-IDLE TREND
rsi = ind.IDLE_RSI.result.result;
if( rsi > this.settings.IDLE_RSI_high ) this.short();
else if( rsi < this.settings.IDLE_RSI_low ) this.long();
if(this.debug) this.lowHigh( rsi, 'idle' );
//log.debug('IDLE-trend');
}
// REAL BULL TREND
else
{
rsi = ind.BULL_RSI.result.result;
if( rsi > this.settings.BULL_RSI_high ) this.short();
else if( rsi < this.settings.BULL_RSI_low ) this.long();
if(this.debug) this.lowHigh( rsi, 'bull' );
//log.debug('BULL-trend');
}

}

}, // check()


/* LONG */
long: function()
{
if( this.trend.direction !== 'up' ) // new trend? (only act on new trends)
{
this.resetTrend();
this.trend.direction = 'up';
this.advice('long');
//log.debug('go long');
}

if(this.debug)
{
this.trend.duration++;
log.debug ('Long since', this.trend.duration, 'candle(s)');
}
},


/* SHORT */
short: function()
{
// new trend? (else do things)
if( this.trend.direction !== 'down' )
{
this.resetTrend();
this.trend.direction = 'down';
this.advice('short');
}

if(this.debug)
{
this.trend.duration++;
log.debug ('Short since', this.trend.duration, 'candle(s)');
}
},


/* END backtest */
end: function(){

let seconds = ((new Date()- this.startTime)/1000),
minutes = seconds/60,
str;

minutes < 1 ? str = seconds + ' seconds' : str = minutes + ' minutes';

log.debug('Finished in ' + str);

if(this.debug)
{
let stat = this.stat;
log.debug('RSI low/high for period:');
log.debug('BEAR low/high: ' + stat.bear.min + ' / ' + stat.bear.max);
log.debug('BULL low/high: ' + stat.bull.min + ' / ' + stat.bull.max);
log.debug('IDLE low/high: ' + stat.idle.min + ' / ' + stat.idle.max);
}
}

};

module.exports = strat;
30 changes: 30 additions & 0 deletions NEO/NEO.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Source: https://raw.githubusercontent.com/gcobs0834/gekko/develop/config/strategies/NEO.toml
# SMA Trends
SMA_long = 150
SMA_short = 40

# BULL
BULL_RSI = 10
BULL_RSI_high = 80
BULL_RSI_low = 50

# IDLE
IDLE_RSI = 12
IDLE_RSI_high = 65
IDLE_RSI_low = 39

# BEAR
BEAR_RSI = 15
BEAR_RSI_high = 50
BEAR_RSI_low = 25

# ROC
ROC = 6
ROC_lvl = 0

# BULL/BEAR is defined by the longer SMA trends
# if SHORT over LONG = BULL
# if SHORT under LONG = BEAR

# ROC is the LENGHT (averaging)
# Leave ROC_lvl at 0 otherwise Results are negative
2 changes: 2 additions & 0 deletions NN_ADX_RSI/NN_ADX_RSI.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Downloaded from: https://github.com/xFFFFF/Gekko-Strategies

var convnetjs = require('convnetjs')
var z = require('zero-fill')
var stats = require('stats-lite')
Expand Down
Loading

0 comments on commit b0560c4

Please sign in to comment.