mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +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()
|
position := s.Position.GetBase()
|
||||||
|
|
||||||
s.mu.Lock()
|
|
||||||
coveredPosition := s.CoveredPosition.Get()
|
coveredPosition := s.CoveredPosition.Get()
|
||||||
uncoverPosition := position.Sub(coveredPosition)
|
uncoverPosition := position.Sub(coveredPosition)
|
||||||
s.mu.Unlock()
|
|
||||||
|
|
||||||
absPos := uncoverPosition.Abs()
|
absPos := uncoverPosition.Abs()
|
||||||
if absPos.Compare(s.hedgeMarket.MinQuantity) > 0 {
|
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) {
|
func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
|
||||||
side := types.SideTypeBuy
|
|
||||||
if pos.IsZero() {
|
if pos.IsZero() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
quantity := pos.Abs()
|
// the default side
|
||||||
|
side := types.SideTypeBuy
|
||||||
if pos.Sign() < 0 {
|
if pos.Sign() < 0 {
|
||||||
side = types.SideTypeSell
|
side = types.SideTypeSell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quantity := pos.Abs()
|
||||||
|
|
||||||
lastPrice := s.lastPrice
|
lastPrice := s.lastPrice
|
||||||
sourceBook := s.pricingBook.CopyDepth(1)
|
sourceBook := s.pricingBook.CopyDepth(1)
|
||||||
switch side {
|
switch side {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user