mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
use mutex composition since we may lock from out side
This commit is contained in:
parent
8071559f99
commit
531799bdfb
|
@ -17,7 +17,7 @@ type Position struct {
|
|||
Quote fixedpoint.Value `json:"quote"`
|
||||
AverageCost fixedpoint.Value `json:"averageCost"`
|
||||
|
||||
mu sync.Mutex
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func (p *Position) String() string {
|
||||
|
@ -49,8 +49,8 @@ func (p *Position) AddTrades(trades []types.Trade) (fixedpoint.Value, bool) {
|
|||
}
|
||||
|
||||
func (p *Position) AddTrade(t types.Trade) (fixedpoint.Value, bool) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
price := fixedpoint.NewFromFloat(t.Price)
|
||||
quantity := fixedpoint.NewFromFloat(t.Quantity)
|
||||
|
|
Loading…
Reference in New Issue
Block a user