bbgo: add description to the open position options

This commit is contained in:
c9s 2022-09-09 17:50:21 +08:00
parent 8dca24e9ee
commit 5f2254e2cb
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -132,24 +132,34 @@ func (e *GeneralOrderExecutor) SubmitOrders(ctx context.Context, submitOrders ..
type OpenPositionOptions struct {
// Long is for open a long position
// Long or Short must be set
Long bool
Long bool `json:"long"`
// Short is for open a short position
// Long or Short must be set
Short bool
Short bool `json:"short"`
// Leverage is used for leveraged position and account
Leverage fixedpoint.Value
Leverage fixedpoint.Value `json:"leverage,omitempty"`
Quantity fixedpoint.Value
MarketOrder bool
LimitOrder bool
// Quantity will be used first, it will override the leverage if it's given.
Quantity fixedpoint.Value `json:"quantity,omitempty"`
// MarketOrder set to true to open a position with a market order
MarketOrder bool
// LimitOrder set to true to open a position with a limit order
LimitOrder bool
// LimitTakerRatio is used when LimitOrder = true, it adjusts the price of the limit order with a ratio.
// So you can ensure that the limit order can be a taker order. Higher the ratio, higher the chance it could be a taker order.
LimitTakerRatio fixedpoint.Value
CurrentPrice fixedpoint.Value
Tag string
}
func (e *GeneralOrderExecutor) OpenPosition(ctx context.Context, options OpenPositionOptions) error {
log.Infof("opening %s position: %+v", e.position.Symbol, options)
price := options.CurrentPrice
submitOrder := types.SubmitOrder{
Symbol: e.position.Symbol,