all: clean up notifiability usage

This commit is contained in:
c9s 2022-06-19 13:01:22 +08:00
parent eacd1f1ae6
commit 88a63df186
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
6 changed files with 4 additions and 12 deletions

View File

@ -68,18 +68,18 @@ func (e *GeneralOrderExecutor) BindProfitStats(profitStats *types.ProfitStats) {
}) })
} }
func (e *GeneralOrderExecutor) Bind(notify NotifyFunc) { func (e *GeneralOrderExecutor) Bind() {
e.activeMakerOrders.BindStream(e.session.UserDataStream) e.activeMakerOrders.BindStream(e.session.UserDataStream)
e.orderStore.BindStream(e.session.UserDataStream) e.orderStore.BindStream(e.session.UserDataStream)
// trade notify // trade notify
e.tradeCollector.OnTrade(func(trade types.Trade, profit, netProfit fixedpoint.Value) { e.tradeCollector.OnTrade(func(trade types.Trade, profit, netProfit fixedpoint.Value) {
notify(trade) Notify(trade)
}) })
e.tradeCollector.OnPositionUpdate(func(position *types.Position) { e.tradeCollector.OnPositionUpdate(func(position *types.Position) {
log.Infof("position changed: %s", position) log.Infof("position changed: %s", position)
notify(position) Notify(position)
}) })
e.tradeCollector.BindStream(e.session.UserDataStream) e.tradeCollector.BindStream(e.session.UserDataStream)

View File

@ -78,7 +78,6 @@ type Exit struct {
type Strategy struct { type Strategy struct {
*bbgo.Graceful *bbgo.Graceful
*bbgo.Notifiability
*bbgo.Persistence *bbgo.Persistence
Environment *bbgo.Environment Environment *bbgo.Environment
@ -204,7 +203,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
s.orderExecutor.BindEnvironment(s.Environment) s.orderExecutor.BindEnvironment(s.Environment)
s.orderExecutor.BindProfitStats(s.ProfitStats) s.orderExecutor.BindProfitStats(s.ProfitStats)
s.orderExecutor.BindTradeStats(s.TradeStats) s.orderExecutor.BindTradeStats(s.TradeStats)
s.orderExecutor.Bind(s.Notifiability.Notify) s.orderExecutor.Bind()
store, _ := session.MarketDataStore(s.Symbol) store, _ := session.MarketDataStore(s.Symbol)

View File

@ -15,9 +15,6 @@ func init() {
} }
type Strategy struct { type Strategy struct {
// The notification system will be injected into the strategy automatically.
*bbgo.Notifiability
// These fields will be filled from the config file (it translates YAML to JSON) // These fields will be filled from the config file (it translates YAML to JSON)
Symbol string `json:"symbol"` Symbol string `json:"symbol"`
Interval types.Interval `json:"interval"` Interval types.Interval `json:"interval"`

View File

@ -20,8 +20,6 @@ func init() {
} }
type Strategy struct { type Strategy struct {
Notifiability *bbgo.Notifiability
Interval types.Interval `json:"interval"` Interval types.Interval `json:"interval"`
BaseCurrency string `json:"baseCurrency"` BaseCurrency string `json:"baseCurrency"`
TargetWeights types.ValueMap `json:"targetWeights"` TargetWeights types.ValueMap `json:"targetWeights"`

View File

@ -29,7 +29,6 @@ func init() {
type Strategy struct { type Strategy struct {
*bbgo.Graceful *bbgo.Graceful
*bbgo.Notifiability
*bbgo.Persistence *bbgo.Persistence
Environment *bbgo.Environment Environment *bbgo.Environment

View File

@ -130,7 +130,6 @@ func (control *TrailingStopControl) GenerateStopOrder(quantity fixedpoint.Value)
// } // }
type Strategy struct { type Strategy struct {
*bbgo.Notifiability `json:"-"`
*bbgo.Persistence *bbgo.Persistence
*bbgo.Graceful `json:"-"` *bbgo.Graceful `json:"-"`