2021-12-27 08:27:05 +00:00
|
|
|
package bbgo
|
|
|
|
|
|
|
|
import "github.com/prometheus/client_golang/prometheus"
|
|
|
|
|
|
|
|
var (
|
|
|
|
metricsConnectionStatus = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_connection_status",
|
|
|
|
Help: "bbgo exchange session connection status",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"channel", // channel: user or market
|
|
|
|
"margin_type", // margin type: none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
2021-12-27 08:27:05 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2024-08-21 07:33:27 +00:00
|
|
|
metricsBalanceLockedMetrics = prometheus.NewGaugeVec(
|
2021-12-27 08:27:05 +00:00
|
|
|
prometheus.GaugeOpts{
|
2021-12-27 09:16:30 +00:00
|
|
|
Name: "bbgo_balances_locked",
|
|
|
|
Help: "bbgo exchange locked balances",
|
2021-12-27 08:27:05 +00:00
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. 1 or 0
|
|
|
|
"symbol", // margin symbol of the connection.
|
2021-12-27 09:16:30 +00:00
|
|
|
"currency",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2024-08-21 07:33:27 +00:00
|
|
|
metricsBalanceAvailableMetrics = prometheus.NewGaugeVec(
|
2021-12-27 09:16:30 +00:00
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_balances_available",
|
|
|
|
Help: "bbgo exchange available balances",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
|
|
|
"currency",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
metricsBalanceDebtMetrics = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_balances_debt",
|
|
|
|
Help: "bbgo exchange balance debt",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
|
|
|
"currency",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
metricsBalanceBorrowedMetrics = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_balances_borrowed",
|
|
|
|
Help: "bbgo exchange balance borrowed",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
|
|
|
"currency",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
metricsBalanceInterestMetrics = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_balances_interest",
|
|
|
|
Help: "bbgo exchange balance interest",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
|
|
|
"currency",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
metricsBalanceNetMetrics = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_balances_net",
|
|
|
|
Help: "bbgo exchange session total net balances",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
2021-12-27 09:16:30 +00:00
|
|
|
"currency",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
metricsTotalBalances = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_balances_total",
|
|
|
|
Help: "bbgo exchange session total balances",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
2021-12-27 08:27:05 +00:00
|
|
|
"currency",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
metricsTradesTotal = prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Name: "bbgo_trades_total",
|
|
|
|
Help: "bbgo exchange session trades",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
|
|
|
"side", // side: buy or sell
|
|
|
|
"liquidity", // maker or taker
|
2021-12-27 08:27:05 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
metricsTradingVolume = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_trading_volume",
|
|
|
|
Help: "bbgo trading volume",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"symbol", // margin symbol of the connection.
|
|
|
|
"side", // side: buy or sell
|
|
|
|
"liquidity", // maker or taker
|
2021-12-27 08:27:05 +00:00
|
|
|
},
|
|
|
|
)
|
2021-12-27 17:39:17 +00:00
|
|
|
|
2024-08-21 07:33:27 +00:00
|
|
|
metricsLastUpdateTimeMetrics = prometheus.NewGaugeVec(
|
2021-12-27 17:39:17 +00:00
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Name: "bbgo_last_update_time",
|
|
|
|
Help: "bbgo last update time of different channel",
|
|
|
|
},
|
|
|
|
[]string{
|
2024-08-21 07:36:35 +00:00
|
|
|
"session",
|
2024-08-21 07:33:27 +00:00
|
|
|
"exchange", // exchange name
|
|
|
|
"margin_type", // margin of connection. none, margin or isolated
|
|
|
|
"channel", // channel: user, market
|
|
|
|
"data_type", // type: balance, ticker, kline, orderbook, trade, order
|
|
|
|
"symbol", // for market data, trade and order
|
|
|
|
"currency", // for balance
|
2021-12-27 17:39:17 +00:00
|
|
|
},
|
|
|
|
)
|
2021-12-27 08:27:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
prometheus.MustRegister(
|
|
|
|
metricsConnectionStatus,
|
2021-12-27 09:16:30 +00:00
|
|
|
metricsTotalBalances,
|
2024-08-21 07:33:27 +00:00
|
|
|
metricsBalanceNetMetrics,
|
|
|
|
metricsBalanceLockedMetrics,
|
|
|
|
metricsBalanceAvailableMetrics,
|
|
|
|
metricsBalanceDebtMetrics,
|
|
|
|
metricsBalanceBorrowedMetrics,
|
|
|
|
metricsBalanceInterestMetrics,
|
2021-12-27 08:27:05 +00:00
|
|
|
metricsTradesTotal,
|
|
|
|
metricsTradingVolume,
|
2024-08-21 07:33:27 +00:00
|
|
|
metricsLastUpdateTimeMetrics,
|
2021-12-27 08:27:05 +00:00
|
|
|
)
|
|
|
|
}
|