mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 03:23:52 +00:00
xdepthmaker: rename last price var to just price
This commit is contained in:
parent
e7c76ddd26
commit
566234d3ab
|
@ -248,7 +248,7 @@ type Strategy struct {
|
||||||
|
|
||||||
askPriceHeartBeat, bidPriceHeartBeat *types.PriceHeartBeat
|
askPriceHeartBeat, bidPriceHeartBeat *types.PriceHeartBeat
|
||||||
|
|
||||||
lastPrice fixedpoint.MutexValue
|
lastSourcePrice fixedpoint.MutexValue
|
||||||
|
|
||||||
stopC, authedC chan struct{}
|
stopC, authedC chan struct{}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ func (s *Strategy) Validate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.HedgeExchange == "" {
|
if s.HedgeExchange == "" {
|
||||||
return errors.New("maker exchange is not configured")
|
return errors.New("hedge exchange is not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.DepthScale == nil {
|
if s.DepthScale == nil {
|
||||||
|
@ -604,12 +604,12 @@ func (s *Strategy) executeHedgeBboCounterParty1(
|
||||||
side types.SideType,
|
side types.SideType,
|
||||||
quantity fixedpoint.Value,
|
quantity fixedpoint.Value,
|
||||||
) error {
|
) error {
|
||||||
lastPrice := s.lastPrice.Get()
|
price := s.lastSourcePrice.Get()
|
||||||
if sourcePrice := s.getSourceBboPrice(side.Reverse()); sourcePrice.Sign() > 0 {
|
if sourcePrice := s.getSourceBboPrice(side.Reverse()); sourcePrice.Sign() > 0 {
|
||||||
lastPrice = sourcePrice
|
price = sourcePrice
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastPrice.IsZero() {
|
if price.IsZero() {
|
||||||
return ErrZeroPrice
|
return ErrZeroPrice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ func (s *Strategy) executeHedgeBboCounterParty1(
|
||||||
s.hedgeMarket,
|
s.hedgeMarket,
|
||||||
side,
|
side,
|
||||||
quantity,
|
quantity,
|
||||||
lastPrice)
|
price)
|
||||||
|
|
||||||
// truncate quantity for the supported precision
|
// truncate quantity for the supported precision
|
||||||
quantity = s.hedgeMarket.TruncateQuantity(quantity)
|
quantity = s.hedgeMarket.TruncateQuantity(quantity)
|
||||||
|
@ -628,8 +628,8 @@ func (s *Strategy) executeHedgeBboCounterParty1(
|
||||||
return ErrZeroQuantity
|
return ErrZeroQuantity
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.hedgeMarket.IsDustQuantity(quantity, lastPrice) {
|
if s.hedgeMarket.IsDustQuantity(quantity, price) {
|
||||||
s.logger.Warnf("skip dust quantity: %s @ price %f", quantity.String(), lastPrice.Float64())
|
s.logger.Warnf("skip dust quantity: %s @ price %f", quantity.String(), price.Float64())
|
||||||
return ErrDustQuantity
|
return ErrDustQuantity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,12 +647,12 @@ func (s *Strategy) executeHedgeMarket(
|
||||||
side types.SideType,
|
side types.SideType,
|
||||||
quantity fixedpoint.Value,
|
quantity fixedpoint.Value,
|
||||||
) error {
|
) error {
|
||||||
lastPrice := s.lastPrice.Get()
|
price := s.lastSourcePrice.Get()
|
||||||
if sourcePrice := s.getSourceBboPrice(side.Reverse()); sourcePrice.Sign() > 0 {
|
if sourcePrice := s.getSourceBboPrice(side.Reverse()); sourcePrice.Sign() > 0 {
|
||||||
lastPrice = sourcePrice
|
price = sourcePrice
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastPrice.IsZero() {
|
if price.IsZero() {
|
||||||
return ErrZeroPrice
|
return ErrZeroPrice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +663,7 @@ func (s *Strategy) executeHedgeMarket(
|
||||||
s.hedgeMarket,
|
s.hedgeMarket,
|
||||||
side,
|
side,
|
||||||
quantity,
|
quantity,
|
||||||
lastPrice)
|
price)
|
||||||
|
|
||||||
// truncate quantity for the supported precision
|
// truncate quantity for the supported precision
|
||||||
quantity = s.hedgeMarket.TruncateQuantity(quantity)
|
quantity = s.hedgeMarket.TruncateQuantity(quantity)
|
||||||
|
@ -671,8 +671,8 @@ func (s *Strategy) executeHedgeMarket(
|
||||||
return ErrZeroQuantity
|
return ErrZeroQuantity
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.hedgeMarket.IsDustQuantity(quantity, lastPrice) {
|
if s.hedgeMarket.IsDustQuantity(quantity, price) {
|
||||||
s.logger.Warnf("skip dust quantity: %s @ price %f", quantity.String(), lastPrice.Float64())
|
s.logger.Warnf("skip dust quantity: %s @ price %f", quantity.String(), price.Float64())
|
||||||
return ErrDustQuantity
|
return ErrDustQuantity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,7 +966,7 @@ func (s *Strategy) updateQuote(ctx context.Context, maxLayer int) {
|
||||||
bestAskPrice := bestAsk.Price
|
bestAskPrice := bestAsk.Price
|
||||||
log.Infof("%s book ticker: best ask / best bid = %v / %v", s.HedgeSymbol, bestAskPrice, bestBidPrice)
|
log.Infof("%s book ticker: best ask / best bid = %v / %v", s.HedgeSymbol, bestAskPrice, bestBidPrice)
|
||||||
|
|
||||||
s.lastPrice.Set(bestBidPrice.Add(bestAskPrice).Div(Two))
|
s.lastSourcePrice.Set(bestBidPrice.Add(bestAskPrice).Div(Two))
|
||||||
|
|
||||||
bookLastUpdateTime := s.sourceBook.LastUpdateTime()
|
bookLastUpdateTime := s.sourceBook.LastUpdateTime()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user