mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
add MaxExposurePosition settings
This commit is contained in:
parent
4ed95e6070
commit
13a8597d59
|
@ -50,12 +50,13 @@ type Strategy struct {
|
|||
UpdateInterval types.Duration `json:"updateInterval"`
|
||||
HedgeInterval types.Duration `json:"hedgeInterval"`
|
||||
|
||||
Margin fixedpoint.Value `json:"margin"`
|
||||
BidMargin fixedpoint.Value `json:"bidMargin"`
|
||||
AskMargin fixedpoint.Value `json:"askMargin"`
|
||||
Quantity fixedpoint.Value `json:"quantity"`
|
||||
QuantityMultiplier fixedpoint.Value `json:"quantityMultiplier"`
|
||||
DisableHedge bool `json:"disableHedge"`
|
||||
Margin fixedpoint.Value `json:"margin"`
|
||||
BidMargin fixedpoint.Value `json:"bidMargin"`
|
||||
AskMargin fixedpoint.Value `json:"askMargin"`
|
||||
Quantity fixedpoint.Value `json:"quantity"`
|
||||
QuantityMultiplier fixedpoint.Value `json:"quantityMultiplier"`
|
||||
MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"`
|
||||
DisableHedge bool `json:"disableHedge"`
|
||||
|
||||
NumLayers int `json:"numLayers"`
|
||||
Pips int `json:"pips"`
|
||||
|
@ -150,6 +151,18 @@ func (s *Strategy) updateQuote(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
// if max exposure position is configured, we should not:
|
||||
// 1. place bid orders when we already bought too much
|
||||
// 2. place ask orders when we already sold too much
|
||||
if s.MaxExposurePosition > 0 {
|
||||
pos := s.state.HedgePosition.AtomicLoad()
|
||||
if pos < -s.MaxExposurePosition {
|
||||
disableMakerAsk = true
|
||||
} else if pos > s.MaxExposurePosition {
|
||||
disableMakerBid = true
|
||||
}
|
||||
}
|
||||
|
||||
hedgeBalances := s.sourceSession.Account.Balances()
|
||||
hedgeQuota := &bbgo.QuotaTransaction{}
|
||||
if b, ok := hedgeBalances[s.sourceMarket.BaseCurrency]; ok {
|
||||
|
@ -481,4 +494,3 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user