bbgo_origin/scripts/setup-grid.sh

116 lines
2.3 KiB
Bash
Raw Normal View History

2020-11-14 04:36:29 +00:00
#!/bin/bash
2021-03-13 11:47:20 +00:00
set -e
2020-11-14 04:36:29 +00:00
2021-03-13 11:56:44 +00:00
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
function warn()
{
echo -e "${YELLOW}$@${NC}"
}
function error()
{
echo -e "${RED}$@${NC}"
}
function info()
{
echo -e "${GREEN}$@${NC}"
}
2021-05-07 11:32:11 +00:00
osf=$(uname | tr '[:upper:]' '[:lower:]')
arch=amd64
2021-12-30 05:46:41 +00:00
version=v1.21.1
2021-05-07 11:32:11 +00:00
dist_file=bbgo-$version-$osf-$arch.tar.gz
2021-12-30 05:49:07 +00:00
exchange=max
if [[ -n $1 ]] ; then
exchange=$1
fi
exchange_upper=$(echo -n $exchange | tr 'a-z' 'A-Z')
2021-05-07 11:32:11 +00:00
2021-03-13 11:56:44 +00:00
info "downloading..."
2021-03-13 11:47:05 +00:00
curl -O -L https://github.com/c9s/bbgo/releases/download/$version/$dist_file
2021-03-13 11:42:07 +00:00
tar xzf $dist_file
2021-05-07 11:32:11 +00:00
mv bbgo-$osf-$arch bbgo
2020-11-14 04:36:29 +00:00
chmod +x bbgo
2021-03-13 11:56:44 +00:00
info "downloaded successfully"
2020-11-14 04:36:29 +00:00
2020-11-14 04:54:57 +00:00
function gen_dotenv()
{
2021-12-30 05:49:07 +00:00
read -p "Enter your $exchange_upper API key: " api_key
read -p "Enter your $exchange_upper API secret: " api_secret
2021-03-13 11:56:44 +00:00
info "generating your .env.local file..."
2020-11-14 04:45:44 +00:00
cat <<END > .env.local
2021-12-30 05:49:07 +00:00
${exchange_upper}_API_KEY=$api_key
${exchange_upper}_API_SECRET=$api_secret
2020-11-14 04:45:44 +00:00
END
2021-03-13 11:56:44 +00:00
info "dotenv is configured successfully"
2020-11-14 04:54:57 +00:00
}
if [[ -e ".env.local" ]] ; then
2021-03-13 11:56:44 +00:00
warn "found an existing .env.local, you will overwrite the existing .env.local file!"
read -p "are you sure? (Y/n) " a
2020-11-14 04:54:57 +00:00
if [[ $a != "n" ]] ; then
gen_dotenv
fi
else
gen_dotenv
fi
2020-11-14 04:36:29 +00:00
if [[ -e "bbgo.yaml" ]] ; then
2021-03-13 11:56:44 +00:00
warn "found existing bbgo.yaml, you will overwrite the existing bbgo.yaml file!"
read -p "are you sure? (Y/n) " a
2020-11-14 04:36:29 +00:00
if [[ $a == "n" ]] ; then
exit
fi
fi
cat <<END > bbgo.yaml
---
exchangeStrategies:
2021-12-30 05:49:07 +00:00
- on: ${exchange}
2020-11-14 04:36:29 +00:00
grid:
symbol: BTCUSDT
2021-03-13 11:42:07 +00:00
quantity: 0.001
2020-11-14 04:36:29 +00:00
gridNumber: 100
2021-03-13 11:42:07 +00:00
profitSpread: 100.0
upperPrice: 50_000.0
lowerPrice: 10_000.0
long: true
2020-11-14 04:36:29 +00:00
END
2021-03-13 11:56:44 +00:00
info "config file is generated successfully"
2021-03-13 11:59:03 +00:00
echo "================================================================"
echo "now you can edit your strategy config file bbgo.yaml to run bbgo"
2020-11-14 04:36:29 +00:00
if [[ $osf == "darwin" ]] ; then
2021-03-13 11:56:44 +00:00
echo "we found you're using MacOS, you can type:"
2020-11-14 04:36:29 +00:00
echo ""
echo " open -a TextEdit bbgo.yaml"
echo ""
2021-03-13 11:56:44 +00:00
else
echo "you look like a pro user, you can edit the config by:"
echo ""
echo " vim bbgo.yaml"
echo ""
2020-11-14 04:36:29 +00:00
fi
echo "To run bbgo just type: "
echo ""
2021-03-13 11:42:07 +00:00
echo " ./bbgo run"
2020-11-14 04:36:29 +00:00
echo ""
echo "To stop bbgo, just hit CTRL-C"
if [[ $osf == "darwin" ]] ; then
open -a TextEdit bbgo.yaml
fi