Skip to content

Commit

Permalink
Check active stop orders
Browse files Browse the repository at this point in the history
  • Loading branch information
evsamsonov committed Sep 9, 2024
1 parent 3b6e5a0 commit 575f30c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion cmd/tinkoff-checkup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func main() {
if len(os.Args) < 3 {
fmt.Println(
"This command checks all methods of Tinkoff Broker.\n" +
"This command checks all methods of Tinkoff Broker.\n" +
"It opens position, changes conditional orders, closes position.",
)
fmt.Println("\nUsage: tinkoff-checkup [ACCOUNT_ID] [INSTRUMENT_FIGI] [-v]")
Expand Down
8 changes: 7 additions & 1 deletion tinkoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (t *Tinkoff) processOrderTrades(ctx context.Context, orderTrades *pb.OrderT
}

// Conditional orders may not be processed in real time. Wait a little to be sure
<-time.After(300 * time.Millisecond)
//<-time.After(1 * time.Second)

Check failure on line 296 in tinkoff.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
conditionalOrdersFound, err := t.conditionalOrdersFound(tinkoffPosition)
if err != nil {
return fmt.Errorf("conditional orders found: %w", err)
Expand Down Expand Up @@ -597,7 +597,13 @@ func (t *Tinkoff) conditionalOrdersFound(position *tnkposition.Position) (bool,
if err != nil {
return false, fmt.Errorf("get stop orders: %w", err)
}
t.logger.Debug("Stop orders", zap.Any("stopOrders", resp.StopOrders))

for _, order := range resp.StopOrders {
if order.Status != pb.StopOrderStatusOption_STOP_ORDER_STATUS_ACTIVE {
continue
}

if order.StopOrderId == position.TakeProfitID() || order.StopOrderId == position.StopLossID() {
return true, nil
}
Expand Down

0 comments on commit 575f30c

Please sign in to comment.