mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
FEATURE: [dca2] store price quantity pairs of the open-position orders into persistence
This commit is contained in:
parent
970c1bb8c7
commit
6676e1e452
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/exchange/retry"
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
|
@ -32,6 +33,16 @@ func (s *Strategy) placeOpenPositionOrders(ctx context.Context) error {
|
|||
|
||||
s.debugOrders(createdOrders)
|
||||
|
||||
// store price quantity pairs into persistence
|
||||
var pqs []PriceQuantity
|
||||
for _, createdOrder := range createdOrders {
|
||||
pqs = append(pqs, PriceQuantity{Price: createdOrder.Price, Quantity: createdOrder.Quantity})
|
||||
}
|
||||
|
||||
s.ProfitStats.OpenPositionPQs = pqs
|
||||
|
||||
bbgo.Sync(ctx, s)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@ import (
|
|||
"github.com/c9s/bbgo/pkg/types"
|
||||
)
|
||||
|
||||
type PriceQuantity struct {
|
||||
Price fixedpoint.Value `json:"price,omitempty"`
|
||||
Quantity fixedpoint.Value `json:"quantity,omitempty"`
|
||||
}
|
||||
|
||||
type ProfitStats struct {
|
||||
Symbol string `json:"symbol"`
|
||||
Market types.Market `json:"market,omitempty"`
|
||||
|
@ -21,6 +26,9 @@ type ProfitStats struct {
|
|||
TotalProfit fixedpoint.Value `json:"totalProfit,omitempty"`
|
||||
TotalFee map[string]fixedpoint.Value `json:"totalFee,omitempty"`
|
||||
|
||||
// used to flexible recovery
|
||||
OpenPositionPQs []PriceQuantity `json:"openPositionPQs,omitempty"`
|
||||
|
||||
types.PersistenceTTL
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user