2018-01-29 04:53:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#encoding=utf8
|
|
|
|
|
|
|
|
function updateenv () {
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "-------------------------"
|
|
|
|
echo "Update your virtual env"
|
|
|
|
echo "-------------------------"
|
2018-01-29 07:35:13 +00:00
|
|
|
source .env/bin/activate
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "pip3 install in-progress. Please wait..."
|
|
|
|
pip3.6 install --quiet --upgrade pip
|
|
|
|
pip3 install --quiet -r requirements.txt --upgrade
|
|
|
|
pip3 install --quiet -r requirements.txt
|
|
|
|
pip3 install --quiet -e .
|
|
|
|
echo "pip3 install completed"
|
|
|
|
echo
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install tab lib
|
|
|
|
function install_talib () {
|
2018-01-29 07:35:13 +00:00
|
|
|
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
|
|
|
|
cd ta-lib && ./configure --prefix=/usr && make && sudo make install
|
|
|
|
cd .. && rm -rf ./ta-lib*
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install bot MacOS
|
|
|
|
function install_macos () {
|
2018-01-29 07:35:13 +00:00
|
|
|
if [ ! -x "$(command -v brew)" ]
|
|
|
|
then
|
|
|
|
echo "-------------------------"
|
|
|
|
echo "Install Brew"
|
|
|
|
echo "-------------------------"
|
|
|
|
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
|
|
fi
|
|
|
|
brew install python3 wget ta-lib
|
2018-05-30 03:49:37 +00:00
|
|
|
|
|
|
|
test_and_fix_python_on_mac
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install bot Debian_ubuntu
|
|
|
|
function install_debian () {
|
2018-01-29 07:35:13 +00:00
|
|
|
sudo add-apt-repository ppa:jonathonf/python-3.6
|
|
|
|
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
|
|
|
|
install_talib
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Upgrade the bot
|
|
|
|
function update () {
|
2018-01-29 07:35:13 +00:00
|
|
|
git pull
|
|
|
|
updateenv
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Reset Develop or Master branch
|
|
|
|
function reset () {
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "----------------------------"
|
|
|
|
echo "Reset branch and virtual env"
|
|
|
|
echo "----------------------------"
|
|
|
|
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ]
|
2018-01-29 04:53:55 +00:00
|
|
|
then
|
2018-01-29 07:35:13 +00:00
|
|
|
if [ -d ".env" ]; then
|
|
|
|
echo "- Delete your previous virtual env"
|
|
|
|
rm -rf .env
|
|
|
|
fi
|
|
|
|
|
|
|
|
git fetch -a
|
|
|
|
|
|
|
|
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'."
|
2018-01-29 04:53:55 +00:00
|
|
|
fi
|
|
|
|
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2018-01-29 07:35:13 +00:00
|
|
|
python3.6 -m venv .env
|
|
|
|
updateenv
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
2018-05-30 03:49:37 +00:00
|
|
|
function test_and_fix_python_on_mac() {
|
|
|
|
|
|
|
|
if ! [ -x "$(command -v python3.6)" ]
|
|
|
|
then
|
|
|
|
echo "-------------------------"
|
|
|
|
echo "Fixing Python"
|
|
|
|
echo "-------------------------"
|
|
|
|
echo "Python 3.6 is not linked in your system. Fixing it..."
|
|
|
|
brew link --overwrite python
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-01-29 04:53:55 +00:00
|
|
|
function config_generator () {
|
|
|
|
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "Starting to generate config.json"
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "General configuration"
|
|
|
|
echo "-------------------------"
|
2018-05-22 14:05:08 +00:00
|
|
|
default_max_trades=3
|
|
|
|
read -p "Max open trades: (Default: $default_max_trades) " max_trades
|
|
|
|
max_trades=${max_trades:-$default_max_trades}
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2018-05-22 14:05:08 +00:00
|
|
|
default_stake_amount=0.05
|
|
|
|
read -p "Stake amount: (Default: $default_stake_amount) " stake_amount
|
|
|
|
stake_amount=${stake_amount:-$default_stake_amount}
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2018-05-22 14:05:08 +00:00
|
|
|
default_stake_currency="BTC"
|
|
|
|
read -p "Stake currency: (Default: $default_stake_currency) " stake_currency
|
|
|
|
stake_currency=${stake_currency:-$default_stake_currency}
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2018-05-22 14:05:08 +00:00
|
|
|
default_fiat_currency="USD"
|
|
|
|
read -p "Fiat currency: (Default: $default_fiat_currency) " fiat_currency
|
|
|
|
fiat_currency=${fiat_currency:-$default_fiat_currency}
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2018-01-29 07:35:13 +00:00
|
|
|
echo
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "Exchange config generator"
|
|
|
|
echo "------------------------"
|
2018-01-29 07:35:13 +00:00
|
|
|
read -p "Exchange API key: " api_key
|
|
|
|
read -p "Exchange API Secret: " api_secret
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "Telegram config generator"
|
|
|
|
echo "-------------------------"
|
|
|
|
read -p "Telegram Token: " token
|
|
|
|
read -p "Telegram Chat_id: " chat_id
|
|
|
|
|
|
|
|
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_currency\": \"BTC\",/\"stake_currency\": \"$stake_currency\",/g" \
|
|
|
|
-e "s/\"fiat_display_currency\": \"USD\",/\"fiat_display_currency\": \"$fiat_currency\",/g" \
|
2018-01-31 08:46:20 +00:00
|
|
|
-e "s/\"your_exchange_key\"/\"$api_key\"/g" \
|
|
|
|
-e "s/\"your_exchange_secret\"/\"$api_secret\"/g" \
|
2018-02-03 20:55:15 +00:00
|
|
|
-e "s/\"your_telegram_token\"/\"$token\"/g" \
|
2018-04-18 11:11:37 +00:00
|
|
|
-e "s/\"your_telegram_chat_id\"/\"$chat_id\"/g" \
|
2018-01-29 07:35:13 +00:00
|
|
|
-e "s/\"dry_run\": false,/\"dry_run\": true,/g" config.json.example > config.json
|
2018-01-29 04:53:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function config () {
|
2018-05-30 03:48:34 +00:00
|
|
|
|
|
|
|
echo "-------------------------"
|
|
|
|
echo "Config file generator"
|
|
|
|
echo "-------------------------"
|
2018-01-29 07:35:13 +00:00
|
|
|
if [ -f config.json ]
|
|
|
|
then
|
|
|
|
read -p "A config file already exist, do you want to override it [Y/N]? "
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
config_generator
|
|
|
|
else
|
|
|
|
echo "Configuration of config.json ignored."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
config_generator
|
|
|
|
fi
|
|
|
|
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
|
|
|
echo "-------------------------"
|
|
|
|
echo "Config file generated"
|
|
|
|
echo "-------------------------"
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "Edit ./config.json to modify Pair and other configurations."
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function install () {
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "-------------------------"
|
|
|
|
echo "Install mandatory dependencies"
|
|
|
|
echo "-------------------------"
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2018-01-29 07:35:13 +00:00
|
|
|
if [ "$(uname -s)" == "Darwin" ]
|
|
|
|
then
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "macOS detected. Setup for this system in-progress"
|
2018-01-29 07:35:13 +00:00
|
|
|
install_macos
|
|
|
|
elif [ -x "$(command -v apt-get)" ]
|
|
|
|
then
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "Debian/Ubuntu detected. Setup for this system in-progress"
|
2018-01-29 07:35:13 +00:00
|
|
|
install_debian
|
|
|
|
else
|
|
|
|
echo "This script does not support your OS."
|
|
|
|
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."
|
|
|
|
sleep 10
|
|
|
|
fi
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2018-01-29 07:35:13 +00:00
|
|
|
reset
|
|
|
|
config
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "-------------------------"
|
|
|
|
echo "Run the bot"
|
|
|
|
echo "-------------------------"
|
|
|
|
echo "You can now use the bot by executing 'source .env/bin/activate; python3.6 freqtrade/main.py'."
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 07:24:41 +00:00
|
|
|
function plot () {
|
|
|
|
echo "
|
|
|
|
-----------------------------------------
|
|
|
|
Install dependencies for Plotting scripts
|
|
|
|
-----------------------------------------
|
|
|
|
"
|
2018-01-29 07:35:13 +00:00
|
|
|
pip install plotly --upgrade
|
2018-01-29 07:24:41 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 04:53:55 +00:00
|
|
|
function help () {
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "usage:"
|
|
|
|
echo " -i,--install Install freqtrade from scratch"
|
|
|
|
echo " -u,--update Command git pull to update."
|
|
|
|
echo " -r,--reset Hard reset your develop/master branch."
|
|
|
|
echo " -c,--config Easy config generator (Will override your existing file)."
|
|
|
|
echo " -p,--plot Install dependencies for Plotting scripts."
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case $* in
|
|
|
|
--install|-i)
|
|
|
|
install
|
|
|
|
;;
|
|
|
|
--config|-c)
|
|
|
|
config
|
|
|
|
;;
|
|
|
|
--update|-u)
|
|
|
|
update
|
|
|
|
;;
|
|
|
|
--reset|-r)
|
|
|
|
reset
|
|
|
|
;;
|
2018-01-29 07:24:41 +00:00
|
|
|
--plot|-p)
|
|
|
|
plot
|
|
|
|
;;
|
2018-01-29 04:53:55 +00:00
|
|
|
*)
|
|
|
|
help
|
|
|
|
;;
|
|
|
|
esac
|
2018-04-18 11:11:37 +00:00
|
|
|
exit 0
|