bbgo_origin/pkg/strategy/rebalance/position_map.go

21 lines
405 B
Go
Raw Normal View History

2023-03-12 15:48:26 +00:00
package rebalance
import (
"github.com/c9s/bbgo/pkg/types"
)
type PositionMap map[string]*types.Position
func NewPositionMap(markets []types.Market) PositionMap {
m := make(PositionMap)
for _, market := range markets {
position := types.NewPositionFromMarket(market)
position.Strategy = ID
position.StrategyInstanceID = instanceID(market.Symbol)
m[market.Symbol] = position
}
return m
}