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
|
||||
}
|
||||
|
||||
metricsNumOfOpenOrders.With(s.newPrometheusLabels()).Set(float64(len(openOrders)))
|
||||
|
||||
// open orders query time + 1 min means this open orders may be changed !
|
||||
openOrdersExpiredTime := time.Now().Add(1 * time.Minute)
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ var (
|
|||
metricsGridBaseInvestment *prometheus.GaugeVec
|
||||
|
||||
metricsGridFilledOrderPrice *prometheus.GaugeVec
|
||||
|
||||
metricsNumOfOpenOrders *prometheus.GaugeVec
|
||||
)
|
||||
|
||||
func labelKeys(labels prometheus.Labels) []string {
|
||||
|
@ -167,6 +169,18 @@ func initMetrics(extendedLabels []string) {
|
|||
"side",
|
||||
}, 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
|
||||
|
@ -193,6 +207,7 @@ func registerMetrics() {
|
|||
metricsGridQuoteInvestment,
|
||||
metricsGridBaseInvestment,
|
||||
metricsGridFilledOrderPrice,
|
||||
metricsNumOfOpenOrders,
|
||||
)
|
||||
metricsRegistered = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user