mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xmaker: add MaxHedgeAccountLeverage option
This commit is contained in:
parent
ad6056834e
commit
ed073264f1
|
@ -119,6 +119,8 @@ type Strategy struct {
|
|||
// MaxExposurePosition defines the unhedged quantity of stop
|
||||
MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"`
|
||||
|
||||
MaxHedgeAccountLeverage fixedpoint.Value `json:"maxHedgeAccountLeverage"`
|
||||
|
||||
DisableHedge bool `json:"disableHedge"`
|
||||
|
||||
NotifyTrade bool `json:"notifyTrade"`
|
||||
|
@ -532,10 +534,9 @@ func (s *Strategy) updateQuote(ctx context.Context) {
|
|||
// calculate credit buffer
|
||||
s.logger.Infof("hedge account net value in usd: %f", netValueInUsd.Float64())
|
||||
|
||||
maximumHedgeAccountLeverage := fixedpoint.NewFromFloat(1.2)
|
||||
maximumValueInUsd := netValueInUsd.Mul(maximumHedgeAccountLeverage)
|
||||
maximumValueInUsd := netValueInUsd.Mul(s.MaxHedgeAccountLeverage)
|
||||
|
||||
s.logger.Infof("hedge account maximum leveraged value in usd: %f", maximumValueInUsd.Float64())
|
||||
s.logger.Infof("hedge account maximum leveraged value in usd: %f (%f x)", maximumValueInUsd.Float64(), s.MaxHedgeAccountLeverage.Float64())
|
||||
|
||||
if quote, ok := hedgeAccount.Balance(s.sourceMarket.QuoteCurrency); ok {
|
||||
debt := quote.Debt()
|
||||
|
@ -562,7 +563,6 @@ func (s *Strategy) updateQuote(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if b, ok := hedgeBalances[s.sourceMarket.BaseCurrency]; ok {
|
||||
// to make bid orders, we need enough base asset in the foreign exchange,
|
||||
|
@ -1037,6 +1037,10 @@ func (s *Strategy) Defaults() error {
|
|||
s.MinMarginLevel = fixedpoint.NewFromFloat(3.0)
|
||||
}
|
||||
|
||||
if s.MaxHedgeAccountLeverage.IsZero() {
|
||||
s.MaxHedgeAccountLeverage = fixedpoint.NewFromFloat(1.2)
|
||||
}
|
||||
|
||||
if s.BidMargin.IsZero() {
|
||||
if !s.Margin.IsZero() {
|
||||
s.BidMargin = s.Margin
|
||||
|
|
Loading…
Reference in New Issue
Block a user