bbgo: check options.price when limit order taker ratio is given

This commit is contained in:
c9s 2022-09-24 01:27:28 +08:00
parent 14c941c9f3
commit bfc4cc0db1
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -266,6 +266,10 @@ func (e *GeneralOrderExecutor) OpenPosition(ctx context.Context, options OpenPos
// quoteBalance, _ := e.session.Account.Balance(e.position.Market.QuoteCurrency)
if !options.LimitOrderTakerRatio.IsZero() {
if options.Price.IsZero() {
return nil, fmt.Errorf("OpenPositionOptions.Price is zero, can not adjust limit taker order price, options given: %+v", options)
}
if options.Long {
// use higher price to buy (this ensures that our order will be filled)
price = price.Mul(one.Add(options.LimitOrderTakerRatio))