xmaker: add DepthQuantity

This commit is contained in:
c9s 2022-01-11 22:47:40 +08:00
parent b302adcc7e
commit 081a143ec0

View File

@ -53,6 +53,7 @@ type Strategy struct {
BidMargin fixedpoint.Value `json:"bidMargin"` BidMargin fixedpoint.Value `json:"bidMargin"`
AskMargin fixedpoint.Value `json:"askMargin"` AskMargin fixedpoint.Value `json:"askMargin"`
UseDepthPrice bool `json:"useDepthPrice"` UseDepthPrice bool `json:"useDepthPrice"`
DepthQuantity fixedpoint.Value `json:"depthQuantity"`
EnableBollBandMargin bool `json:"enableBollBandMargin"` EnableBollBandMargin bool `json:"enableBollBandMargin"`
BollBandInterval types.Interval `json:"bollBandInterval"` BollBandInterval types.Interval `json:"bollBandInterval"`
@ -345,8 +346,12 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
accumulativeBidQuantity += bidQuantity accumulativeBidQuantity += bidQuantity
if s.UseDepthPrice { if s.UseDepthPrice {
if s.DepthQuantity > 0 {
bidPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeBuy), s.DepthQuantity)
} else {
bidPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeBuy), accumulativeBidQuantity) bidPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeBuy), accumulativeBidQuantity)
} }
}
bidPrice = bidPrice.MulFloat64(1.0 - bidMargin.Float64()) bidPrice = bidPrice.MulFloat64(1.0 - bidMargin.Float64())
if i > 0 && pips > 0 { if i > 0 && pips > 0 {
@ -394,8 +399,12 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
accumulativeAskQuantity += askQuantity accumulativeAskQuantity += askQuantity
if s.UseDepthPrice { if s.UseDepthPrice {
if s.DepthQuantity > 0 {
askPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeSell), s.DepthQuantity)
} else {
askPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeSell), accumulativeAskQuantity) askPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeSell), accumulativeAskQuantity)
} }
}
askPrice = askPrice.MulFloat64(1.0 + askMargin.Float64()) askPrice = askPrice.MulFloat64(1.0 + askMargin.Float64())
if i > 0 && pips > 0 { if i > 0 && pips > 0 {