mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
all: reformat code
This commit is contained in:
parent
c9859c9238
commit
81560746bd
|
@ -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) {
|
||||
switch s.Side {
|
||||
case types.SideTypeBuy:
|
||||
// for short position
|
||||
// for short position, it's:
|
||||
// (avg_cost - price) / price
|
||||
return position.AverageCost.Sub(price).Div(price), nil
|
||||
case types.SideTypeSell:
|
||||
return price.Sub(position.AverageCost).Div(position.AverageCost), nil
|
||||
|
|
|
@ -44,7 +44,7 @@ func IterateFields(obj interface{}, cb func(ft reflect.StructField, fv reflect.V
|
|||
continue
|
||||
}
|
||||
|
||||
if err := cb(ft, fv) ; err != nil {
|
||||
if err := cb(ft, fv); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,6 +177,7 @@ type Strategy struct {
|
|||
bbgo.StrategyController
|
||||
}
|
||||
|
||||
|
||||
func (s *Strategy) ID() string {
|
||||
return ID
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user