Merge pull request #961 from frin1/fix/exit_protective_stop_loss-repay

Feature: Add auto-repay to exit_protective_stop_loss
This commit is contained in:
Yo-An Lin 2022-09-20 12:04:24 +08:00 committed by GitHub
commit 1086845522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,14 +67,15 @@ func (s *ProtectiveStopLoss) placeStopOrder(ctx context.Context, position *types
} }
createdOrders, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ createdOrders, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
Symbol: position.Symbol, Symbol: position.Symbol,
Side: types.SideTypeBuy, Side: types.SideTypeBuy,
Type: types.OrderTypeStopLimit, Type: types.OrderTypeStopLimit,
Quantity: position.GetQuantity(), Quantity: position.GetQuantity(),
Price: s.stopLossPrice.Mul(one.Add(fixedpoint.NewFromFloat(0.005))), // +0.5% from the trigger price, slippage protection Price: s.stopLossPrice.Mul(one.Add(fixedpoint.NewFromFloat(0.005))), // +0.5% from the trigger price, slippage protection
StopPrice: s.stopLossPrice, StopPrice: s.stopLossPrice,
Market: position.Market, Market: position.Market,
Tag: "protectiveStopLoss", Tag: "protectiveStopLoss",
MarginSideEffect: types.SideEffectTypeAutoRepay,
}) })
if len(createdOrders) > 0 { if len(createdOrders) > 0 {