Indent functions code
This commit is contained in:
parent
96c54716d7
commit
7321836bfb
278
setup.sh
278
setup.sh
@ -1,196 +1,170 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#encoding=utf8
|
#encoding=utf8
|
||||||
freqtradepath=$(pwd)
|
|
||||||
|
|
||||||
function go_to_folder () {
|
|
||||||
cd $freqtradepath
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateenv () {
|
function updateenv () {
|
||||||
echo "
|
echo "
|
||||||
-------------------------
|
-------------------------
|
||||||
Update your virtual env
|
Update your virtual env
|
||||||
-------------------------
|
-------------------------
|
||||||
"
|
"
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip3.6 install --upgrade pip
|
pip3.6 install --upgrade pip
|
||||||
pip3 install -r requirements.txt --upgrade
|
pip3 install -r requirements.txt --upgrade
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
pip3 install -e .
|
pip3 install -e .
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install tab lib
|
# Install tab lib
|
||||||
function install_talib () {
|
function install_talib () {
|
||||||
curl -O -L http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
|
curl -O -L http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
|
||||||
tar zxvf ta-lib-0.4.0-src.tar.gz
|
tar zxvf ta-lib-0.4.0-src.tar.gz
|
||||||
cd ta-lib && ./configure --prefix=/usr && make && sudo make install
|
cd ta-lib && ./configure --prefix=/usr && make && sudo make install
|
||||||
cd .. && rm -rf ./ta-lib*
|
cd .. && rm -rf ./ta-lib*
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install bot MacOS
|
# Install bot MacOS
|
||||||
function install_macos () {
|
function install_macos () {
|
||||||
if [ ! -x "$(command -v brew)" ]
|
if [ ! -x "$(command -v brew)" ]
|
||||||
then
|
then
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo "Install Brew"
|
echo "Install Brew"
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo
|
echo
|
||||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||||
fi
|
fi
|
||||||
brew install python3 wget ta-lib
|
brew install python3 wget ta-lib
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install bot Debian_ubuntu
|
# Install bot Debian_ubuntu
|
||||||
function install_debian () {
|
function install_debian () {
|
||||||
sudo add-apt-repository ppa:jonathonf/python-3.6
|
sudo add-apt-repository ppa:jonathonf/python-3.6
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install python3.6 python3.6-venv python3.6-dev build-essential autoconf libtool pkg-config make wget git
|
sudo apt-get install python3.6 python3.6-venv python3.6-dev build-essential autoconf libtool pkg-config make wget git
|
||||||
install_talib
|
install_talib
|
||||||
}
|
}
|
||||||
|
|
||||||
# Upgrade the bot
|
# Upgrade the bot
|
||||||
function update () {
|
function update () {
|
||||||
go_to_folder
|
git pull
|
||||||
git pull
|
updateenv
|
||||||
updateenv
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Reset Develop or Master branch
|
# Reset Develop or Master branch
|
||||||
function reset () {
|
function reset () {
|
||||||
|
echo "----------------------------"
|
||||||
|
echo "Reset branch and virtual env"
|
||||||
|
echo "----------------------------"
|
||||||
|
echo
|
||||||
|
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ]
|
||||||
|
then
|
||||||
|
if [ -d ".env" ]; then
|
||||||
|
echo "- Delete your previous virtual env"
|
||||||
|
rm -rf .env
|
||||||
|
fi
|
||||||
|
|
||||||
echo "
|
git fetch -a
|
||||||
----------------------------
|
|
||||||
Reset branch and virtual env
|
|
||||||
----------------------------
|
|
||||||
"
|
|
||||||
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ]
|
|
||||||
then
|
|
||||||
go_to_folder
|
|
||||||
|
|
||||||
if [ -d ".env" ]; then
|
if [ "1" == $(git branch -vv |grep -c "* develop") ]
|
||||||
echo "- Delete your previous virtual env"
|
then
|
||||||
rm -rf .env
|
echo "- Hard resetting of 'develop' branch."
|
||||||
|
git reset --hard origin/develop
|
||||||
|
elif [ "1" == $(git branch -vv |grep -c "* master") ]
|
||||||
|
then
|
||||||
|
echo "- Hard resetting of 'master' branch."
|
||||||
|
git reset --hard origin/master
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Reset ignored because you are not on 'master' or 'develop'."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git fetch -a
|
python3.6 -m venv .env
|
||||||
|
updateenv
|
||||||
if [ "1" == $(git branch -vv |grep -c "* develop") ]
|
|
||||||
then
|
|
||||||
echo "- Hard resetting of 'develop' branch."
|
|
||||||
git reset --hard origin/develop
|
|
||||||
elif [ "1" == $(git branch -vv |grep -c "* master") ]
|
|
||||||
then
|
|
||||||
echo "- Hard resetting of 'master' branch."
|
|
||||||
git reset --hard origin/master
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Reset ignored because you are not on 'master' or 'develop'."
|
|
||||||
fi
|
|
||||||
|
|
||||||
python3.6 -m venv .env
|
|
||||||
updateenv
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function config_generator () {
|
function config_generator () {
|
||||||
|
|
||||||
echo "Starting to generate config.json"
|
echo "Starting to generate config.json"
|
||||||
|
|
||||||
echo "
|
echo "-------------------------"
|
||||||
-------------------------
|
echo "General configuration"
|
||||||
General configuration
|
echo "-------------------------"
|
||||||
-------------------------
|
echo
|
||||||
"
|
read -p "Max open trades: (Default: 3) " max_trades
|
||||||
read -p "Max open trades: (Default: 3)
|
|
||||||
" max_trades
|
|
||||||
|
|
||||||
read -p "Stake amount: (Default: 0.05)
|
read -p "Stake amount: (Default: 0.05) " stake_amount
|
||||||
" stake_amount
|
|
||||||
|
|
||||||
read -p "Stake currency: (Default: BTC)
|
read -p "Stake currency: (Default: BTC) " stake_currency
|
||||||
" stake_currency
|
|
||||||
|
|
||||||
read -p "Fiat currency: (Default: USD)
|
read -p "Fiat currency: (Default: USD) " fiat_currency
|
||||||
" fiat_currency
|
|
||||||
|
|
||||||
echo "
|
echo "------------------------"
|
||||||
------------------------
|
echo "Bittrex config generator"
|
||||||
Bittrex config generator
|
echo "------------------------"
|
||||||
------------------------
|
echo
|
||||||
"
|
read -p "Exchange API key: " api_key
|
||||||
read -p "Exchange API key
|
read -p "Exchange API Secret: " api_secret
|
||||||
" api_key
|
|
||||||
read -p "Exchange API Secret
|
|
||||||
" -s api_secret
|
|
||||||
|
|
||||||
echo "
|
echo "-------------------------"
|
||||||
-------------------------
|
echo "Telegram config generator"
|
||||||
Telegram config generator
|
echo "-------------------------"
|
||||||
-------------------------
|
read -p "Telegram Token: " token
|
||||||
"
|
read -p "Telegram Chat_id: " chat_id
|
||||||
read -p "Telegram Token
|
|
||||||
" -s token
|
|
||||||
read -p "Telegram Chat_id
|
|
||||||
" chat_id
|
|
||||||
|
|
||||||
sed -e "s/\"max_open_trades\": 3,/\"max_open_trades\": $max_trades,/g" \
|
sed -e "s/\"max_open_trades\": 3,/\"max_open_trades\": $max_trades,/g" \
|
||||||
-e "s/\"stake_amount\": 0.05,/\"stake_amount\": $stake_amount,/g" \
|
-e "s/\"stake_amount\": 0.05,/\"stake_amount\": $stake_amount,/g" \
|
||||||
-e "s/\"stake_currency\": \"BTC\",/\"stake_currency\": \"$stake_currency\",/g" \
|
-e "s/\"stake_currency\": \"BTC\",/\"stake_currency\": \"$stake_currency\",/g" \
|
||||||
-e "s/\"fiat_display_currency\": \"USD\",/\"fiat_display_currency\": \"$fiat_currency\",/g" \
|
-e "s/\"fiat_display_currency\": \"USD\",/\"fiat_display_currency\": \"$fiat_currency\",/g" \
|
||||||
-e "s/\"your_echange_key\"/\"$api_key\"/g" \
|
-e "s/\"your_echange_key\"/\"$api_key\"/g" \
|
||||||
-e "s/\"your_echange_secret\"/\"$api_secret\"/g" \
|
-e "s/\"your_echange_secret\"/\"$api_secret\"/g" \
|
||||||
-e "s/\"your_instagram_token\"/\"$token\"/g" \
|
-e "s/\"your_instagram_token\"/\"$token\"/g" \
|
||||||
-e "s/\"your_instagram_chat_id\"/\"$chat_id\"/g"
|
-e "s/\"your_instagram_chat_id\"/\"$chat_id\"/g"
|
||||||
-e "s/\"dry_run\": false,/\"dry_run\": true,/g" config.json.example > config.json
|
-e "s/\"dry_run\": false,/\"dry_run\": true,/g" config.json.example > config.json
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function config () {
|
function config () {
|
||||||
go_to_folder
|
if [ -f config.json ]
|
||||||
if [ -f config.json ]
|
then
|
||||||
then
|
read -p "A config file already exist, do you want to override it [Y/N]? "
|
||||||
read -p "A config file already exist, do you want to override it [Y/N]?
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||||
"
|
then
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
config_generator
|
||||||
then
|
else
|
||||||
config_generator
|
echo "Configuration of config.json ignored."
|
||||||
else
|
fi
|
||||||
echo "Configuration of config.json ignored."
|
else
|
||||||
fi
|
config_generator
|
||||||
else
|
fi
|
||||||
config_generator
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Edit ./config.json to modify Pair and other configurations."
|
echo "Edit ./config.json to modify Pair and other configurations."
|
||||||
}
|
}
|
||||||
|
|
||||||
function install () {
|
function install () {
|
||||||
echo "
|
echo "-------------------------"
|
||||||
-------------------------
|
echo "Install mandatory dependencies"
|
||||||
Install mandatory dependencies
|
echo "-------------------------"
|
||||||
-------------------------
|
echo
|
||||||
"
|
|
||||||
|
|
||||||
go_to_folder
|
if [ "$(uname -s)" == "Darwin" ]
|
||||||
if [ "$(uname -s)" == "Darwin" ]
|
then
|
||||||
then
|
echo "- You are on macOS"
|
||||||
echo "- You are on macOS"
|
install_macos
|
||||||
install_macos
|
elif [ -x "$(command -v apt-get)" ]
|
||||||
elif [ -x "$(command -v apt-get)" ]
|
then
|
||||||
then
|
echo "- You are on Debian/Ubuntu"
|
||||||
echo "- You are on Debian/Ubuntu"
|
install_debian
|
||||||
install_debian
|
else
|
||||||
else
|
echo "This script does not support your OS."
|
||||||
echo "This script does not support your OS."
|
echo "If you have Python3.6, pip, virtualenv, ta-lib you can continue."
|
||||||
echo "If you have Python3.6, pip, virtualenv, ta-lib you can continue."
|
echo "Wait 10 seconds to continue the next install steps or use ctrl+c to interrupt this shell."
|
||||||
echo "Wait 10 seconds to continue the next install steps or use ctrl+c to interrupt this shell."
|
sleep 10
|
||||||
sleep 10
|
fi
|
||||||
fi
|
reset
|
||||||
reset
|
echo "
|
||||||
echo "
|
- Install complete.
|
||||||
- Install complete.
|
"
|
||||||
"
|
config
|
||||||
config
|
echo "You can now use the bot by executing 'source .env/bin/activate; python3 freqtrade/main.py'."
|
||||||
echo "You can now use the bot by executing 'source .env/bin/activate; python3 freqtrade/main.py'."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function plot () {
|
function plot () {
|
||||||
@ -199,16 +173,16 @@ echo "
|
|||||||
Install dependencies for Plotting scripts
|
Install dependencies for Plotting scripts
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
"
|
"
|
||||||
pip install plotly
|
pip install plotly --upgrade
|
||||||
}
|
}
|
||||||
|
|
||||||
function help () {
|
function help () {
|
||||||
echo "usage:"
|
echo "usage:"
|
||||||
echo " -i,--install Install freqtrade from scratch"
|
echo " -i,--install Install freqtrade from scratch"
|
||||||
echo " -u,--update Command git pull to update."
|
echo " -u,--update Command git pull to update."
|
||||||
echo " -r,--reset Hard reset your develop/master branch."
|
echo " -r,--reset Hard reset your develop/master branch."
|
||||||
echo " -c,--config Easy config generator (Will override your existing file)."
|
echo " -c,--config Easy config generator (Will override your existing file)."
|
||||||
echo " -p,--plot Install dependencies for Plotting scripts."
|
echo " -p,--plot Install dependencies for Plotting scripts."
|
||||||
}
|
}
|
||||||
|
|
||||||
case $* in
|
case $* in
|
||||||
|
Loading…
Reference in New Issue
Block a user