Skip to content

Commit

Permalink
Merge pull request #1459 from c9s/kbearXD/fix/move-common-strategy
Browse files Browse the repository at this point in the history
FIX: move common.Strategy to Initialize
  • Loading branch information
c9s authored Dec 18, 2023
2 parents c71152d + eda0723 commit 4bdaf11
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 9 deletions.
7 changes: 6 additions & 1 deletion pkg/strategy/atrpin/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init() {
}

type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand All @@ -36,6 +36,11 @@ type Strategy struct {
// bbgo.OpenPositionOptions
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

func (s *Strategy) ID() string {
return ID
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/strategy/dca2/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
}

type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand Down Expand Up @@ -89,6 +89,7 @@ func (s *Strategy) Defaults() error {

func (s *Strategy) Initialize() error {
s.logger = log.WithFields(s.LogFields)
s.Strategy = &common.Strategy{}
return nil
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/strategy/fixedmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {

// Fixed spread market making strategy
type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand All @@ -45,7 +45,9 @@ func (s *Strategy) Defaults() error {
}
return nil
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/strategy/liquiditymaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func init() {
// - place enough total liquidity amount on the order book, for example, 20k USDT value liquidity on both sell and buy
// - ensure the spread by placing the orders from the mid price (or the last trade price)
type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand Down Expand Up @@ -66,6 +66,11 @@ type Strategy struct {
orderGenerator *LiquidityOrderGenerator
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

func (s *Strategy) ID() string {
return ID
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/strategy/random/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {
}

type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand All @@ -42,6 +42,7 @@ func (s *Strategy) Defaults() error {
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/strategy/rsicross/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {
}

type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand All @@ -36,6 +36,11 @@ type Strategy struct {
bbgo.OpenPositionOptions
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

func (s *Strategy) ID() string {
return ID
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/strategy/scmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func init() {

// Strategy scmaker is a stable coin market maker
type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand Down Expand Up @@ -69,6 +69,11 @@ type Strategy struct {
intensity *IntensityStream
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

func (s *Strategy) ID() string {
return ID
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/strategy/wall/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
}

type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment
Market types.Market
Expand Down Expand Up @@ -64,6 +64,11 @@ type Strategy struct {
activeWallOrders *bbgo.ActiveOrderBook
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

func (s *Strategy) ID() string {
return ID
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/strategy/xfixedmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {

// Fixed spread market making strategy
type Strategy struct {
common.Strategy
*common.Strategy

Environment *bbgo.Environment

Expand Down Expand Up @@ -51,7 +51,9 @@ func (s *Strategy) Defaults() error {
}
return nil
}

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
return nil
}

Expand Down

0 comments on commit 4bdaf11

Please sign in to comment.