forked from c9s/bbgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request c9s#487 from zenixls2/update/release_script_dnum
update: readme for dnum. fix: script for curl downloading
- Loading branch information
Showing
11 changed files
with
470 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Dnum: High Precision Numeric Implementation | ||
---------------------------------------------- | ||
The `dnum` version of `fixedpoint` supports up to 16 digits of decimal precision. It's two times slower than the legacy version, which only supports up to 8 digits of decimal precision. We recommend that strategy developers do algorithmic calculations in `float64`, then convert them back to `fixedpoint` to interact with exchanges to keep the balance between speed and the accuracy of accounting result. | ||
|
||
To Install dnum version of bbgo, we've create several scripts for quick setup: | ||
|
||
```sh | ||
# grid trading strategy for binance exchange | ||
bash <(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-grid-dnum.sh) binance | ||
|
||
# grid trading strategy for max exchange | ||
bash <(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-grid-dnum.sh) max | ||
|
||
# bollinger grid trading strategy for binance exchange | ||
bash <(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-bollgrid-dnum.sh) binance | ||
|
||
# bollinger grid trading strategy for max exchange | ||
bash <(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-bollgrid-dnum.sh) max | ||
``` | ||
|
||
If you already have the configuration somewhere, you may want to use the download-only script: | ||
```sh | ||
bash <(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/download-dnum.sh) | ||
``` | ||
|
||
The precompiled dnum binaries are also available in the [Release Page](https://github.com/c9s/bbgo/releases). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
set -e | ||
version=$(curl -fs https://api.github.com/repos/c9s/bbgo/releases/latest | awk -F '"' '/tag_name/{print $4}') | ||
osf=$(uname | tr '[:upper:]' '[:lower:]') | ||
arch="" | ||
case $(uname -m) in | ||
x86_64 | ia64) arch="amd64";; | ||
arm64 | aarch64 | arm) arch="arm64";; | ||
*) | ||
echo "unsupported architecture: $(uname -m)" | ||
exit 1;; | ||
esac | ||
dist_file=bbgo-dnum-$version-$osf-$arch.tar.gz | ||
|
||
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}" | ||
} | ||
|
||
info "downloading..." | ||
curl -O -L https://github.com/c9s/bbgo/releases/download/$version/$dist_file | ||
tar xzf $dist_file | ||
mv bbgo-dnum-$osf-$arch bbgo | ||
chmod +x bbgo | ||
info "downloaded successfully" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
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}" | ||
} | ||
version=$(curl -fs https://api.github.com/repos/c9s/bbgo/releases/latest | awk -F '"' '/tag_name/{print $4}') | ||
osf=$(uname | tr '[:upper:]' '[:lower:]') | ||
arch="" | ||
case $(uname -m) in | ||
x86_64 | ia64) arch="amd64";; | ||
arm64 | aarch64 | arm) arch="arm64";; | ||
*) | ||
echo "unsupported architecture: $(uname -m)" | ||
exit 1;; | ||
esac | ||
dist_file=bbgo-dnum-$version-$osf-$arch.tar.gz | ||
|
||
info "downloading..." | ||
curl -O -L https://github.com/c9s/bbgo/releases/download/$version/$dist_file | ||
tar xzf $dist_file | ||
mv bbgo-dnum-$osf-$arch bbgo | ||
chmod +x bbgo | ||
info "downloaded successfully" | ||
|
||
function gen_dotenv() | ||
{ | ||
read -p "Enter your MAX API key: " api_key | ||
read -p "Enter your MAX API secret: " api_secret | ||
echo "Generating your .env.local file..." | ||
cat <<END > .env.local | ||
MAX_API_KEY=$api_key | ||
MAX_API_SECRET=$api_secret | ||
END | ||
|
||
} | ||
|
||
if [[ -e ".env.local" ]] ; then | ||
echo "Found existing .env.local, you will overwrite the existing .env.local file!" | ||
read -p "Are you sure? (Y/n) " a | ||
if [[ $a != "n" ]] ; then | ||
gen_dotenv | ||
fi | ||
else | ||
gen_dotenv | ||
fi | ||
|
||
if [[ -e "bbgo.yaml" ]] ; then | ||
echo "Found existing bbgo.yaml, you will overwrite the existing bbgo.yaml file!" | ||
read -p "Are you sure? (Y/n) " a | ||
if [[ $a == "n" ]] ; then | ||
exit | ||
fi | ||
fi | ||
|
||
cat <<END > bbgo.yaml | ||
--- | ||
exchangeStrategies: | ||
- on: max | ||
bollgrid: | ||
symbol: BTCUSDT | ||
interval: 1h | ||
gridNumber: 20 | ||
quantity: 0.001 | ||
profitSpread: 100.0 | ||
END | ||
|
||
info "config file is generated successfully" | ||
echo "================================================================" | ||
echo "now you can edit your strategy config file bbgo.yaml to run bbgo" | ||
|
||
if [[ $osf == "darwin" ]] ; then | ||
echo "we found you're using MacOS, you can type:" | ||
echo "" | ||
echo " open -a TextEdit bbgo.yaml" | ||
echo "" | ||
else | ||
echo "you look like a pro user, you can edit the config by:" | ||
echo "" | ||
echo " vim bbgo.yaml" | ||
echo "" | ||
fi | ||
|
||
echo "To run bbgo just type: " | ||
echo "" | ||
echo " ./bbgo run" | ||
echo "" | ||
echo "To stop bbgo, just hit CTRL-C" | ||
|
||
if [[ $osf == "darwin" ]] ; then | ||
open -a TextEdit bbgo.yaml | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/bin/bash | ||
set -e | ||
version=$(curl -fs https://api.github.com/repos/c9s/bbgo/releases/latest | awk -F '"' '/tag_name/{print $4}') | ||
osf=$(uname | tr '[:upper:]' '[:lower:]') | ||
arch="" | ||
case $(uname -m) in | ||
x86_64 | ia64) arch="amd64";; | ||
arm64 | aarch64 | arm) arch="arm64";; | ||
*) | ||
echo "unsupported architecture: $(uname -m)" | ||
exit 1;; | ||
esac | ||
dist_file=bbgo-dnum-$version-$osf-$arch.tar.gz | ||
|
||
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}" | ||
} | ||
|
||
info "downloading..." | ||
curl -O -L https://github.com/c9s/bbgo/releases/download/$version/$dist_file | ||
tar xzf $dist_file | ||
mv bbgo-dnum-$osf-$arch bbgo | ||
chmod +x bbgo | ||
info "downloaded successfully" | ||
|
||
if [[ -e "bbgo.yaml" ]] ; then | ||
echo "Found existing bbgo.yaml, you will overwrite the existing bbgo.yaml file!" | ||
read -p "Are you sure? (Y/n) " a | ||
if [[ $a == "n" ]] ; then | ||
exit | ||
fi | ||
fi | ||
|
||
cat <<END > bbgo.yaml | ||
--- | ||
riskControls: | ||
sessionBased: | ||
max: | ||
orderExecutor: | ||
bySymbol: | ||
BTCUSDT: | ||
# basic risk control order executor | ||
basic: | ||
minQuoteBalance: 100.0 | ||
maxBaseAssetBalance: 3.0 | ||
minBaseAssetBalance: 0.0 | ||
maxOrderAmount: 1000.0 | ||
exchangeStrategies: | ||
- on: max | ||
grid: | ||
symbol: BTCUSDT | ||
quantity: 0.002 | ||
gridNumber: 100 | ||
profitSpread: 50.0 | ||
upperPrice: 14000.0 | ||
lowerPrice: 11000.0 | ||
END | ||
|
||
echo "Config file is generated" | ||
|
||
if [[ -e ".env.local" ]] ; then | ||
echo "Found existing .env.local, you will overwrite the existing .env.local file!" | ||
read -p "Are you sure? (Y/n) " a | ||
if [[ $a == "n" ]] ; then | ||
exit | ||
fi | ||
fi | ||
|
||
read -p "Enter your MAX API key: " api_key | ||
|
||
read -p "Enter your MAX API secret: " api_secret | ||
|
||
echo "Generating your .env.local file..." | ||
cat <<END > .env.local | ||
export MAX_API_KEY=$api_key | ||
export MAX_API_SECRET=$api_secret | ||
END | ||
|
||
echo "Now you can edit your strategy config file bbgo.yaml to run bbgo" | ||
|
||
if [[ $osf == "darwin" ]] ; then | ||
echo "We found you're using MacOS, you can type:" | ||
echo "" | ||
echo " open -a TextEdit bbgo.yaml" | ||
echo "" | ||
fi | ||
|
||
echo "To run bbgo just type: " | ||
echo "" | ||
echo " source .env.local && ./bbgo run --config bbgo.yaml" | ||
echo "" | ||
echo "To stop bbgo, just hit CTRL-C" | ||
|
||
if [[ $osf == "darwin" ]] ; then | ||
open -a TextEdit bbgo.yaml | ||
fi | ||
|
Oops, something went wrong.