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/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 diff --git a/install.sh b/install.sh index 96e5a2d..bed5dbe 100755 --- a/install.sh +++ b/install.sh @@ -5,32 +5,111 @@ 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 -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" +} + +function processfiles(){ + location=$1 + echo "+++ Processing target location: ${location}" + IFS=$'\n' + for src in `cat ${tmpfile}` + do + # 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" + 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 + 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 + 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" + continue + 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' )) -for i in "${e[@]}" -do -echo "Copy indicator: $i" -cp $i $g/strategies/indicators/ -done - -e=($(find ./ -name *.js | grep -E -v '!|indicators')) -for i in "${e[@]}" -do -echo "Copy strategy: $i" -cp $i $g/strategies -done - -e=($(find ./ -name *.toml | grep -E -v '!')) -for i in "${e[@]}" -do -echo "Copy strategy config: $i" -cp $i $g/config/strategies/ -done + +tmpfile="filenamecomparison.$(date '+%s').tmp" + +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"