mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
add open orders metrics
This commit is contained in:
parent
c6d4ebf57b
commit
136c2cd36f
|
@ -61,6 +61,8 @@ func (s *Strategy) syncActiveOrders(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
metricsNumOfOpenOrders.With(s.newPrometheusLabels()).Set(float64(len(openOrders)))
|
||||||
|
|
||||||
// open orders query time + 1 min means this open orders may be changed !
|
// open orders query time + 1 min means this open orders may be changed !
|
||||||
openOrdersExpiredTime := time.Now().Add(1 * time.Minute)
|
openOrdersExpiredTime := time.Now().Add(1 * time.Minute)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ var (
|
||||||
metricsGridBaseInvestment *prometheus.GaugeVec
|
metricsGridBaseInvestment *prometheus.GaugeVec
|
||||||
|
|
||||||
metricsGridFilledOrderPrice *prometheus.GaugeVec
|
metricsGridFilledOrderPrice *prometheus.GaugeVec
|
||||||
|
|
||||||
|
metricsNumOfOpenOrders *prometheus.GaugeVec
|
||||||
)
|
)
|
||||||
|
|
||||||
func labelKeys(labels prometheus.Labels) []string {
|
func labelKeys(labels prometheus.Labels) []string {
|
||||||
|
@ -167,6 +169,18 @@ func initMetrics(extendedLabels []string) {
|
||||||
"side",
|
"side",
|
||||||
}, extendedLabels...),
|
}, extendedLabels...),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
metricsNumOfOpenOrders = prometheus.NewGaugeVec(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Name: "bbgo_grid2_num_of_open_orders",
|
||||||
|
Help: "number of open orders",
|
||||||
|
},
|
||||||
|
append([]string{
|
||||||
|
"exchange", // exchange name
|
||||||
|
"symbol", // symbol of the market
|
||||||
|
}, extendedLabels...),
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var metricsRegistered = false
|
var metricsRegistered = false
|
||||||
|
@ -193,6 +207,7 @@ func registerMetrics() {
|
||||||
metricsGridQuoteInvestment,
|
metricsGridQuoteInvestment,
|
||||||
metricsGridBaseInvestment,
|
metricsGridBaseInvestment,
|
||||||
metricsGridFilledOrderPrice,
|
metricsGridFilledOrderPrice,
|
||||||
|
metricsNumOfOpenOrders,
|
||||||
)
|
)
|
||||||
metricsRegistered = true
|
metricsRegistered = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user