mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xmaker: add DepthQuantity
This commit is contained in:
parent
b302adcc7e
commit
081a143ec0
|
@ -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"`
|
||||||
|
@ -98,7 +99,7 @@ type Strategy struct {
|
||||||
book *types.StreamOrderBook
|
book *types.StreamOrderBook
|
||||||
activeMakerOrders *bbgo.LocalActiveOrderBook
|
activeMakerOrders *bbgo.LocalActiveOrderBook
|
||||||
|
|
||||||
hedgeErrorLimiter *rate.Limiter
|
hedgeErrorLimiter *rate.Limiter
|
||||||
hedgeErrorRateReservation *rate.Reservation
|
hedgeErrorRateReservation *rate.Reservation
|
||||||
|
|
||||||
orderStore *bbgo.OrderStore
|
orderStore *bbgo.OrderStore
|
||||||
|
@ -345,7 +346,11 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
|
||||||
|
|
||||||
accumulativeBidQuantity += bidQuantity
|
accumulativeBidQuantity += bidQuantity
|
||||||
if s.UseDepthPrice {
|
if s.UseDepthPrice {
|
||||||
bidPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeBuy), accumulativeBidQuantity)
|
if s.DepthQuantity > 0 {
|
||||||
|
bidPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeBuy), s.DepthQuantity)
|
||||||
|
} else {
|
||||||
|
bidPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeBuy), accumulativeBidQuantity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bidPrice = bidPrice.MulFloat64(1.0 - bidMargin.Float64())
|
bidPrice = bidPrice.MulFloat64(1.0 - bidMargin.Float64())
|
||||||
|
@ -394,7 +399,11 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
|
||||||
accumulativeAskQuantity += askQuantity
|
accumulativeAskQuantity += askQuantity
|
||||||
|
|
||||||
if s.UseDepthPrice {
|
if s.UseDepthPrice {
|
||||||
askPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeSell), accumulativeAskQuantity)
|
if s.DepthQuantity > 0 {
|
||||||
|
askPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeSell), s.DepthQuantity)
|
||||||
|
} else {
|
||||||
|
askPrice = aggregatePrice(sourceBook.SideBook(types.SideTypeSell), accumulativeAskQuantity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
askPrice = askPrice.MulFloat64(1.0 + askMargin.Float64())
|
askPrice = askPrice.MulFloat64(1.0 + askMargin.Float64())
|
||||||
|
@ -643,7 +652,7 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.hedgeErrorLimiter = rate.NewLimiter(rate.Every(1 * time.Minute), 1)
|
s.hedgeErrorLimiter = rate.NewLimiter(rate.Every(1*time.Minute), 1)
|
||||||
|
|
||||||
// configure sessions
|
// configure sessions
|
||||||
sourceSession, ok := sessions[s.SourceExchange]
|
sourceSession, ok := sessions[s.SourceExchange]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user