not emit WaitToOpenPosition when kline event

This commit is contained in:
kbearXD 2024-05-13 14:32:48 +08:00
parent 6cdd2f0d71
commit f49924caa4
2 changed files with 1 additions and 3 deletions

View File

@ -74,7 +74,7 @@ func (s *Strategy) emitNextState(nextState State) {
// TakeProfitReady -> the takeProfit order filled ->
func (s *Strategy) runState(ctx context.Context) {
s.logger.Info("[DCA] runState")
stateTriggerTicker := time.NewTicker(3 * time.Minute)
stateTriggerTicker := time.NewTicker(1 * time.Minute)
defer stateTriggerTicker.Stop()
for {

View File

@ -263,8 +263,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
session.MarketDataStream.OnKLine(func(kline types.KLine) {
switch s.state {
case WaitToOpenPosition:
s.emitNextState(PositionOpening)
case OpenPositionOrderFilled:
if s.takeProfitPrice.IsZero() {
s.logger.Warn("take profit price should not be 0 when there is at least one open-position order filled, please check it")