Skip to content

Commit

Permalink
refactor: Remove unnecessary log and fmt imports
Browse files Browse the repository at this point in the history
  • Loading branch information
rluisr committed Feb 18, 2024
1 parent 1a593e8 commit bdfd021
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 5 additions & 11 deletions pkg/external/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
package external

import (
"fmt"
"log"
"os"
"os/signal"
"time"
Expand Down Expand Up @@ -51,8 +49,11 @@ func Cron() {
tvController.Interactor.TVRepository.Logging().Error("NewJob: FetchOrder", err.Error(), err)
}

job, err := s.NewJob(
gocron.CronJob("* * * * *", false),
_, err = s.NewJob(
// KeepAlive を続けるために短い間隔で行う
gocron.DurationJob(
3*time.Second,
),
gocron.NewTask(func() {
icErr := tvController.InventoryCheck(5 * time.Minute)
if icErr != nil {
Expand All @@ -68,13 +69,6 @@ func Cron() {

s.Start()

nextTime, err := job.NextRun()
if err != nil {
log.Println(err)
return
}
tvController.Interactor.TVRepository.Logging().Info(fmt.Sprintf("Next run: %s", nextTime))

quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
<-quit
Expand Down
4 changes: 3 additions & 1 deletion pkg/usecase/tv_interactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ func (i *TVInteractor) InventoryCheck(cancelAfter time.Duration) error {
}

for _, order := range orders.Result.List {
if order.OrderStatus == bybit.OrderStatusUntriggered {
// New: 新規注文(ポジションは持ってない)
// Untriggered: TP/SL のみの注文(ポジション注文は通っているが、TP/SL 注文がある状態)
if order.OrderStatus == bybit.OrderStatusNew {
createdAt, cErr := utils.TimestampMSToTime(order.CreatedTime)
if cErr != nil {
return cErr
Expand Down

0 comments on commit bdfd021

Please sign in to comment.