all: reformat code

This commit is contained in:
c9s 2022-07-06 22:35:57 +08:00
parent c9859c9238
commit 81560746bd
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 5 additions and 2 deletions

View File

@ -71,10 +71,12 @@ func (s *TrailingStop2) Bind(session *ExchangeSession, orderExecutor *GeneralOrd
} }
} }
// getRatio returns the ratio between the price and the average cost of the position
func (s *TrailingStop2) getRatio(price fixedpoint.Value, position *types.Position) (fixedpoint.Value, error) { func (s *TrailingStop2) getRatio(price fixedpoint.Value, position *types.Position) (fixedpoint.Value, error) {
switch s.Side { switch s.Side {
case types.SideTypeBuy: case types.SideTypeBuy:
// for short position // for short position, it's:
// (avg_cost - price) / price
return position.AverageCost.Sub(price).Div(price), nil return position.AverageCost.Sub(price).Div(price), nil
case types.SideTypeSell: case types.SideTypeSell:
return price.Sub(position.AverageCost).Div(position.AverageCost), nil return price.Sub(position.AverageCost).Div(position.AverageCost), nil

View File

@ -44,7 +44,7 @@ func IterateFields(obj interface{}, cb func(ft reflect.StructField, fv reflect.V
continue continue
} }
if err := cb(ft, fv) ; err != nil { if err := cb(ft, fv); err != nil {
return err return err
} }
} }

View File

@ -177,6 +177,7 @@ type Strategy struct {
bbgo.StrategyController bbgo.StrategyController
} }
func (s *Strategy) ID() string { func (s *Strategy) ID() string {
return ID return ID
} }