2018-01-29 04:53:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#encoding=utf8
|
|
|
|
|
2021-10-25 05:27:08 +00:00
|
|
|
function echo_block() {
|
|
|
|
echo "----------------------------"
|
|
|
|
echo $1
|
|
|
|
echo "----------------------------"
|
|
|
|
}
|
|
|
|
|
2019-06-24 05:10:24 +00:00
|
|
|
function check_installed_pip() {
|
|
|
|
${PYTHON} -m pip > /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Installing Pip for ${PYTHON}"
|
2021-07-19 21:01:32 +00:00
|
|
|
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
|
|
|
${PYTHON} get-pip.py
|
|
|
|
rm get-pip.py
|
2019-06-24 05:10:24 +00:00
|
|
|
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
|
|
|
|
|
2022-05-15 17:22:12 +00:00
|
|
|
for v in 10 9 8
|
2021-07-15 07:03:32 +00:00
|
|
|
do
|
2021-07-15 01:25:51 +00:00
|
|
|
PYTHON="python3.${v}"
|
|
|
|
which $PYTHON
|
|
|
|
if [ $? -eq 0 ]; then
|
2021-07-15 02:01:43 +00:00
|
|
|
echo "using ${PYTHON}"
|
2021-07-15 01:25:51 +00:00
|
|
|
check_installed_pip
|
|
|
|
return
|
|
|
|
fi
|
2021-10-17 17:23:51 +00:00
|
|
|
done
|
2021-07-15 01:25:51 +00:00
|
|
|
|
2022-02-05 21:19:42 +00:00
|
|
|
echo "No usable python found. Please make sure to have python3.8 or newer installed."
|
2021-07-15 01:25:51 +00:00
|
|
|
exit 1
|
2018-08-12 08:37:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function updateenv() {
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Updating your virtual env"
|
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..."
|
2023-02-01 09:20:40 +00:00
|
|
|
# Setuptools 65.5.0 is the last version that can install gym==0.21.0
|
|
|
|
${PYTHON} -m pip install --upgrade pip wheel setuptools==65.5.0
|
2019-01-06 11:02:57 +00:00
|
|
|
read -p "Do you want to install dependencies for dev [y/N]? "
|
2022-04-05 04:51:07 +00:00
|
|
|
dev=$REPLY
|
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=""
|
2023-01-31 15:09:14 +00:00
|
|
|
read -p "Do you want to install plotting dependencies (plotly) [y/N]? "
|
2020-11-30 20:17:50 +00:00
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
REQUIREMENTS_PLOT="-r requirements-plot.txt"
|
|
|
|
fi
|
2021-09-17 16:03:54 +00:00
|
|
|
if [ "${SYS_ARCH}" == "armv7l" ] || [ "${SYS_ARCH}" == "armv6l" ]; then
|
2020-11-30 20:17:50 +00:00
|
|
|
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
|
|
|
|
|
2022-07-20 10:56:46 +00:00
|
|
|
REQUIREMENTS_FREQAI=""
|
2022-10-05 13:58:54 +00:00
|
|
|
REQUIREMENTS_FREQAI_RL=""
|
2022-07-20 10:56:46 +00:00
|
|
|
read -p "Do you want to install dependencies for freqai [y/N]? "
|
|
|
|
dev=$REPLY
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
2022-11-23 15:34:50 +00:00
|
|
|
REQUIREMENTS_FREQAI="-r requirements-freqai.txt --use-pep517"
|
2022-10-05 13:58:54 +00:00
|
|
|
read -p "Do you also want dependencies for freqai-rl (~700mb additional space required) [y/N]? "
|
|
|
|
dev=$REPLY
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
REQUIREMENTS_FREQAI="-r requirements-freqai-rl.txt"
|
|
|
|
fi
|
2022-07-20 10:56:46 +00:00
|
|
|
fi
|
|
|
|
|
2022-10-05 13:58:54 +00:00
|
|
|
${PYTHON} -m pip install --upgrade -r ${REQUIREMENTS} ${REQUIREMENTS_HYPEROPT} ${REQUIREMENTS_PLOT} ${REQUIREMENTS_FREQAI} ${REQUIREMENTS_FREQAI_RL}
|
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
|
2022-06-11 16:02:03 +00:00
|
|
|
|
|
|
|
echo "Installing freqUI"
|
|
|
|
freqtrade install-ui
|
|
|
|
|
2019-06-24 05:10:24 +00:00
|
|
|
echo "pip install completed"
|
2018-05-30 03:48:34 +00:00
|
|
|
echo
|
2022-04-09 09:53:47 +00:00
|
|
|
if [[ $dev =~ ^[Yy]$ ]]; then
|
2022-04-23 15:05:41 +00:00
|
|
|
${PYTHON} -m pre_commit install
|
2022-04-05 04:51:07 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed installing pre-commit"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-04-09 09:53:47 +00:00
|
|
|
fi
|
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
|
|
|
|
|
2021-10-17 17:23:51 +00:00
|
|
|
cd build_helpers && ./install_ta-lib.sh
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Quitting. Please fix the above error before continuing."
|
|
|
|
cd ..
|
|
|
|
exit 1
|
|
|
|
fi;
|
|
|
|
|
|
|
|
cd ..
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-17 17:23:51 +00:00
|
|
|
function install_mac_newer_python_dependencies() {
|
|
|
|
|
2021-07-15 01:20:12 +00:00
|
|
|
if [ ! $(brew --prefix --installed hdf5 2>/dev/null) ]
|
|
|
|
then
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Installing hdf5"
|
2021-07-15 01:20:12 +00:00
|
|
|
brew install hdf5
|
|
|
|
fi
|
2021-08-29 08:34:01 +00:00
|
|
|
export HDF5_DIR=$(brew --prefix)
|
2021-07-15 01:20:12 +00:00
|
|
|
|
|
|
|
if [ ! $(brew --prefix --installed c-blosc 2>/dev/null) ]
|
|
|
|
then
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Installing c-blosc"
|
2021-07-15 01:20:12 +00:00
|
|
|
brew install c-blosc
|
2021-10-17 17:23:51 +00:00
|
|
|
fi
|
2021-08-29 08:34:01 +00:00
|
|
|
export CBLOSC_DIR=$(brew --prefix)
|
2021-07-15 01:20:12 +00:00
|
|
|
}
|
|
|
|
|
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
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Installing Brew"
|
2018-01-29 07:35:13 +00:00
|
|
|
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
|
|
fi
|
2022-03-01 23:36:11 +00:00
|
|
|
|
|
|
|
brew install gettext
|
|
|
|
|
2021-07-15 01:20:12 +00:00
|
|
|
#Gets number after decimal in python version
|
2021-07-19 21:01:32 +00:00
|
|
|
version=$(egrep -o 3.\[0-9\]+ <<< $PYTHON | sed 's/3.//g')
|
2021-10-17 17:23:51 +00:00
|
|
|
|
2021-07-15 01:20:12 +00:00
|
|
|
if [[ $version -ge 9 ]]; then #Checks if python version >= 3.9
|
|
|
|
install_mac_newer_python_dependencies
|
|
|
|
fi
|
2018-10-11 17:26:19 +00:00
|
|
|
install_talib
|
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
|
2022-05-02 22:20:13 +00:00
|
|
|
sudo apt-get install -y gcc build-essential autoconf libtool pkg-config make wget git curl $(echo lib${PYTHON}-dev ${PYTHON}-venv)
|
2021-10-25 05:33:02 +00:00
|
|
|
install_talib
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install bot RedHat_CentOS
|
|
|
|
function install_redhat() {
|
|
|
|
sudo yum update
|
2021-11-04 06:44:58 +00:00
|
|
|
sudo yum install -y gcc gcc-c++ make autoconf libtool pkg-config wget git $(echo ${PYTHON}-devel | sed 's/\.//g')
|
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() {
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Resetting branch and virtual env"
|
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
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function config() {
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Please use 'freqtrade new-config -c config.json' to generate a new configuration file."
|
2018-01-29 04:53:55 +00:00
|
|
|
}
|
|
|
|
|
2019-01-05 19:00:10 +00:00
|
|
|
function install() {
|
2021-12-11 09:01:24 +00:00
|
|
|
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Installing mandatory dependencies"
|
2018-01-29 04:53:55 +00:00
|
|
|
|
2021-10-25 05:33:02 +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
|
2021-10-25 05:33:02 +00:00
|
|
|
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
|
2021-10-25 05:33:02 +00:00
|
|
|
elif [ -x "$(command -v yum)" ]; then
|
|
|
|
echo "Red Hat/CentOS detected. Setup for this system in-progress"
|
|
|
|
install_redhat
|
2018-01-29 07:35:13 +00:00
|
|
|
else
|
|
|
|
echo "This script does not support your OS."
|
2022-01-24 15:29:56 +00:00
|
|
|
echo "If you have Python version 3.8 - 3.10, 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
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Run the bot !"
|
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() {
|
2021-10-25 05:27:08 +00:00
|
|
|
echo_block "Installing dependencies for Plotting scripts"
|
2021-07-19 21:01:32 +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
|
|
|
}
|
|
|
|
|
2022-01-24 15:29:56 +00:00
|
|
|
# Verify if 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
|