mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +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) {
|
func (p *Position) AddTrade(t types.Trade) (fixedpoint.Value, bool) {
|
||||||
p.Lock()
|
|
||||||
defer p.Unlock()
|
|
||||||
|
|
||||||
price := fixedpoint.NewFromFloat(t.Price)
|
price := fixedpoint.NewFromFloat(t.Price)
|
||||||
quantity := fixedpoint.NewFromFloat(t.Quantity)
|
quantity := fixedpoint.NewFromFloat(t.Quantity)
|
||||||
quoteQuantity := fixedpoint.NewFromFloat(t.QuoteQuantity)
|
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 long position
|
||||||
// Base < 0 means we're in short position
|
// Base < 0 means we're in short position
|
||||||
switch t.Side {
|
switch t.Side {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user