Skip to content

Conversation

dboyliao
Copy link
Collaborator

No description provided.

@dboyliao dboyliao force-pushed the dboy/trad-78 branch 3 times, most recently from 208ab7f to 8384e8a Compare March 26, 2025 06:56
@dboyliao dboyliao marked this pull request as ready for review March 26, 2025 06:57
@dboyliao dboyliao requested a review from c9s March 26, 2025 06:57
@dboyliao dboyliao changed the title FEAT: [metrics] add prometheus metrics for xdepthmaker FEAT: [metrics] add prometheus metrics on maker market for xdepthmaker Mar 26, 2025
@@ -44,6 +44,9 @@ var makerBestAskPriceMetrics = prometheus.NewGaugeVec(
}, []string{"strategy_type", "strategy_id", "exchange", "symbol"})

func UpdateMakerOpenOrderMetrics(strategyType, strategyId, exchangeName, symbol string, submitOrders []types.SubmitOrder) {
if len(submitOrders) == 0 {
return
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when submitOrders = 0, we should reset metrics?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add this as an extra protection.
There is an early return at line 1212 in strategy.go.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we do not reset metrics before, I don't feel like we need to reset metrics here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.
Working on it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


var openOrdersCountMetrics = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "bbgo_xdepthmaker_market_open_order_count",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be just "bbgo_xdepthmaker_open_order_count"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.


var openOrderExposureInUsdtMetrics = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "bbgo_xdepthmaker_inrange_open_order_exposure_in_usdt",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call it liquidity ?
bbgo_xdepthmaker_liquidity

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rename it into bbgo_xdepthmaker_depth_in_usd.
It feels like a proper naming to me.

})
s.makerBook = types.NewStreamBook(s.Symbol, s.makerSession.ExchangeName)
s.makerBook.BindStream(makerMarketStream)
s.makerBook.OnUpdate(func(_ types.SliceOrderBook) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can pull this closure out to a method of "Strategy"

something like: s.makerBook.OnUpdate(s.handleMakerBookUpdate)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dboyliao dboyliao requested a review from c9s March 26, 2025 07:31
…lated metrics for clarity. Handle metric updates with 0 submit orders.
@dboyliao dboyliao merged commit dbb1616 into main Mar 26, 2025
3 checks passed
@dboyliao dboyliao deleted the dboy/trad-78 branch March 26, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants