From 12b9775eb3310e69f030cc0adf59ba2d571e2090 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 22 Mar 2023 21:17:33 +0800 Subject: [PATCH] rename funding to xfunding --- pkg/cmd/strategy/builtin.go | 2 +- .../{funding => xfunding}/strategy.go | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) rename pkg/strategy/{funding => xfunding}/strategy.go (92%) diff --git a/pkg/cmd/strategy/builtin.go b/pkg/cmd/strategy/builtin.go index edfdce475..50e1ec8bb 100644 --- a/pkg/cmd/strategy/builtin.go +++ b/pkg/cmd/strategy/builtin.go @@ -16,7 +16,6 @@ import ( _ "github.com/c9s/bbgo/pkg/strategy/fixedmaker" _ "github.com/c9s/bbgo/pkg/strategy/flashcrash" _ "github.com/c9s/bbgo/pkg/strategy/fmaker" - _ "github.com/c9s/bbgo/pkg/strategy/funding" _ "github.com/c9s/bbgo/pkg/strategy/grid" _ "github.com/c9s/bbgo/pkg/strategy/grid2" _ "github.com/c9s/bbgo/pkg/strategy/harmonic" @@ -38,6 +37,7 @@ import ( _ "github.com/c9s/bbgo/pkg/strategy/trendtrader" _ "github.com/c9s/bbgo/pkg/strategy/wall" _ "github.com/c9s/bbgo/pkg/strategy/xbalance" + _ "github.com/c9s/bbgo/pkg/strategy/xfunding" _ "github.com/c9s/bbgo/pkg/strategy/xgap" _ "github.com/c9s/bbgo/pkg/strategy/xmaker" _ "github.com/c9s/bbgo/pkg/strategy/xnav" diff --git a/pkg/strategy/funding/strategy.go b/pkg/strategy/xfunding/strategy.go similarity index 92% rename from pkg/strategy/funding/strategy.go rename to pkg/strategy/xfunding/strategy.go index d056a8fb7..407fcc6f0 100644 --- a/pkg/strategy/funding/strategy.go +++ b/pkg/strategy/xfunding/strategy.go @@ -1,4 +1,4 @@ -package funding +package xfunding import ( "context" @@ -14,7 +14,7 @@ import ( "github.com/c9s/bbgo/pkg/types" ) -const ID = "funding" +const ID = "xfunding" var log = logrus.WithField("strategy", ID) @@ -66,6 +66,11 @@ func (s *Strategy) ID() string { return ID } +func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) { + // TODO implement me + panic("implement me") +} + func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { // session.Subscribe(types.BookChannel, s.Symbol, types.SubscribeOptions{}) @@ -99,11 +104,6 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se return nil } - premiumIndex, err := session.Exchange.(*binance.Exchange).QueryPremiumIndex(ctx, s.Symbol) - if err != nil { - log.Error("exchange does not support funding rate api") - } - var ma types.Float64Indicator for _, detection := range s.SupportDetection { @@ -124,10 +124,14 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se Window: detection.MovingAverageIntervalWindow.Window, }) } - } session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(kline types.KLine) { + premiumIndex, err := session.Exchange.(*binance.Exchange).QueryPremiumIndex(ctx, s.Symbol) + if err != nil { + log.Error("exchange does not support funding rate api") + } + // skip k-lines from other symbols for _, detection := range s.SupportDetection { var lastMA = ma.Last() @@ -195,3 +199,8 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se })) return nil } + +func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.OrderExecutionRouter, sessions map[string]*bbgo.ExchangeSession) error { + // TODO implement me + panic("implement me") +}