bbgo_origin/pkg/strategy/rebalance/position_map.go

23 lines
498 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
2023-10-31 05:53:12 +00:00
func (m PositionMap) CreatePositions(markets map[string]types.Market) PositionMap {
for symbol, market := range markets {
if _, ok := m[symbol]; ok {
2023-03-14 06:37:54 +00:00
continue
}
2023-10-31 05:53:12 +00:00
log.Infof("creating position for symbol %s", symbol)
2023-03-12 15:48:26 +00:00
position := types.NewPositionFromMarket(market)
position.Strategy = ID
2023-10-31 05:53:12 +00:00
position.StrategyInstanceID = instanceID(symbol)
m[symbol] = position
2023-03-12 15:48:26 +00:00
}
return m
}