mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +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) {
|
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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user