From e72055be485a2efbf2b4e1a433bcc517683d94b8 Mon Sep 17 00:00:00 2001 From: Christof Spanring Date: Wed, 3 Apr 2019 02:08:44 +0200 Subject: [PATCH 1/4] fixed install script to not overwrite existing files and avoid duplicates --- install.sh | 57 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 96e5a2d..b3d53cc 100755 --- a/install.sh +++ b/install.sh @@ -11,26 +11,57 @@ echo 'Type path to Gekko folder: [ex. /home/xFFFFF/gekko/] and press ENTER' read g fi -echo "Install strategies to $g directory"; +function copy(){ + orig=$1 + folder=`echo $orig | tr '/' '\n' | head -n 2 | tail -n 1 | tr ' ' '_'` + name=`echo $orig | tr '/' '\n' | tail -n 1` + cont=`echo $name | tr '.' '\n' | head -n 1` + ext=`echo $name | tr '.' '\n' | tail -n 1` + location=$2 + count=1 +# if [ -e "$location$name" ] && [ -n "$(diff "$orig" "$location$name")" ] +# then +# let count="$count+1" + name="${cont}-${folder}.${ext}" +# fi + while [ -e "$location$name" ] && [ -n "$(diff "$orig" "$location$name")" ] + do + let count="$count+1" + name="${cont}-${count}.${ext}" + done + if [ -e "$location$name" ] && [ -z "$(diff "${orig}" "${location}${name}")" ] + then + echo "Exact same file already present" + return + fi + if [ $count -gt 1 ] + then + echo "New name: $name" + fi + cp "$orig" "$location/$name" +} +echo "Install strategies to $g directory" #sed "s!\./!!g; s/^/\"/g; s/$/\"/g" -e=($(find . -name *.js | grep -E 'indicators' )) -for i in "${e[@]}" + +e=$(find ./ -name *.js | grep -E 'indicators' ) +echo "${e[@]}" | while read i do -echo "Copy indicator: $i" -cp $i $g/strategies/indicators/ + echo "Copy indicator: $i" + copy "$i" "$g/strategies/indicators/" done -e=($(find ./ -name *.js | grep -E -v '!|indicators')) -for i in "${e[@]}" +e=$(find ./ -name *.js | grep -E -v '!|indicators') +echo "${e[@]}" | while read i do -echo "Copy strategy: $i" -cp $i $g/strategies + echo "Copy strategy: $i" + copy "$i" "$g/strategies/" done -e=($(find ./ -name *.toml | grep -E -v '!')) -for i in "${e[@]}" +e=$(find ./ -name *.toml | grep -E -v '!') +echo "${e[@]}" | while read i do -echo "Copy strategy config: $i" -cp $i $g/config/strategies/ + echo "Copy strategy config: $i" + copy "$i" "$g/config/strategies/" done + echo "Install complete" From 2b34e1c221e3ad276c17adbfb1d0c2e33a8e34a1 Mon Sep 17 00:00:00 2001 From: Christof Spanring Date: Wed, 3 Apr 2019 02:10:26 +0200 Subject: [PATCH 2/4] submodule initiliatization should be included in readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 54fba46..3d6f560 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,9 @@ Feel free if You want share strategies on this repo. I will backtest it after pu ### Unix-like 1. `git clone https://github.com/xFFFFF/Gekko-Strategies` 2. `cd Gekko-Strategies` -3. `bash install.sh` -4. Restart Gekko +3. `git submodule update --init` +4. `bash install.sh` +5. Restart Gekko ### Windows 1. Download: https://github.com/xFFFFF/Gekko-Strategies/archive/master.zip From 8d0f54f5a5e495227084570071c2ea5591ee5132 Mon Sep 17 00:00:00 2001 From: Christof Spanring Date: Thu, 4 Apr 2019 21:18:50 +0200 Subject: [PATCH 3/4] new install.sh tries to keep filenames, particularly for indicators --- !WORKSOP/indicators/StopLoss.js | 2 +- install.sh | 109 ++++++++++++++++++++++++-------- 2 files changed, 83 insertions(+), 28 deletions(-) diff --git a/!WORKSOP/indicators/StopLoss.js b/!WORKSOP/indicators/StopLoss.js index 5893beb..78b41dd 100644 --- a/!WORKSOP/indicators/StopLoss.js +++ b/!WORKSOP/indicators/StopLoss.js @@ -32,4 +32,4 @@ Indicator.prototype.long = function(price) { this.action = 'continue'; // reset in case we are in freefall before a buy } -module.exports = Indicator; \ No newline at end of file +module.exports = Indicator; diff --git a/install.sh b/install.sh index b3d53cc..abffeaa 100755 --- a/install.sh +++ b/install.sh @@ -5,10 +5,10 @@ echo 'Gekko-Strategies installator' if [ -n "$1" ] then -g=$1 + g=$1 else -echo 'Type path to Gekko folder: [ex. /home/xFFFFF/gekko/] and press ENTER' -read g + echo 'Type path to Gekko folder: [ex. /home/xFFFFF/gekko/] and press ENTER' + read g fi function copy(){ @@ -19,11 +19,11 @@ function copy(){ ext=`echo $name | tr '.' '\n' | tail -n 1` location=$2 count=1 -# if [ -e "$location$name" ] && [ -n "$(diff "$orig" "$location$name")" ] -# then -# let count="$count+1" + if [ -e "$location$name" ] && [ -n "$(diff "$orig" "$location$name")" ] + then + let count="$count+1" name="${cont}-${folder}.${ext}" -# fi + fi while [ -e "$location$name" ] && [ -n "$(diff "$orig" "$location$name")" ] do let count="$count+1" @@ -38,30 +38,85 @@ function copy(){ then echo "New name: $name" fi - cp "$orig" "$location/$name" +# cp "$orig" "$location/$name" } + +function processfiles(){ + location=$1 + echo "+++ Processing target location: ${location}" + IFS=$'\n' + for src in `cat ${tmpfile}` + do +# echo "Source file: ${src}" + folder=`echo "$src" | tr '/' '\n' | head -n 2 | tail -n 1 | tr ' ' '_'` + name=`echo "$src"| tr '/' '\n' | tail -n 1` + oname="$name" + cont=`echo "$name" | tr '.' '\n' | head -n 1` + ext=`echo "$name" | tr '.' '\n' | tail -n 1` + # First check: do we have multiple different occurences of this file + if [ `grep -E "/${name}$" ${tmpfile} | wc -l` -gt 1 ] + then + pre="${src}" + for other in `grep -E "/${name}$" ${tmpfile}` + do + if [ -n "$(diff "$pre" "$other")" ] + then + if [ $(diff "$pre" "$other" | wc -l) -lt 10 ] + then + diff "$pre" "$other" + echo "compared $pre $other" + read + fi + name="${cont}-${folder}.${ext}" + break + fi + done + fi + # Second check: is there a different file under the same name in target folder + if [ -e "$location$name" ] && [ -n "$(diff "${src}" "${location}${name}")" ] + then + if [ $(diff "$src" "$location$name" | wc -l) -lt 10 ] + then + diff "$pre" "$other" + echo "compared $src $location$name" + read + fi + name="${cont}-${folder}.${ext}" + fi + count=1 + # Third check: increase counter until there is no different file in target directory + while [ -e "$location$name" ] && [ -n "$(diff "$src" "$location$name")" ] + do + let count="$count+1" + name="${cont}-${count}.${ext}" + done + # If the same file is already present we don't copy + if [ -e "$location$name" ] && [ -z "$(diff "${src}" "${location}${name}")" ] + then + echo "Exact same file already present" + return + fi + # If we changed the name report the change + if [ "$oname" != "$name" ] + then + echo "New name: $name" + fi +# cp "$src" "$location/$name" + done + unset IFS +} + echo "Install strategies to $g directory" #sed "s!\./!!g; s/^/\"/g; s/$/\"/g" -e=$(find ./ -name *.js | grep -E 'indicators' ) -echo "${e[@]}" | while read i -do - echo "Copy indicator: $i" - copy "$i" "$g/strategies/indicators/" -done - -e=$(find ./ -name *.js | grep -E -v '!|indicators') -echo "${e[@]}" | while read i -do - echo "Copy strategy: $i" - copy "$i" "$g/strategies/" -done +tmpfile="filenamecomparison.$(date '+%s').tmp" -e=$(find ./ -name *.toml | grep -E -v '!') -echo "${e[@]}" | while read i -do - echo "Copy strategy config: $i" - copy "$i" "$g/config/strategies/" -done +find ./ -name *.js | grep -E 'indicators' | grep -v '!' > ${tmpfile} +processfiles "$g/strategies/indicators/" +find ./ -name *.js | grep -E -v '!|indicators' > ${tmpfile} +processfiles "$g/strategies/" +find ./ -name *.toml | grep -E -v '!' > ${tmpfile} +processfiles "$g/config/strategies/" +rm -f ${tmpfile} echo "Install complete" From 95f21272a18bf5f406282cc7ffa4e60eb60cb87c Mon Sep 17 00:00:00 2001 From: Christof Spanring Date: Thu, 4 Apr 2019 21:25:02 +0200 Subject: [PATCH 4/4] bugs in install.sh --- install.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index abffeaa..bed5dbe 100755 --- a/install.sh +++ b/install.sh @@ -47,7 +47,12 @@ function processfiles(){ IFS=$'\n' for src in `cat ${tmpfile}` do -# echo "Source file: ${src}" + # If the same file is already present we skip it + if [ -e "$location$name" ] && [ -z "$(diff "${src}" "${location}${name}")" ] + then + continue + fi + echo "Source file: ${src}" folder=`echo "$src" | tr '/' '\n' | head -n 2 | tail -n 1 | tr ' ' '_'` name=`echo "$src"| tr '/' '\n' | tail -n 1` oname="$name" @@ -61,12 +66,6 @@ function processfiles(){ do if [ -n "$(diff "$pre" "$other")" ] then - if [ $(diff "$pre" "$other" | wc -l) -lt 10 ] - then - diff "$pre" "$other" - echo "compared $pre $other" - read - fi name="${cont}-${folder}.${ext}" break fi @@ -75,12 +74,6 @@ function processfiles(){ # Second check: is there a different file under the same name in target folder if [ -e "$location$name" ] && [ -n "$(diff "${src}" "${location}${name}")" ] then - if [ $(diff "$src" "$location$name" | wc -l) -lt 10 ] - then - diff "$pre" "$other" - echo "compared $src $location$name" - read - fi name="${cont}-${folder}.${ext}" fi count=1 @@ -94,14 +87,14 @@ function processfiles(){ if [ -e "$location$name" ] && [ -z "$(diff "${src}" "${location}${name}")" ] then echo "Exact same file already present" - return + continue fi # If we changed the name report the change if [ "$oname" != "$name" ] then echo "New name: $name" fi -# cp "$src" "$location/$name" + cp "$src" "$location/$name" done unset IFS }