bbgo_origin/pkg/strategy/rebalance/position_map.go
2023-10-31 13:53:12 +08:00

23 lines
498 B
Go

package rebalance
import (
"github.com/c9s/bbgo/pkg/types"
)
type PositionMap map[string]*types.Position
func (m PositionMap) CreatePositions(markets map[string]types.Market) PositionMap {
for symbol, market := range markets {
if _, ok := m[symbol]; ok {
continue
}
log.Infof("creating position for symbol %s", symbol)
position := types.NewPositionFromMarket(market)
position.Strategy = ID
position.StrategyInstanceID = instanceID(symbol)
m[symbol] = position
}
return m
}