all: improve logging

This commit is contained in:
c9s 2023-03-24 02:09:49 +08:00
parent 209fb102fa
commit f3049de2ba
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 16 additions and 9 deletions

View File

@ -32,9 +32,14 @@ crossExchangeStrategies:
futuresSession: binance_futures
symbol: ETHUSDT
leverage: 1.0
incrementalQuoteQuantity: 11
quoteInvestment: 110
incrementalQuoteQuantity: 20
quoteInvestment: 50
shortFundingRate:
high: 0.000%
## when funding rate is higher than this high value, the strategy will start buying spot and opening a short position
high: 0.001%
## when funding rate is lower than this low value, the strategy will start closing futures position and sell the spot
low: -0.01%
## reset will reset the spot/futures positions, the transfer stats and the position state.
reset: true

View File

@ -349,7 +349,7 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
case <-ticker.C:
s.queryAndDetectPremiumIndex(ctx, binanceFutures)
s.sync(ctx)
}
}
}()
@ -370,13 +370,11 @@ func (s *Strategy) queryAndDetectPremiumIndex(ctx context.Context, binanceFuture
return
}
log.Infof("premiumIndex: %+v", premiumIndex)
log.Info(premiumIndex)
if changed := s.detectPremiumIndex(premiumIndex); changed {
log.Infof("position state changed: %s %s", s.positionType, s.State.PositionState.String())
log.Infof("position state changed to -> %s %s", s.positionType, s.State.PositionState.String())
}
s.sync(ctx)
}
func (s *Strategy) sync(ctx context.Context) {
@ -548,6 +546,8 @@ func (s *Strategy) increaseSpotPosition(ctx context.Context) {
if s.State.UsedQuoteInvestment.Compare(s.QuoteInvestment) >= 0 {
// stop increase the position
s.State.PositionState = PositionReady
s.startClosingPosition()
return
}
@ -642,6 +642,7 @@ func (s *Strategy) startOpeningPosition(pt types.PositionType, t time.Time) {
return
}
log.Infof("startOpeningPosition")
s.State.PositionState = PositionOpening
s.positionType = pt
@ -657,6 +658,7 @@ func (s *Strategy) startClosingPosition() {
return
}
log.Infof("startClosingPosition")
s.State.PositionState = PositionClosing
// reset the transfer stats

View File

@ -16,5 +16,5 @@ type PremiumIndex struct {
}
func (i *PremiumIndex) String() string {
return fmt.Sprintf("%s %s %s %s NEXT: %s", i.Symbol, i.MarkPrice.String(), i.LastFundingRate.Percentage(), i.Time, i.NextFundingTime)
return fmt.Sprintf("PremiumIndex | %s | %.4f | %s | %s | NEXT FUNDING TIME: %s", i.Symbol, i.MarkPrice.Float64(), i.LastFundingRate.Percentage(), i.Time, i.NextFundingTime)
}