rename cronExpression to schedule

This commit is contained in:
narumi 2024-01-06 17:37:13 +08:00
parent 6367bd79d3
commit dc2895c4dc
4 changed files with 22 additions and 48 deletions

View File

@ -4,7 +4,7 @@ exchangeStrategies:
random: random:
symbol: USDCUSDT symbol: USDCUSDT
# https://pkg.go.dev/github.com/robfig/cron#hdr-Predefined_schedules # https://pkg.go.dev/github.com/robfig/cron#hdr-Predefined_schedules
cronExpression: "@every 8h" schedule: "@every 8h"
quantity: 8 quantity: 8
onStart: true onStart: true
dryRun: true dryRun: true

View File

@ -1,39 +1,13 @@
--- ---
notifications:
slack:
defaultChannel: "bbgo"
errorChannel: "bbgo-error"
switches:
trade: true
orderUpdate: true
submitOrder: true
backtest:
startTime: "2022-01-01"
endTime: "2022-10-01"
symbols:
- BTCUSDT
- ETHUSDT
- MAXUSDT
account:
max:
makerFeeRate: 0.075%
takerFeeRate: 0.075%
balances:
BTC: 0.0
ETH: 0.0
MAX: 0.0
USDT: 10000.0
exchangeStrategies: exchangeStrategies:
- on: max - on: max
rebalance: rebalance:
cronExpression: "@every 1s" schedule: "@every 1s"
quoteCurrency: USDT quoteCurrency: TWD
targetWeights: targetWeights:
BTC: 50% BTC: 60%
ETH: 25% ETH: 30%
USDT: 25% TWD: 10%
threshold: 1% threshold: 1%
maxAmount: 1_000 # max amount to buy or sell per order maxAmount: 1_000 # max amount to buy or sell per order
orderType: LIMIT_MAKER # LIMIT, LIMIT_MAKER or MARKET orderType: LIMIT_MAKER # LIMIT, LIMIT_MAKER or MARKET

View File

@ -29,7 +29,7 @@ type Strategy struct {
Market types.Market Market types.Market
Symbol string `json:"symbol"` Symbol string `json:"symbol"`
CronExpression string `json:"cronExpression"` Schedule string `json:"schedule"`
OnStart bool `json:"onStart"` OnStart bool `json:"onStart"`
DryRun bool `json:"dryRun"` DryRun bool `json:"dryRun"`
@ -55,8 +55,8 @@ func (s *Strategy) InstanceID() string {
} }
func (s *Strategy) Validate() error { func (s *Strategy) Validate() error {
if s.CronExpression == "" { if s.Schedule == "" {
return fmt.Errorf("cronExpression is required") return fmt.Errorf("schedule is required")
} }
if err := s.QuantityOrAmount.Validate(); err != nil { if err := s.QuantityOrAmount.Validate(); err != nil {
@ -83,7 +83,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
}) })
s.cron = cron.New() s.cron = cron.New()
s.cron.AddFunc(s.CronExpression, s.placeOrder) s.cron.AddFunc(s.Schedule, s.placeOrder)
s.cron.Start() s.cron.Start()
return nil return nil

View File

@ -27,7 +27,7 @@ type Strategy struct {
Environment *bbgo.Environment Environment *bbgo.Environment
CronExpression string `json:"cronExpression"` Schedule string `json:"schedule"`
QuoteCurrency string `json:"quoteCurrency"` QuoteCurrency string `json:"quoteCurrency"`
TargetWeights types.ValueMap `json:"targetWeights"` TargetWeights types.ValueMap `json:"targetWeights"`
Threshold fixedpoint.Value `json:"threshold"` Threshold fixedpoint.Value `json:"threshold"`
@ -130,7 +130,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
}) })
s.cron = cron.New() s.cron = cron.New()
s.cron.AddFunc(s.CronExpression, func() { s.cron.AddFunc(s.Schedule, func() {
s.rebalance(ctx) s.rebalance(ctx)
}) })
s.cron.Start() s.cron.Start()