mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add readme content about testnet, fix code syntax
This commit is contained in:
parent
9cf835728c
commit
84dbae1592
|
@ -173,6 +173,15 @@ bbgo pnl --exchange binance --asset BTC --since "2019-01-01"
|
||||||
|
|
||||||
## Advanced Configuration
|
## Advanced Configuration
|
||||||
|
|
||||||
|
### 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:
|
||||||
|
```bash
|
||||||
|
export PAPER_TRADE=1
|
||||||
|
export DISABLE_MARKET_CACHE=1 # the symbols supported in testnet is far less than the mainnet
|
||||||
|
```
|
||||||
|
|
||||||
### Notification
|
### Notification
|
||||||
|
|
||||||
- [Setting up Telegram notification](./doc/configuration/telegram.md)
|
- [Setting up Telegram notification](./doc/configuration/telegram.md)
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const BNB = "BNB"
|
const BNB = "BNB"
|
||||||
|
@ -61,8 +62,8 @@ func isBinanceUs() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func paperTrade() bool {
|
func paperTrade() bool {
|
||||||
v, err := strconv.ParseBool(os.Getenv("PAPER_TRADE"))
|
v, ok := util.GetEnvVarBool("PAPER_TRADE")
|
||||||
return err == nil && v
|
return ok && v
|
||||||
}
|
}
|
||||||
|
|
||||||
type Exchange struct {
|
type Exchange struct {
|
||||||
|
|
|
@ -3,8 +3,6 @@ package service
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/cache"
|
"github.com/c9s/bbgo/pkg/cache"
|
||||||
|
@ -12,6 +10,7 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrNotImplemented = errors.New("not implemented")
|
var ErrNotImplemented = errors.New("not implemented")
|
||||||
|
@ -26,8 +25,8 @@ type SyncService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func paperTrade() bool {
|
func paperTrade() bool {
|
||||||
v, err := strconv.ParseBool(os.Getenv("PAPER_TRADE"))
|
v, ok := util.GetEnvVarBool("PAPER_TRADE")
|
||||||
return err == nil && v
|
return ok && v
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncSessionSymbols syncs the trades from the given exchange session
|
// SyncSessionSymbols syncs the trades from the given exchange session
|
||||||
|
@ -51,28 +50,31 @@ func (s *SyncService) SyncSessionSymbols(ctx context.Context, exchange types.Exc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !paperTrade() {
|
if paperTrade() {
|
||||||
log.Infof("syncing %s deposit records...", exchange.Name())
|
return nil
|
||||||
if err := s.DepositService.Sync(ctx, exchange); err != nil {
|
}
|
||||||
if err != ErrNotImplemented {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("syncing %s withdraw records...", exchange.Name())
|
log.Infof("syncing %s deposit records...", exchange.Name())
|
||||||
if err := s.WithdrawService.Sync(ctx, exchange); err != nil {
|
if err := s.DepositService.Sync(ctx, exchange); err != nil {
|
||||||
if err != ErrNotImplemented {
|
if err != ErrNotImplemented {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("syncing %s reward records...", exchange.Name())
|
|
||||||
if err := s.RewardService.Sync(ctx, exchange); err != nil {
|
|
||||||
if err != ErrExchangeRewardServiceNotImplemented {
|
|
||||||
log.Infof("%s reward service is not supported", exchange.Name())
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("syncing %s withdraw records...", exchange.Name())
|
||||||
|
if err := s.WithdrawService.Sync(ctx, exchange); err != nil {
|
||||||
|
if err != ErrNotImplemented {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("syncing %s reward records...", exchange.Name())
|
||||||
|
if err := s.RewardService.Sync(ctx, exchange); err != nil {
|
||||||
|
if err != ErrExchangeRewardServiceNotImplemented {
|
||||||
|
log.Infof("%s reward service is not supported", exchange.Name())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user