mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
move addTrade lock section
This commit is contained in:
parent
e636a5008d
commit
d0e4a5e65c
|
@ -107,9 +107,6 @@ func (p *Position) AddTrades(trades []types.Trade) (fixedpoint.Value, bool) {
|
|||
}
|
||||
|
||||
func (p *Position) AddTrade(t types.Trade) (fixedpoint.Value, bool) {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
price := fixedpoint.NewFromFloat(t.Price)
|
||||
quantity := fixedpoint.NewFromFloat(t.Quantity)
|
||||
quoteQuantity := fixedpoint.NewFromFloat(t.QuoteQuantity)
|
||||
|
@ -125,6 +122,9 @@ func (p *Position) AddTrade(t types.Trade) (fixedpoint.Value, bool) {
|
|||
|
||||
}
|
||||
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
// Base > 0 means we're in long position
|
||||
// Base < 0 means we're in short position
|
||||
switch t.Side {
|
||||
|
|
Loading…
Reference in New Issue
Block a user