Open c9s opened 2 years ago
I’m interested in this task and will contribute the frontend part.
@jundesu thank you!
Here’s my draft. Please review it.
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.
Requirement
In this panel, we will render the metrics of each running strategy. There are some common metrics we are interested in:
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:
Implementation
Hence, we need to add a new interface for strategies to export their metrics.
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:
And the response structure could be something like: