Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wanted it to work with all strategies #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion !WORKSOP/indicators/StopLoss.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
module.exports = Indicator;
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
127 changes: 103 additions & 24 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"