From dcbeace40edcaafe91e01f96cacfee5dd8866b7e Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 22 Jun 2022 23:24:11 +0800 Subject: [PATCH] skeleton: update more comments --- pkg/strategy/skeleton/strategy.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/strategy/skeleton/strategy.go b/pkg/strategy/skeleton/strategy.go index 28caacb92..0424ca3dd 100644 --- a/pkg/strategy/skeleton/strategy.go +++ b/pkg/strategy/skeleton/strategy.go @@ -12,13 +12,21 @@ import ( "github.com/c9s/bbgo/pkg/types" ) +// ID is the unique strategy ID, it needs to be in all lower case +// For example, grid strategy uses "grid" const ID = "skeleton" +// Attach the strategy field with our ID, so that the logs from this strategy will be tagged with our ID var log = logrus.WithField("strategy", ID) -var Ten = fixedpoint.NewFromInt(10) +var ten = fixedpoint.NewFromInt(10) +// init is a special function of golang, it will be called when the program is started +// importing this package will trigger the init function call. func init() { + // Register our struct type to BBGO + // Note that you don't need to field the fields. + // BBGO uses reflect to parse your type information. bbgo.RegisterStrategy(ID, &Strategy{}) } @@ -133,7 +141,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se // Note that the available balance is a fixed-point object, so you can not compare it with integer directly. // Instead, you should call valueA.Compare(valueB) quantityAmount := quoteBalance.Available - if quantityAmount.Sign() <= 0 || quantityAmount.Compare(Ten) < 0 { + if quantityAmount.Sign() <= 0 || quantityAmount.Compare(ten) < 0 { return }