Strategy metric panel
Requirement
In this panel, we will render the metrics of each running strategy. There are some common metrics we are interested in:
- total net profit (gross profit - gross loss - trading fee)
- gross profit (total profit)
- gross loss (total loss)
- trading volume
- running time
Some panel could be different if the strategy is not a position-based strategy, for example, the grid strategy.
For grid strategy, we're interested in:
- How many grids are placed.
- Upper price and lower price. (the top of the grid and the bottom of the grid)
- The number of arbitrages.
- Total arbitrage profits
Implementation
Hence, we need to add a new interface for strategies to export their metrics.
type MetricsExporter interface {
Metrics() interface{}
}
And each strategy can export their own metrics structs that could be marshalled into JSON format for the front-end application to render.
And the metrics could be fetched from an endpoint like:
https://localhost:3000/exchangeStrategies/metrics
And the response structure could be something like:
[
{ "instanceID": "....", "strategy": "grid", "symbol": "BTCUSDT", "stats": {....}, "status": "RUNNING" },
{ "instanceID": "....", "strategy": "bollmaker", "symbol": "BNBUSDT", "stats": {....}, "status": "STOPPED" },
]
I’m interested in this task and will contribute the frontend part.
@jundesu thank you!
Here’s my draft. Please review it.

- The grid strategy algorithm is easier than other strategies, so I want to implement it first.
- I study other similar products. They all provide the information on my draft. I think the information is necessary for the grid strategy.
If you agree with the draft, I will design the desired json response. Thank you.
@c9s According to my draft, could bbgo server provide the api response for grid strategy?
[
{
"id":"uuid",
"instanceID": "....",
"strategy": "grid",
"symbol": "BTCUSDT",
"metrics": {
"oneDayArbs": 0,
"totalArbs": 3,
"investment": 100,
"totalProfits": 5.6,
"gridProfits": 2.5,
"floatingPNL": 3.1,
"currentPrice": 29000,
"lowestPrice": 25000,
"highestPrice": 35000
},
"status": "RUNNING",
"startTime": 1654938187102
}
]
yes, It's something similar: (I renamed the metrics to stats)
[
{
"id":"uuid",
"instanceID": "....",
"strategy": "grid",
"grid": {
"symbol": "BTCUSDT",
..... other grid strategy settings
},
"stats": {
"oneDayArbs": 0,
"totalArbs": 3,
"investment": 100,
"totalProfits": 5.6,
"gridProfits": 2.5,
"floatingPNL": 3.1,
"currentPrice": 29000,
"lowestPrice": 25000,
"highestPrice": 35000
},
"status": "RUNNING",
"startTime": 1654938187102
}
]
our grid strategy config looks like:
exchangeStrategies:
- on: binance
grid:
symbol: BTCUSDT
quantity: 0.001
# scaleQuantity:
# byPrice:
# exp:
# domain: [20_000, 30_000]
# range: [0.2, 0.001]
gridNumber: 20
profitSpread: 1000.0 # The profit price spread that you want to add to your sell order when your buy order is executed
upperPrice: 30_000.0
lowerPrice: 28_000.0
# long: true # The sell order is submitted in the same order amount as the filled corresponding buy order, rather than the same quantity.