update doc

This commit is contained in:
c9s 2022-07-04 12:02:13 +08:00
parent 9fbe2e859e
commit 69179ab66f
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 49 additions and 113 deletions

158
README.md
View File

@ -30,7 +30,8 @@ You can use BBGO's trading unit and back-test unit to implement your own strateg
### Trading Unit Developers 🧑‍💻
You can use BBGO's underlying common exchange API, currently it supports 4+ major exchanges, so you don't have to repeat the implementation.
You can use BBGO's underlying common exchange API, currently it supports 4+ major exchanges, so you don't have to repeat
the implementation.
## Features
@ -44,37 +45,38 @@ You can use BBGO's underlying common exchange API, currently it supports 4+ majo
- Built-in parameter optimization tool.
- Built-in Grid strategy and many other built-in strategies.
- Multi-exchange session support: you can connect to more than 2 exchanges with different accounts or subaccounts.
- Indicators with interface similar to `pandas.Series`([series](https://github.com/c9s/bbgo/blob/main/doc/development/series.md))([usage](https://github.com/c9s/bbgo/blob/main/doc/development/indicator.md)):
- [Accumulation/Distribution Indicator](./pkg/indicator/ad.go)
- [Arnaud Legoux Moving Average](./pkg/indicator/alma.go)
- [Average True Range](./pkg/indicator/atr.go)
- [Bollinger Bands](./pkg/indicator/boll.go)
- [Commodity Channel Index](./pkg/indicator/cci.go)
- [Cumulative Moving Average](./pkg/indicator/cma.go)
- [Double Exponential Moving Average](./pkg/indicator/dema.go)
- [Directional Movement Index](./pkg/indicator/dmi.go)
- [Brownian Motion's Drift Factor](./pkg/indicator/drift.go)
- [Ease of Movement](./pkg/indicator/emv.go)
- [Exponentially Weighted Moving Average](./pkg/indicator/ewma.go)
- [Hull Moving Average](./pkg/indicator/hull.go)
- [Trend Line (Tool)](./pkg/indicator/line.go)
- [Moving Average Convergence Divergence Indicator](./pkg/indicator/macd.go)
- [On-Balance Volume](./pkg/indicator/obv.go)
- [Pivot](./pkg/indicator/pivot.go)
- [Running Moving Average](./pkg/indicator/rma.go)
- [Relative Strength Index](./pkg/indicator/rsi.go)
- [Simple Moving Average](./pkg/indicator/sma.go)
- [Ehler's Super Smoother Filter](./pkg/indicator/ssf.go)
- [Stochastic Oscillator](./pkg/indicator/stoch.go)
- [SuperTrend](./pkg/indicator/supertrend.go)
- [Triple Exponential Moving Average](./pkg/indicator/tema.go)
- [Tillson T3 Moving Average](./pkg/indicator/till.go)
- [Triangular Moving Average](./pkg/indicator/tma.go)
- [Variable Index Dynamic Average](./pkg/indicator/vidya.go)
- [Volatility Indicator](./pkg/indicator/volatility.go)
- [Volume Weighted Average Price](./pkg/indicator/vwap.go)
- [Zero Lag Exponential Moving Average](./pkg/indicator/zlema.go)
- And more...
- Indicators with interface similar
to `pandas.Series`([series](https://github.com/c9s/bbgo/blob/main/doc/development/series.md))([usage](https://github.com/c9s/bbgo/blob/main/doc/development/indicator.md)):
- [Accumulation/Distribution Indicator](./pkg/indicator/ad.go)
- [Arnaud Legoux Moving Average](./pkg/indicator/alma.go)
- [Average True Range](./pkg/indicator/atr.go)
- [Bollinger Bands](./pkg/indicator/boll.go)
- [Commodity Channel Index](./pkg/indicator/cci.go)
- [Cumulative Moving Average](./pkg/indicator/cma.go)
- [Double Exponential Moving Average](./pkg/indicator/dema.go)
- [Directional Movement Index](./pkg/indicator/dmi.go)
- [Brownian Motion's Drift Factor](./pkg/indicator/drift.go)
- [Ease of Movement](./pkg/indicator/emv.go)
- [Exponentially Weighted Moving Average](./pkg/indicator/ewma.go)
- [Hull Moving Average](./pkg/indicator/hull.go)
- [Trend Line (Tool)](./pkg/indicator/line.go)
- [Moving Average Convergence Divergence Indicator](./pkg/indicator/macd.go)
- [On-Balance Volume](./pkg/indicator/obv.go)
- [Pivot](./pkg/indicator/pivot.go)
- [Running Moving Average](./pkg/indicator/rma.go)
- [Relative Strength Index](./pkg/indicator/rsi.go)
- [Simple Moving Average](./pkg/indicator/sma.go)
- [Ehler's Super Smoother Filter](./pkg/indicator/ssf.go)
- [Stochastic Oscillator](./pkg/indicator/stoch.go)
- [SuperTrend](./pkg/indicator/supertrend.go)
- [Triple Exponential Moving Average](./pkg/indicator/tema.go)
- [Tillson T3 Moving Average](./pkg/indicator/till.go)
- [Triangular Moving Average](./pkg/indicator/tma.go)
- [Variable Index Dynamic Average](./pkg/indicator/vidya.go)
- [Volatility Indicator](./pkg/indicator/volatility.go)
- [Volume Weighted Average Price](./pkg/indicator/vwap.go)
- [Zero Lag Exponential Moving Average](./pkg/indicator/zlema.go)
- And more...
- HeikinAshi OHLC / Normal OHLC (check [this config](https://github.com/c9s/bbgo/blob/main/config/skeleton.yaml#L5))
- React-powered Web Dashboard.
- Docker image ready.
@ -115,7 +117,8 @@ Get your exchange API key and secret after you register the accounts (you can ch
- OKEx: <https://www.okex.com/join/2412712?src=from:ios-share>
- Kucoin: <https://www.kucoin.com/ucenter/signup?rcode=r3KX2D4>
This project is maintained and supported by a small group of team. If you would like to support this project, please register on the exchanges using the provided links with referral codes above.
This project is maintained and supported by a small group of team. If you would like to support this project, please
register on the exchanges using the provided links with referral codes above.
## Installation
@ -145,8 +148,8 @@ bash <(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/download.
Or refer to the [Release Page](https://github.com/c9s/bbgo/releases) and download manually.
Since v2, we've added new float point implementation from dnum to support decimals with higher precision.
To download & setup, please refer to [Dnum Installation](doc/topics/dnum-binary.md)
Since v2, we've added new float point implementation from dnum to support decimals with higher precision. To download &
setup, please refer to [Dnum Installation](doc/topics/dnum-binary.md)
### One-click Linode StackScript
@ -241,8 +244,8 @@ bbgo pnl --exchange binance --asset BTC --since "2019-01-01"
### Testnet (Paper Trading)
Currently only supports binance testnet.
To run bbgo in testnet, apply new API keys from [Binance Test Network](https://testnet.binance.vision), and set the following env before you start bbgo:
Currently only supports binance testnet. To run bbgo in testnet, apply new API keys
from [Binance Test Network](https://testnet.binance.vision), and set the following env before you start bbgo:
```bash
export PAPER_TRADE=1
@ -344,7 +347,8 @@ Check out the strategy directory [strategy](pkg/strategy) for all built-in strat
indicator [bollgrid](pkg/strategy/bollgrid)
- `grid` strategy implements the fixed price band grid strategy [grid](pkg/strategy/grid). See
[document](./doc/strategy/grid.md).
- `supertrend` strategy uses Supertrend indicator as trend, and DEMA indicator as noise filter [supertrend](pkg/strategy/supertrend). See
- `supertrend` strategy uses Supertrend indicator as trend, and DEMA indicator as noise
filter [supertrend](pkg/strategy/supertrend). See
[document](./doc/strategy/supertrend.md).
- `support` strategy uses K-lines with high volume as support [support](pkg/strategy/support). See
[document](./doc/strategy/support.md).
@ -365,78 +369,9 @@ bbgo run --config config/buyandhold.yaml
See [Back-testing](./doc/topics/back-testing.md)
## Adding New Built-in Strategy
## Adding Strategy
Fork and clone this repository, Create a directory under `pkg/strategy/newstrategy`, write your strategy
at `pkg/strategy/newstrategy/strategy.go`.
Define a strategy struct:
```go
package newstrategy
import (
"github.com/c9s/bbgo/pkg/fixedpoint"
)
type Strategy struct {
Symbol string `json:"symbol"`
Param1 int `json:"param1"`
Param2 int `json:"param2"`
Param3 fixedpoint.Value `json:"param3"`
}
```
Register your strategy:
```go
package newstrategy
const ID = "newstrategy"
const stateKey = "state-v1"
var log = logrus.WithField("strategy", ID)
func init() {
bbgo.RegisterStrategy(ID, &Strategy{})
}
```
Implement the strategy methods:
```go
package newstrategy
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "2m"})
}
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
// ....
return nil
}
```
Edit `pkg/cmd/builtin.go`, and import the package, like this:
```go
package cmd
// import built-in strategies
import (
_ "github.com/c9s/bbgo/pkg/strategy/bollgrid"
_ "github.com/c9s/bbgo/pkg/strategy/buyandhold"
_ "github.com/c9s/bbgo/pkg/strategy/flashcrash"
_ "github.com/c9s/bbgo/pkg/strategy/grid"
_ "github.com/c9s/bbgo/pkg/strategy/pricealert"
_ "github.com/c9s/bbgo/pkg/strategy/support"
_ "github.com/c9s/bbgo/pkg/strategy/swing"
_ "github.com/c9s/bbgo/pkg/strategy/trailingstop"
_ "github.com/c9s/bbgo/pkg/strategy/xmaker"
_ "github.com/c9s/bbgo/pkg/strategy/xpuremaker"
)
```
See [Developing Strategy](./doc/topics/developing-strategy.md)
## Write your own private strategy
@ -635,8 +570,9 @@ What's Position?
## Looking For A New Strategy?
You can write an article about BBGO in any topic, in 750-1500 words for exchange, and I can implement the strategy for you (depends on the complexity and efforts).
If you're interested in, DM me in telegram <https://t.me/c123456789s> or twitter <https://twitter.com/c9s>, we can discuss.
You can write an article about BBGO in any topic, in 750-1500 words for exchange, and I can implement the strategy for
you (depends on the complexity and efforts). If you're interested in, DM me in telegram <https://t.me/c123456789s> or
twitter <https://twitter.com/c9s>, we can discuss.
## Contributing

View File

@ -10,11 +10,11 @@ For built-in strategies, they are placed in `pkg/strategy` of the BBGO source re
For external strategies, you can create a private repository as an isolated go package and place your strategy inside
it.
In general, strategies are Go struct, placed in Go package.
In general, strategies are Go struct, defined in the Go package.
## Quick Start
To add your first strategy, the fastest way is to add the built-in strategy.
To add your first strategy, the fastest way is to add it as a built-in strategy.
Simply edit `pkg/cmd/builtin.go` and import your strategy package there.