mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
xdepthmaker: remove shared mutex lock usage
This commit is contained in:
parent
345c92c295
commit
b02580f9f6
|
@ -487,10 +487,8 @@ func (s *Strategy) CrossRun(
|
|||
|
||||
position := s.Position.GetBase()
|
||||
|
||||
s.mu.Lock()
|
||||
coveredPosition := s.CoveredPosition.Get()
|
||||
uncoverPosition := position.Sub(coveredPosition)
|
||||
s.mu.Unlock()
|
||||
|
||||
absPos := uncoverPosition.Abs()
|
||||
if absPos.Compare(s.hedgeMarket.MinQuantity) > 0 {
|
||||
|
@ -537,17 +535,18 @@ func (s *Strategy) CrossRun(
|
|||
}
|
||||
|
||||
func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
|
||||
side := types.SideTypeBuy
|
||||
if pos.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
quantity := pos.Abs()
|
||||
|
||||
// the default side
|
||||
side := types.SideTypeBuy
|
||||
if pos.Sign() < 0 {
|
||||
side = types.SideTypeSell
|
||||
}
|
||||
|
||||
quantity := pos.Abs()
|
||||
|
||||
lastPrice := s.lastPrice
|
||||
sourceBook := s.pricingBook.CopyDepth(1)
|
||||
switch side {
|
||||
|
|
Loading…
Reference in New Issue
Block a user