mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
all: clean up notifiability usage
This commit is contained in:
parent
eacd1f1ae6
commit
88a63df186
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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"`
|
||||||
|
|
|
@ -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"`
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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:"-"`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user