mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
Merge pull request #742 from c9s/improve/notify-api
refactor: clean up bbgo.Notifiability
This commit is contained in:
commit
bce64df7d9
|
@ -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.orderStore.BindStream(e.session.UserDataStream)
|
||||
|
||||
// trade notify
|
||||
e.tradeCollector.OnTrade(func(trade types.Trade, profit, netProfit fixedpoint.Value) {
|
||||
notify(trade)
|
||||
Notify(trade)
|
||||
})
|
||||
|
||||
e.tradeCollector.OnPositionUpdate(func(position *types.Position) {
|
||||
log.Infof("position changed: %s", position)
|
||||
notify(position)
|
||||
Notify(position)
|
||||
})
|
||||
|
||||
e.tradeCollector.BindStream(e.session.UserDataStream)
|
||||
|
|
|
@ -50,8 +50,6 @@ type MarginAsset struct {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*bbgo.Notifiability
|
||||
|
||||
Interval types.Interval `json:"interval"`
|
||||
MinMarginLevel fixedpoint.Value `json:"minMarginLevel"`
|
||||
MaxMarginLevel fixedpoint.Value `json:"maxMarginLevel"`
|
||||
|
|
|
@ -25,10 +25,6 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
// The notification system will be injected into the strategy automatically.
|
||||
// This field will be injected automatically since it's a single exchange strategy.
|
||||
*bbgo.Notifiability
|
||||
|
||||
// OrderExecutor is an interface for submitting order.
|
||||
// This field will be injected automatically since it's a single exchange strategy.
|
||||
bbgo.OrderExecutor
|
||||
|
|
|
@ -51,7 +51,6 @@ type BollingerSetting struct {
|
|||
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
|
|
@ -48,7 +48,6 @@ func (b BudgetPeriod) Duration() time.Duration {
|
|||
// Strategy is the Dollar-Cost-Average strategy
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
|
|
@ -27,10 +27,6 @@ func init() {
|
|||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
|
||||
// The notification system will be injected into the strategy automatically.
|
||||
// This field will be injected automatically since it's a single exchange strategy.
|
||||
*bbgo.Notifiability
|
||||
|
||||
SourceExchangeName string `json:"sourceExchange"`
|
||||
|
||||
TargetExchangeName string `json:"targetExchange"`
|
||||
|
|
|
@ -22,8 +22,6 @@ func init() {
|
|||
type Strategy struct {
|
||||
Market types.Market
|
||||
|
||||
Notifiability *bbgo.Notifiability
|
||||
|
||||
TotalAmount fixedpoint.Value `json:"totalAmount,omitempty"`
|
||||
|
||||
// Interval is the period that you want to submit order
|
||||
|
|
|
@ -32,7 +32,6 @@ type IntervalWindowSetting struct {
|
|||
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
|
|
@ -27,7 +27,6 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*bbgo.Notifiability
|
||||
// These fields will be filled from the config file (it translates YAML to JSON)
|
||||
Symbol string `json:"symbol"`
|
||||
Market types.Market `json:"-"`
|
||||
|
|
|
@ -45,10 +45,6 @@ type State struct {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
// The notification system will be injected into the strategy automatically.
|
||||
// This field will be injected automatically since it's a single exchange strategy.
|
||||
*bbgo.Notifiability `json:"-" yaml:"-"`
|
||||
|
||||
*bbgo.Graceful `json:"-" yaml:"-"`
|
||||
|
||||
*bbgo.Persistence
|
||||
|
|
|
@ -78,7 +78,6 @@ type Exit struct {
|
|||
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
|
||||
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.BindProfitStats(s.ProfitStats)
|
||||
s.orderExecutor.BindTradeStats(s.TradeStats)
|
||||
s.orderExecutor.Bind(s.Notifiability.Notify)
|
||||
s.orderExecutor.Bind()
|
||||
|
||||
store, _ := session.MarketDataStore(s.Symbol)
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@ func init() {
|
|||
}
|
||||
|
||||
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)
|
||||
Symbol string `json:"symbol"`
|
||||
Interval types.Interval `json:"interval"`
|
||||
|
|
|
@ -20,8 +20,6 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
Notifiability *bbgo.Notifiability
|
||||
|
||||
Interval types.Interval `json:"interval"`
|
||||
BaseCurrency string `json:"baseCurrency"`
|
||||
TargetWeights types.ValueMap `json:"targetWeights"`
|
||||
|
|
|
@ -19,8 +19,6 @@ func init() {
|
|||
type Strategy struct {
|
||||
Market types.Market
|
||||
|
||||
Notifiability *bbgo.Notifiability
|
||||
|
||||
// StandardIndicatorSet contains the standard indicators of a market (symbol)
|
||||
// This field will be injected automatically since we defined the Symbol field.
|
||||
*bbgo.StandardIndicatorSet
|
||||
|
|
|
@ -29,7 +29,6 @@ func init() {
|
|||
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
|
|
@ -130,7 +130,6 @@ func (control *TrailingStopControl) GenerateStopOrder(quantity fixedpoint.Value)
|
|||
// }
|
||||
|
||||
type Strategy struct {
|
||||
*bbgo.Notifiability `json:"-"`
|
||||
*bbgo.Persistence
|
||||
*bbgo.Graceful `json:"-"`
|
||||
|
||||
|
|
|
@ -26,10 +26,6 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
// The notification system will be injected into the strategy automatically.
|
||||
// This field will be injected automatically since it's a single exchange strategy.
|
||||
*bbgo.Notifiability
|
||||
|
||||
// OrderExecutor is an interface for submitting order.
|
||||
// This field will be injected automatically since it's a single exchange strategy.
|
||||
bbgo.OrderExecutor
|
||||
|
|
|
@ -28,8 +28,6 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*bbgo.Notifiability
|
||||
|
||||
// These fields will be filled from the config file (it translates YAML to JSON)
|
||||
Symbol string `json:"symbol"`
|
||||
Market types.Market `json:"-"`
|
||||
|
|
|
@ -31,7 +31,6 @@ func init() {
|
|||
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
|
|
@ -136,7 +136,6 @@ func (a *Address) UnmarshalJSON(body []byte) error {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
Notifiability *bbgo.Notifiability
|
||||
*bbgo.Graceful
|
||||
*bbgo.Persistence
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ func (s *State) Reset() {
|
|||
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
|
||||
Symbol string `json:"symbol"`
|
||||
|
|
|
@ -34,7 +34,6 @@ func init() {
|
|||
|
||||
type Strategy struct {
|
||||
*bbgo.Graceful
|
||||
*bbgo.Notifiability
|
||||
*bbgo.Persistence
|
||||
Environment *bbgo.Environment
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ func (s *State) Reset() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
Notifiability *bbgo.Notifiability
|
||||
*bbgo.Graceful
|
||||
*bbgo.Persistence
|
||||
*bbgo.Environment
|
||||
|
|
Loading…
Reference in New Issue
Block a user