mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
35 lines
742 B
Go
35 lines
742 B
Go
package grid2
|
|
|
|
import (
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
)
|
|
|
|
// PinOrderMap store the pin-order's relation, we will change key from string to fixedpoint.Value when FormatString fixed
|
|
type PinOrderMap map[string]types.Order
|
|
|
|
// AscendingOrders get the orders from pin order map and sort it in asc order
|
|
func (m PinOrderMap) AscendingOrders() []types.Order {
|
|
var orders []types.Order
|
|
for _, order := range m {
|
|
// skip empty order
|
|
if order.OrderID == 0 {
|
|
continue
|
|
}
|
|
|
|
orders = append(orders, order)
|
|
}
|
|
|
|
types.SortOrdersUpdateTimeAscending(orders)
|
|
|
|
return orders
|
|
}
|
|
|
|
func (m PinOrderMap) SyncOrderMap() *types.SyncOrderMap {
|
|
orderMap := types.NewSyncOrderMap()
|
|
for _, order := range m {
|
|
orderMap.Add(order)
|
|
}
|
|
|
|
return orderMap
|
|
}
|