mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
FEATURE: emit position when position updated and reset
This commit is contained in:
parent
e3a4887302
commit
0616c73a88
|
@ -215,6 +215,9 @@ func (s *Strategy) runTakeProfitReady(ctx context.Context, next State) {
|
|||
// reset position and open new round for profit stats before position opening
|
||||
s.Position.Reset()
|
||||
|
||||
// emit position
|
||||
s.EmitPosition(s.Position)
|
||||
|
||||
// store into redis
|
||||
bbgo.Sync(ctx, s)
|
||||
|
||||
|
|
|
@ -237,6 +237,9 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
|
||||
// update take profit price here
|
||||
s.updateTakeProfitPrice()
|
||||
|
||||
// emit position update
|
||||
s.EmitPosition(position)
|
||||
})
|
||||
|
||||
s.OrderExecutor.ActiveMakerOrders().OnFilled(func(o types.Order) {
|
||||
|
@ -427,6 +430,14 @@ func (s *Strategy) ContinueNextRound() {
|
|||
s.nextRoundPaused = false
|
||||
}
|
||||
|
||||
func (s *Strategy) GetTakeProfitPrice() fixedpoint.Value {
|
||||
if s.Position.Base == 0 {
|
||||
return fixedpoint.Zero
|
||||
}
|
||||
|
||||
return s.takeProfitPrice
|
||||
}
|
||||
|
||||
func (s *Strategy) UpdateProfitStatsUntilSuccessful(ctx context.Context) error {
|
||||
var op = func() error {
|
||||
if updated, err := s.UpdateProfitStats(ctx); err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user