mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 19:13:52 +00:00
xmaker: fix buckets with prometheus.ExponentialBuckets and record cancel maker orders metrics
This commit is contained in:
parent
f554d5f594
commit
11fcf8c617
|
@ -6,12 +6,14 @@ var cancelOrderDurationMetrics = prometheus.NewHistogramVec(
|
|||
prometheus.HistogramOpts{
|
||||
Name: "xmaker_cancel_order_duration_milliseconds",
|
||||
Help: "cancel order duration in milliseconds",
|
||||
Buckets: prometheus.ExponentialBuckets(50, 1.3, 10),
|
||||
}, []string{"strategy_type", "strategy_id", "exchange", "symbol"})
|
||||
|
||||
var makerOrderPlacementDurationMetrics = prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "xmaker_maker_order_placement_duration_milliseconds",
|
||||
Help: "maker order placement duration in milliseconds",
|
||||
Buckets: prometheus.ExponentialBuckets(50, 1.3, 10),
|
||||
}, []string{"strategy_type", "strategy_id", "exchange", "symbol"})
|
||||
|
||||
var openOrderBidExposureInUsdMetrics = prometheus.NewGaugeVec(
|
||||
|
|
|
@ -546,12 +546,16 @@ func (s *Strategy) getLayerPrice(
|
|||
}
|
||||
|
||||
func (s *Strategy) updateQuote(ctx context.Context) error {
|
||||
cancelMakerOrdersProfile := timeprofile.Start("cancelMakerOrders")
|
||||
|
||||
if err := s.activeMakerOrders.GracefulCancel(ctx, s.makerSession.Exchange); err != nil {
|
||||
s.logger.Warnf("there are some %s orders not canceled, skipping placing maker orders", s.Symbol)
|
||||
s.activeMakerOrders.Print()
|
||||
return nil
|
||||
}
|
||||
|
||||
cancelOrderDurationMetrics.With(s.metricsLabels).Observe(float64(cancelMakerOrdersProfile.Stop().Milliseconds()))
|
||||
|
||||
if s.activeMakerOrders.NumOfOrders() > 0 {
|
||||
s.logger.Warnf("unable to cancel all %s orders, skipping placing maker orders", s.Symbol)
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user