2018-01-29 04:53:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#encoding=utf8
|
|
|
|
|
2019-06-24 05:10:24 +00:00
|
|
|
function check_installed_pip() {
|
|
|
|
${PYTHON} -m pip > /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
2019-06-27 04:20:22 +00:00
|
|
|
echo "pip not found (called as '${PYTHON} -m pip'). Please make sure that pip is available for ${PYTHON}."
|
2019-06-24 05:10:24 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-08-12 08:37:10 +00:00
|
|
|
# Check which python version is installed
|
|
|
|
function check_installed_python() {
|
2019-08-07 19:44:47 +00:00
|
|
|
if [ -n "${VIRTUAL_ENV}" ]; then
|
|
|
|
echo "Please deactivate your virtual environment before running setup.sh."
|
|
|
|
echo "You can do this by running 'deactivate'."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2020-02-01 13:59:14 +00:00
|
|
|
which python3.8
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "using Python 3.8"
|
|
|
|
PYTHON=python3.8
|
|
|
|
check_installed_pip
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2020-12-14 18:18:54 +00:00
|
|
|
which python3.9
|
2018-08-12 08:37:10 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2020-12-14 18:18:54 +00:00
|
|
|
echo "using Python 3.9"
|
|
|
|
PYTHON=python3.9
|
2019-06-24 05:10:24 +00:00
|
|
|
check_installed_pip
|
2018-08-12 08:37:10 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2020-12-14 18:18:54 +00:00
|
|
|
which python3.7
|
2018-08-12 08:37:10 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2020-12-14 18:18:54 +00:00
|
|
|
echo "using Python 3.7"
|
|
|
|
PYTHON=python3.7
|
2019-06-24 05:10:24 +00:00
|
|
|
check_installed_pip
|
2018-08-12 08:37:10 +00:00
|
|
|
return
|
2020-12-14 18:18:54 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-12 08:37:10 +00:00
|
|
|
|
2019-01-05 18:50:46 +00:00
|
|
|
if [ -z ${PYTHON} ]; then
|
2020-12-14 19:18:34 +00:00
|
|
|
echo "No usable python found. Please make sure to have python3.7 or newer installed"
|
2019-01-05 18:50:46 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-08-12 08:37:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function updateenv() {
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "-------------------------"
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Updating your virtual env"
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "-------------------------"
|
2019-08-07 19:19:16 +00:00
|
|
|
if [ ! -f .env/bin/activate ]; then
|
|
|
|
echo "Something went wrong, no virtual environment found."
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-01-29 07:35:13 +00:00
|
|
|
source .env/bin/activate
|
2020-11-30 20:10:11 +00:00
|
|
|
SYS_ARCH=$(uname -m)
|
2019-06-24 05:10:24 +00:00
|
|
|
echo "pip install in-progress. Please wait..."
|
2019-08-07 19:03:03 +00:00
|
|
|
${PYTHON} -m pip install --upgrade pip
|
2019-01-06 11:02:57 +00:00
|
|
|
read -p "Do you want to install dependencies for dev [y/N]? "
|
2018-12-02 13:08:00 +00:00
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
2020-11-30 19:56:14 +00:00
|
|
|
REQUIREMENTS=requirements-dev.txt
|
2018-12-02 13:08:00 +00:00
|
|
|
else
|
2020-11-30 19:56:14 +00:00
|
|
|
REQUIREMENTS=requirements.txt
|
|
|
|
fi
|
2020-11-30 20:10:11 +00:00
|
|
|
REQUIREMENTS_HYPEROPT=""
|
2020-11-30 20:17:50 +00:00
|
|
|
REQUIREMENTS_PLOT=""
|
|
|
|
read -p "Do you want to install plotting dependencies (plotly) [y/N]? "
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
REQUIREMENTS_PLOT="-r requirements-plot.txt"
|
|
|
|
fi
|
|
|
|
if [ "${SYS_ARCH}" == "armv7l" ]; then
|
|
|
|
echo "Detected Raspberry, installing cython, skipping hyperopt installation."
|
|
|
|
${PYTHON} -m pip install --upgrade cython
|
|
|
|
else
|
2020-11-30 20:10:11 +00:00
|
|
|
# Is not Raspberry
|
2020-11-30 20:17:50 +00:00
|
|
|
read -p "Do you want to install hyperopt dependencies [y/N]? "
|
2020-11-30 20:10:11 +00:00
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
REQUIREMENTS_HYPEROPT="-r requirements-hyperopt.txt"
|
|
|
|
fi
|
2018-12-02 13:08:00 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-30 20:17:50 +00:00
|
|
|
${PYTHON} -m pip install --upgrade -r ${REQUIREMENTS} ${REQUIREMENTS_HYPEROPT} ${REQUIREMENTS_PLOT}
|
2020-11-30 19:56:14 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed installing dependencies"
|
|
|
|
exit 1
|
2018-12-02 13:08:00 +00:00
|
|
|
fi
|
2019-06-24 05:10:24 +00:00
|
|
|
${PYTHON} -m pip install -e .
|
2020-11-30 19:56:14 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed installing Freqtrade"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-06-24 05:10:24 +00:00
|
|
|
echo "pip install completed"
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install tab lib
|
2019-01-05 19:00:10 +00:00
|
|
|
function install_talib() {
|
2019-01-05 18:51:51 +00:00
|
|
|
if [ -f /usr/local/lib/libta_lib.a ]; then
|
|
|
|
echo "ta-lib already installed, skipping"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2019-01-02 18:26:58 +00:00
|
|
|
cd build_helpers
|
2018-01-29 07:35:13 +00:00
|
|
|
tar zxvf ta-lib-0.4.0-src.tar.gz
|
2018-10-11 17:26:19 +00:00
|
|
|
cd ta-lib
|
|
|
|
sed -i.bak "s|0.00000001|0.000000000000000001 |g" src/ta_func/ta_utility.h
|
|
|
|
./configure --prefix=/usr/local
|
|
|
|
make
|
|
|
|
sudo make install
|
2019-08-07 19:35:52 +00:00
|
|
|
if [ -x "$(command -v apt-get)" ]; then
|
|
|
|
echo "Updating library path using ldconfig"
|
|
|
|
sudo ldconfig
|
|
|
|
fi
|
2018-10-23 17:36:57 +00:00
|
|
|
cd .. && rm -rf ./ta-lib/
|
2019-01-02 18:26:58 +00:00
|
|
|
cd ..
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install bot MacOS
|
2019-01-05 19:00:10 +00:00
|
|
|
function install_macos() {
|
2018-01-29 07:35:13 +00:00
|
|
|
if [ ! -x "$(command -v brew)" ]
|
|
|
|
then
|
|
|
|
echo "-------------------------"
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Installing Brew"
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "-------------------------"
|
|
|
|
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
|
|
fi
|
2018-10-11 17:26:19 +00:00
|
|
|
install_talib
|
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
|
2019-01-05 19:00:10 +00:00
|
|
|
function install_debian() {
|
2018-01-29 07:35:13 +00:00
|
|
|
sudo apt-get update
|
2019-08-07 19:03:03 +00:00
|
|
|
sudo apt-get install -y build-essential autoconf libtool pkg-config make wget git
|
2018-01-29 07:35:13 +00:00
|
|
|
install_talib
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Upgrade the bot
|
2019-01-05 19:00:10 +00:00
|
|
|
function update() {
|
2018-01-29 07:35:13 +00:00
|
|
|
git pull
|
|
|
|
updateenv
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
2020-09-20 09:45:08 +00:00
|
|
|
# Reset Develop or Stable branch
|
2019-01-05 19:00:10 +00:00
|
|
|
function reset() {
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "----------------------------"
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Reseting branch and virtual env"
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "----------------------------"
|
2019-08-07 19:45:58 +00:00
|
|
|
|
2020-09-20 09:45:08 +00:00
|
|
|
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* stable") ]
|
2018-01-29 04:53:55 +00:00
|
|
|
then
|
2018-01-29 07:35:13 +00:00
|
|
|
|
2019-08-07 19:45:58 +00:00
|
|
|
read -p "Reset git branch? (This will remove all changes you made!) [y/N]? "
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
2018-01-29 07:35:13 +00:00
|
|
|
|
2019-08-07 19:45:58 +00:00
|
|
|
git fetch -a
|
|
|
|
|
2020-11-30 19:56:14 +00:00
|
|
|
if [ "1" == $(git branch -vv | grep -c "* develop") ]
|
2019-08-07 19:45:58 +00:00
|
|
|
then
|
|
|
|
echo "- Hard resetting of 'develop' branch."
|
|
|
|
git reset --hard origin/develop
|
2020-11-30 19:56:14 +00:00
|
|
|
elif [ "1" == $(git branch -vv | grep -c "* stable") ]
|
2019-08-07 19:45:58 +00:00
|
|
|
then
|
2020-09-20 09:45:08 +00:00
|
|
|
echo "- Hard resetting of 'stable' branch."
|
|
|
|
git reset --hard origin/stable
|
2019-08-07 19:45:58 +00:00
|
|
|
fi
|
2018-01-29 07:35:13 +00:00
|
|
|
fi
|
|
|
|
else
|
2020-09-20 09:45:08 +00:00
|
|
|
echo "Reset ignored because you are not on 'stable' or 'develop'."
|
2018-01-29 04:53:55 +00:00
|
|
|
fi
|
|
|
|
|
2019-08-07 19:45:58 +00:00
|
|
|
if [ -d ".env" ]; then
|
2020-11-30 19:56:14 +00:00
|
|
|
echo "- Deleting your previous virtual env"
|
2019-08-07 19:45:58 +00:00
|
|
|
rm -rf .env
|
|
|
|
fi
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2018-08-12 08:37:10 +00:00
|
|
|
${PYTHON} -m venv .env
|
2019-08-07 19:03:03 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Could not create virtual environment. Leaving now"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-01-29 07:35:13 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function config_generator() {
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "Starting to generate config.json"
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Generating General configuration"
|
2018-01-29 07:35:13 +00:00
|
|
|
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
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Generating exchange config "
|
2018-05-30 03:48:34 +00:00
|
|
|
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
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Generating Telegram config"
|
2018-01-29 07:35:13 +00:00
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function config() {
|
2018-05-30 03:48:34 +00:00
|
|
|
|
|
|
|
echo "-------------------------"
|
2020-02-09 10:41:29 +00:00
|
|
|
echo "Please use 'freqtrade new-config -c config.json' to generate a new configuration file."
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "-------------------------"
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function install() {
|
2018-01-29 07:35:13 +00:00
|
|
|
echo "-------------------------"
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Installing mandatory dependencies"
|
2018-01-29 07:35:13 +00:00
|
|
|
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."
|
2018-08-12 08:37:10 +00:00
|
|
|
echo "If you have Python3.6 or Python3.7, pip, virtualenv, ta-lib you can continue."
|
2018-01-29 07:35:13 +00:00
|
|
|
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 "-------------------------"
|
2019-01-06 11:02:57 +00:00
|
|
|
echo "Run the bot !"
|
2018-05-30 03:48:34 +00:00
|
|
|
echo "-------------------------"
|
2020-04-25 14:55:13 +00:00
|
|
|
echo "You can now use the bot by executing 'source .env/bin/activate; freqtrade <subcommand>'."
|
2020-11-30 19:56:14 +00:00
|
|
|
echo "You can see the list of available bot sub-commands by executing 'source .env/bin/activate; freqtrade --help'."
|
2020-04-25 14:32:11 +00:00
|
|
|
echo "You verify that freqtrade is installed successfully by running 'source .env/bin/activate; freqtrade --version'."
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function plot() {
|
2018-01-29 07:24:41 +00:00
|
|
|
echo "
|
|
|
|
-----------------------------------------
|
2019-01-06 11:02:57 +00:00
|
|
|
Installing dependencies for Plotting scripts
|
2018-01-29 07:24:41 +00:00
|
|
|
-----------------------------------------
|
|
|
|
"
|
2019-06-24 05:10:24 +00:00
|
|
|
${PYTHON} -m pip install plotly --upgrade
|
2018-01-29 07:24:41 +00:00
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +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."
|
2020-09-20 09:45:08 +00:00
|
|
|
echo " -r,--reset Hard reset your develop/stable branch."
|
2018-01-29 07:35:13 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-12-14 18:18:54 +00:00
|
|
|
# Verify if 3.7 or 3.8 is installed
|
2018-08-12 08:37:10 +00:00
|
|
|
check_installed_python
|
|
|
|
|
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
|