mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
xdepthmaker: add hedgeMaxOrderQuantity protection
This commit is contained in:
parent
b3d58a9e05
commit
6a5ab424c9
|
@ -207,6 +207,8 @@ type Strategy struct {
|
||||||
|
|
||||||
HedgeStrategy HedgeStrategy `json:"hedgeStrategy"`
|
HedgeStrategy HedgeStrategy `json:"hedgeStrategy"`
|
||||||
|
|
||||||
|
HedgeMaxOrderQuantity fixedpoint.Value `json:"hedgeMaxOrderQuantity"`
|
||||||
|
|
||||||
FullReplenishInterval types.Duration `json:"fullReplenishInterval"`
|
FullReplenishInterval types.Duration `json:"fullReplenishInterval"`
|
||||||
|
|
||||||
OrderCancelWaitTime types.Duration `json:"orderCancelWaitTime"`
|
OrderCancelWaitTime types.Duration `json:"orderCancelWaitTime"`
|
||||||
|
@ -599,6 +601,11 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) error {
|
||||||
|
|
||||||
quantity := pos.Abs()
|
quantity := pos.Abs()
|
||||||
|
|
||||||
|
if s.HedgeMaxOrderQuantity.Sign() > 0 {
|
||||||
|
s.logger.Infof("hedgeMaxOrderQuantity is set to %s, limiting the given quantity %s", s.HedgeMaxOrderQuantity.String(), quantity.String())
|
||||||
|
quantity = fixedpoint.Min(s.HedgeMaxOrderQuantity, quantity)
|
||||||
|
}
|
||||||
|
|
||||||
switch s.HedgeStrategy {
|
switch s.HedgeStrategy {
|
||||||
case HedgeStrategyMarket:
|
case HedgeStrategyMarket:
|
||||||
return s.executeHedgeMarket(ctx, side, quantity)
|
return s.executeHedgeMarket(ctx, side, quantity)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user