xmaker: add config bid/ask margin metrics

This commit is contained in:
c9s 2024-08-27 15:35:39 +08:00
parent 7e65aca62e
commit b3c8739983
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 16 additions and 0 deletions

View File

@ -38,6 +38,18 @@ var configMaxExposureMetrics = prometheus.NewGaugeVec(
Help: "",
}, []string{"strategy_type", "strategy_id", "symbol"})
var configBidMarginMetrics = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "xmaker_config_bid_margin",
Help: "",
}, []string{"strategy_type", "strategy_id", "symbol"})
var configAskMarginMetrics = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "xmaker_config_ask_margin",
Help: "",
}, []string{"strategy_type", "strategy_id", "symbol"})
func init() {
prometheus.MustRegister(
openOrderBidExposureInUsdMetrics,
@ -46,5 +58,7 @@ func init() {
makerBestAskPriceMetrics,
configNumOfLayersMetrics,
configMaxExposureMetrics,
configBidMarginMetrics,
configAskMarginMetrics,
)
}

View File

@ -894,6 +894,8 @@ func (s *Strategy) CrossRun(
configLabels := prometheus.Labels{"strategy_id": s.InstanceID(), "strategy_type": ID, "symbol": s.Symbol}
configNumOfLayersMetrics.With(configLabels).Set(float64(s.NumLayers))
configMaxExposureMetrics.With(configLabels).Set(s.MaxExposurePosition.Float64())
configBidMarginMetrics.With(configLabels).Set(s.BidMargin.Float64())
configAskMarginMetrics.With(configLabels).Set(s.AskMargin.Float64())
if s.Position == nil {
s.Position = types.NewPositionFromMarket(s.makerMarket)