mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add more details to the readme
This commit is contained in:
parent
062a008674
commit
89fdc313e0
146
README.md
146
README.md
|
@ -57,13 +57,6 @@ go get -u github.com/c9s/bbgo/cmd/bbgo
|
|||
Add your dotenv file:
|
||||
|
||||
```
|
||||
# optional
|
||||
SLACK_TOKEN=
|
||||
|
||||
# optional
|
||||
TELEGRAM_BOT_TOKEN=
|
||||
TELEGRAM_BOT_AUTH_TOKEN=
|
||||
|
||||
# if you have one
|
||||
BINANCE_API_KEY=
|
||||
BINANCE_API_SECRET=
|
||||
|
@ -77,14 +70,12 @@ FTX_API_KEY=
|
|||
FTX_API_SECRET=
|
||||
# specify it if credentials are for subaccount
|
||||
FTX_SUBACCOUNT=
|
||||
|
||||
# optional, if you have the db setup
|
||||
MYSQL_URL=root@tcp(127.0.0.1:3306)/bbgo?parseTime=true
|
||||
```
|
||||
|
||||
Prepare your dotenv file `.env.local` and BBGO yaml config file `bbgo.yaml`.
|
||||
|
||||
The minimal bbgo.yaml could be generated by:
|
||||
|
||||
```shell
|
||||
mkdir config
|
||||
(cd config && curl -o bbgo.yaml https://raw.githubusercontent.com/c9s/bbgo/main/config/minimal.yaml)
|
||||
|
@ -103,7 +94,6 @@ If you want to switch to other dotenv file, you can add an `--dotenv` option or
|
|||
bbgo sync --dotenv .env.dev --config config/grid.yaml --session binance
|
||||
```
|
||||
|
||||
|
||||
To sync remote exchange klines data for backtesting:
|
||||
|
||||
```sh
|
||||
|
@ -116,7 +106,6 @@ To run backtest:
|
|||
bbgo backtest --exchange binance --base-asset-baseline
|
||||
```
|
||||
|
||||
|
||||
To query transfer history:
|
||||
|
||||
```sh
|
||||
|
@ -135,19 +124,101 @@ To run strategy:
|
|||
bbgo run
|
||||
```
|
||||
|
||||
## Advanced Setup
|
||||
|
||||
### Setting up Telegram Bot Notification
|
||||
|
||||
Open your Telegram app, and chat with @botFather
|
||||
|
||||
Enter `/newbot` to create a new bot
|
||||
|
||||
Enter the bot display name. ex. `your_bbgo_bot`
|
||||
|
||||
Enter the bot username. This should be global unique. e.g., `bbgo_bot_711222333`
|
||||
|
||||
Botfather will response your a bot token. *Keep bot token safe*
|
||||
|
||||
Set `TELEGRAM_BOT_TOKEN` in the `.env.local` file, e.g.,
|
||||
|
||||
```shell
|
||||
TELEGRAM_BOT_TOKEN=347374838:ABFTjfiweajfiawoejfiaojfeijoaef
|
||||
```
|
||||
|
||||
For the telegram chat authentication (your bot needs to verify it's you), if you only need a fixed authentication token,
|
||||
you can set `TELEGRAM_AUTH_TOKEN` in the `.env.local` file, e.g.,
|
||||
|
||||
```shell
|
||||
TELEGRAM_BOT_AUTH_TOKEN=itsme55667788
|
||||
```
|
||||
|
||||
Run your bbgo,
|
||||
|
||||
Open your Telegram app, search your bot `bbgo_bot_711222333`
|
||||
|
||||
Enter `/start` and `/auth {code}`
|
||||
|
||||
Done! your notifications will be routed to the telegram chat.
|
||||
|
||||
### Setting up Slack Notification
|
||||
|
||||
Put your slack bot token in the .env.local file:
|
||||
|
||||
```shell
|
||||
SLACK_TOKEN=xxoox
|
||||
```
|
||||
|
||||
### Synchronizing Trading Data
|
||||
|
||||
By synchronizing trades and orders to the local database, you can earn some benefits like PnL calculations, backtesting
|
||||
and asset calculation.
|
||||
|
||||
#### Configure MySQL Database
|
||||
|
||||
To use MySQL database for data syncing, first you need to install your mysql server:
|
||||
|
||||
```shell
|
||||
# For Ubuntu Linux
|
||||
sudo apt-get install -y mysql-server
|
||||
```
|
||||
|
||||
Create your mysql database:
|
||||
|
||||
```shell
|
||||
mysql -uroot -e "CREATE DATABASE bbgo CHARSET utf8"
|
||||
```
|
||||
|
||||
Then put these environment variables in your `.env.local` file:
|
||||
|
||||
```shell
|
||||
DB_DRIVER=mysql
|
||||
DB_DSN=root@tcp(127.0.0.1:3306)/bbgo
|
||||
```
|
||||
|
||||
#### Configure Sqlite3 Database
|
||||
|
||||
Just put these environment variables in your `.env.local` file:
|
||||
|
||||
```shell
|
||||
DB_DRIVER=sqlite3
|
||||
DB_DSN=bbgo.sqlite3
|
||||
```
|
||||
|
||||
## Built-in Strategies
|
||||
|
||||
Check out the strategy directory [strategy](pkg/strategy) for all built-in strategies:
|
||||
|
||||
- `pricealert` strategy demonstrates how to use the notification system [pricealert](pkg/strategy/pricealert)
|
||||
- `xpuremaker` strategy demonstrates how to maintain the orderbook and submit maker orders [xpuremaker](pkg/strategy/xpuremaker)
|
||||
- `buyandhold` strategy demonstrates how to subscribe kline events and submit market order [buyandhold](pkg/strategy/buyandhold)
|
||||
- `bollgrid` strategy implements a basic grid strategy with the built-in bollinger indicator [bollgrid](pkg/strategy/bollgrid)
|
||||
- `xpuremaker` strategy demonstrates how to maintain the orderbook and submit maker
|
||||
orders [xpuremaker](pkg/strategy/xpuremaker)
|
||||
- `buyandhold` strategy demonstrates how to subscribe kline events and submit market
|
||||
order [buyandhold](pkg/strategy/buyandhold)
|
||||
- `bollgrid` strategy implements a basic grid strategy with the built-in bollinger
|
||||
indicator [bollgrid](pkg/strategy/bollgrid)
|
||||
- `grid` strategy implements the fixed price band grid strategy [grid](pkg/strategy/grid)
|
||||
- `flashcrash` strategy implements a strategy that catches the flashcrash [flashcrash](pkg/strategy/flashcrash)
|
||||
|
||||
To run these built-in strategies, just
|
||||
modify the config file to make the configuration suitable for you, for example if you want to run
|
||||
To run these built-in strategies, just modify the config file to make the configuration suitable for you, for example if
|
||||
you want to run
|
||||
`buyandhold` strategy:
|
||||
|
||||
```sh
|
||||
|
@ -214,12 +285,12 @@ bbgo build --config config/bbgo.yaml
|
|||
|
||||
In order to minimize the strategy code, bbgo supports dynamic dependency injection.
|
||||
|
||||
Before executing your strategy, bbgo injects the components into your strategy object if
|
||||
it found the embedded field that is using bbgo component. for example:
|
||||
Before executing your strategy, bbgo injects the components into your strategy object if it found the embedded field
|
||||
that is using bbgo component. for example:
|
||||
|
||||
```go
|
||||
type Strategy struct {
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Notifiability
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -230,14 +301,12 @@ Supported components (single exchange strategy only for now):
|
|||
- `*bbgo.Notifiability`
|
||||
- `bbgo.OrderExecutor`
|
||||
|
||||
|
||||
If you have `Symbol string` field in your strategy, your strategy will be detected as a symbol-based strategy,
|
||||
then the following types could be injected automatically:
|
||||
If you have `Symbol string` field in your strategy, your strategy will be detected as a symbol-based strategy, then the
|
||||
following types could be injected automatically:
|
||||
|
||||
- `*bbgo.ExchangeSession`
|
||||
- `types.Market`
|
||||
|
||||
|
||||
## Strategy Execution Phases
|
||||
|
||||
1. Load config from the config file.
|
||||
|
@ -275,21 +344,6 @@ streambook.BindStream(stream)
|
|||
|
||||
(TBD)
|
||||
|
||||
## Telegram Integration
|
||||
|
||||
- In telegram: @botFather
|
||||
- /newbot
|
||||
- input bot display name. ex. `bbgo_bot`
|
||||
- input bot username. This should be global unique. ex. `PeqFqJxP_bbgo_bot`
|
||||
- Botfather return bot token. Keep bot token safe
|
||||
- Set `TELEGRAM_BOT_TOKEN` in `.env.local`
|
||||
- Set `TELEGRAM_AUTH_TOKEN` in `.env.local`. Generate your own auth token. ex. 92463901, or kx2UX@eM
|
||||
- Run bbgo
|
||||
- In telegram: search your bot `PeqFqJxP_bbgo_bot`
|
||||
- /start
|
||||
- /auth 92463901
|
||||
- done! your session will route to telegram
|
||||
|
||||
## Helm Chart
|
||||
|
||||
Prepare your docker image locally (you can also use the docker image from docker hub):
|
||||
|
@ -306,16 +360,15 @@ Prepare your secret:
|
|||
kubectl create secret generic bbgo-grid --from-env-file .env.local
|
||||
```
|
||||
|
||||
Configure your config file, the chart defaults to read config/bbgo.yaml to
|
||||
create a configmap:
|
||||
Configure your config file, the chart defaults to read config/bbgo.yaml to create a configmap:
|
||||
|
||||
```
|
||||
cp config/grid.yaml config/bbgo.yaml
|
||||
vim config/bbgo.yaml
|
||||
```
|
||||
|
||||
Install chart with the preferred release name, the release name maps to the
|
||||
previous secret we just created, that is, `bbgo-grid`:
|
||||
Install chart with the preferred release name, the release name maps to the previous secret we just created, that
|
||||
is, `bbgo-grid`:
|
||||
|
||||
```
|
||||
helm install bbgo-grid ./charts/bbgo
|
||||
|
@ -335,7 +388,7 @@ helm delete bbgo
|
|||
2. Clone your forked repository into `$GOPATH/github.com/c9s/bbgo`.
|
||||
3. Change directory into `$GOPATH/github.com/c9s/bbgo`.
|
||||
4. Create a branch and start your development.
|
||||
5. Test your changes.
|
||||
5. Test your changes.
|
||||
6. Push your changes to your fork.
|
||||
7. Send a pull request.
|
||||
|
||||
|
@ -382,7 +435,6 @@ for lorca
|
|||
make embed && go run -tags web ./cmd/bbgo-lorca
|
||||
```
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
### By contributing pull requests
|
||||
|
@ -401,14 +453,14 @@ You may register your exchange account with my referral ID to support this proje
|
|||
- BTC address `3J6XQJNWT56amqz9Hz2BEVQ7W4aNmb5kiU`
|
||||
- USDT ERC20 address `0x63E5805e027548A384c57E20141f6778591Bac6F`
|
||||
|
||||
|
||||
## Community
|
||||
|
||||
You can join our telegram channel <https://t.me/bbgocrypto>, it's in Chinese, but English is fine as well.
|
||||
|
||||
## Contribution
|
||||
|
||||
BBGO has a token BBG for the ecosystem (contract address: <https://etherscan.io/address/0x3afe98235d680e8d7a52e1458a59d60f45f935c0>).
|
||||
BBGO has a token BBG for the ecosystem (contract
|
||||
address: <https://etherscan.io/address/0x3afe98235d680e8d7a52e1458a59d60f45f935c0>).
|
||||
|
||||
Each issue has its BBG label, by completing the issue with a pull request, you can get correspond amount of BBG.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user