mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
refine the back-testing doc
This commit is contained in:
parent
ae7a2e714a
commit
142e5e9407
22
README.md
22
README.md
|
@ -118,24 +118,6 @@ To calculate pnl:
|
|||
bbgo pnl --exchange binance --asset BTC --since "2019-01-01"
|
||||
```
|
||||
|
||||
## Backtesting
|
||||
|
||||
To sync remote exchange klines data for backtesting:
|
||||
|
||||
```sh
|
||||
bbgo backtest --exchange binance -v --sync --sync-only --sync-from 2020-01-01
|
||||
```
|
||||
|
||||
To run backtest:
|
||||
|
||||
```sh
|
||||
bbgo backtest --exchange binance --base-asset-baseline
|
||||
```
|
||||
|
||||
Note on date formats, the following date formats are supported:
|
||||
* RFC3339, which looks like `2006-01-02T15:04:05Z07:00`
|
||||
* RFC822, which looks like `02 Jan 06 15:04 MST`
|
||||
* You can also use `2021-11-26T15:04:56`
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
|
@ -219,6 +201,10 @@ vim config/buyandhold.yaml
|
|||
bbgo run --config config/buyandhold.yaml
|
||||
```
|
||||
|
||||
## Back-testing
|
||||
|
||||
See [Back-testing](./doc/topics/back-testing.md)
|
||||
|
||||
## Adding New Built-in Strategy
|
||||
|
||||
Fork and clone this repository, Create a directory under `pkg/strategy/newstrategy`, write your strategy
|
||||
|
|
61
doc/topics/back-testing.md
Normal file
61
doc/topics/back-testing.md
Normal file
|
@ -0,0 +1,61 @@
|
|||
## Back-testing
|
||||
|
||||
First, you need to add the back-testing config to your `bbgo.yaml`:
|
||||
|
||||
```yaml
|
||||
backtest:
|
||||
# your back-test will start at the 2021-01-10, be sure to sync the data before 2021-01-10
|
||||
# because some indicator like EMA needs more data to calculate the current EMA value.
|
||||
startTime: "2021-01-10"
|
||||
|
||||
# your back-test will end at the 2021-01-10
|
||||
endTime: "2021-01-21"
|
||||
|
||||
# the symbol data that you want to sync and back-test
|
||||
symbols:
|
||||
- BTCUSDT
|
||||
|
||||
account:
|
||||
# the initial account balance you want to start with
|
||||
balances:
|
||||
BTC: 0.0
|
||||
USDT: 10000.0
|
||||
```
|
||||
|
||||
Note on date formats, the following date formats are supported:
|
||||
* RFC3339, which looks like `2006-01-02T15:04:05Z07:00`
|
||||
* RFC822, which looks like `02 Jan 06 15:04 MST`
|
||||
* You can also use `2021-11-26T15:04:56`
|
||||
|
||||
And then, you can sync remote exchange k-lines (candle bars) data for back-testing:
|
||||
|
||||
```sh
|
||||
bbgo backtest --exchange binance -v --sync --sync-only --sync-from 2020-11-01 --config config/grid.yaml
|
||||
```
|
||||
|
||||
Note that, you should sync from an earlier date before your startTime, here we sync one month before `2021-01-10`.
|
||||
|
||||
- `--sync` - sync the data to the latest data point before we start the back-test.
|
||||
- `--sync-only` - only the back-test data syncing will be executed. do not run back-test.
|
||||
- `--sync-from` - sync the data from a specific endpoint. note that, once you've start the sync, you can not simply add more data before the initial date.
|
||||
- `-v` - verbose message output
|
||||
- `--config config/grid.yaml` - use a specific config file instead of the default config file `./bbgo.yaml`
|
||||
|
||||
Run back-test:
|
||||
|
||||
```sh
|
||||
bbgo backtest --exchange binance --base-asset-baseline --config config/grid.yaml
|
||||
```
|
||||
|
||||
If you're developing a strategy, you might want to start with a command like this:
|
||||
|
||||
```shell
|
||||
godotenv -f .env.local -- go run ./cmd/bbgo backtest --exchange max --sync-from 2020-11-01 --config config/grid.yaml --base-asset-baseline
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
If you want to test the max draw down (MDD) you can adjust the start date to somewhere near 2020-03-12
|
||||
|
||||
See <https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp>
|
||||
|
Loading…
Reference in New Issue
Block a user