-
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dbg package for debugging functions
- Loading branch information
Showing
5 changed files
with
50 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dbg | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
types2 "github.com/c9s/bbgo/pkg/types" | ||
) | ||
|
||
func DebugSubmitOrders(logger logrus.FieldLogger, submitOrders []types2.SubmitOrder) { | ||
var sb strings.Builder | ||
sb.WriteString("SubmitOrders[\n") | ||
for i, order := range submitOrders { | ||
sb.WriteString(fmt.Sprintf("%3d) ", i+1) + order.String() + "\n") | ||
} | ||
sb.WriteString("] End of SubmitOrders") | ||
|
||
logger.Info(sb.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package types | ||
|
||
func ClassifyOrdersByStatus(orders []Order) (opened, cancelled, filled, unexpected []Order) { | ||
for _, order := range orders { | ||
switch order.Status { | ||
case OrderStatusNew, OrderStatusPartiallyFilled: | ||
opened = append(opened, order) | ||
case OrderStatusFilled: | ||
filled = append(filled, order) | ||
case OrderStatusCanceled: | ||
cancelled = append(cancelled, order) | ||
default: | ||
unexpected = append(unexpected, order) | ||
} | ||
} | ||
|
||
return opened, cancelled, filled, unexpected | ||
} |