mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xdepthmaker: replace AtomicAdd with Add
This commit is contained in:
parent
ab3579700f
commit
3048a13f0b
|
@ -1197,7 +1197,7 @@ func align(x, y *Value) bool {
|
||||||
}
|
}
|
||||||
yshift = e
|
yshift = e
|
||||||
// check(0 <= yshift && yshift <= 20)
|
// check(0 <= yshift && yshift <= 20)
|
||||||
//y.coef = (y.coef + halfpow10[yshift]) / pow10[yshift]
|
// y.coef = (y.coef + halfpow10[yshift]) / pow10[yshift]
|
||||||
y.coef = (y.coef) / pow10[yshift]
|
y.coef = (y.coef) / pow10[yshift]
|
||||||
// check(int(y.exp)+yshift == int(x.exp))
|
// check(int(y.exp)+yshift == int(x.exp))
|
||||||
return true
|
return true
|
||||||
|
@ -1364,4 +1364,4 @@ func (x Value) Clamp(min, max Value) Value {
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,8 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
||||||
// 1) short position -> reduce short position
|
// 1) short position -> reduce short position
|
||||||
// 2) short position -> increase short position
|
// 2) short position -> increase short position
|
||||||
if trade.Exchange == s.hedgeSession.ExchangeName {
|
if trade.Exchange == s.hedgeSession.ExchangeName {
|
||||||
s.CoveredPosition.AtomicAdd(c)
|
// TODO: make this atomic
|
||||||
|
s.CoveredPosition = s.CoveredPosition.Add(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.ProfitStats.AddTrade(trade)
|
s.ProfitStats.AddTrade(trade)
|
||||||
|
@ -557,9 +558,9 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
|
||||||
// if the hedge is on sell side, then we should add positive position
|
// if the hedge is on sell side, then we should add positive position
|
||||||
switch side {
|
switch side {
|
||||||
case types.SideTypeSell:
|
case types.SideTypeSell:
|
||||||
s.CoveredPosition.AtomicAdd(quantity)
|
s.CoveredPosition = s.CoveredPosition.Add(quantity)
|
||||||
case types.SideTypeBuy:
|
case types.SideTypeBuy:
|
||||||
s.CoveredPosition.AtomicAdd(quantity.Neg())
|
s.CoveredPosition = s.CoveredPosition.Add(quantity.Neg())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user