From 73c2c84cab1854d93f5bf9f2952548126e8e3f15 Mon Sep 17 00:00:00 2001 From: Andy Cheng Date: Fri, 15 Apr 2022 16:06:19 +0800 Subject: [PATCH] feature: prototype of strategy controller struct --- pkg/bbgo/strategy_controller.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/bbgo/strategy_controller.go b/pkg/bbgo/strategy_controller.go index f30d11b65..99d19982f 100644 --- a/pkg/bbgo/strategy_controller.go +++ b/pkg/bbgo/strategy_controller.go @@ -1 +1,22 @@ package bbgo + +import ( + "context" + "github.com/c9s/bbgo/pkg/types" +) + +type StrategyController struct { + status types.StrategyStatus + + SuspendCallbacks []func(ctx context.Context) +} + +func (s *StrategyController) OnSuspend(cb func(ctx context.Context)) { + s.SuspendCallbacks = append(s.SuspendCallbacks, cb) +} + +func (s *StrategyController) EmitKLineClosed(ctx context.Context) { + for _, cb := range s.SuspendCallbacks { + cb(ctx) + } +}