mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
strategy: fix irr
This commit is contained in:
parent
04453c23ea
commit
26d640ff3b
|
@ -13,22 +13,21 @@ sessions:
|
|||
|
||||
exchangeStrategies:
|
||||
- on: binance
|
||||
oneliner:
|
||||
irr:
|
||||
symbol: BTCBUSD
|
||||
interval: 1m
|
||||
interval: 1s
|
||||
window: 120
|
||||
amount: 5_000.0
|
||||
|
||||
backtest:
|
||||
sessions:
|
||||
- binance
|
||||
startTime: "2021-01-01"
|
||||
endTime: "2022-09-30"
|
||||
startTime: "2022-10-01"
|
||||
endTime: "2022-10-04"
|
||||
symbols:
|
||||
- BTCBUSD
|
||||
accounts:
|
||||
binance:
|
||||
takerFeeRate: 0.0
|
||||
balances:
|
||||
# ETH: 1
|
||||
BUSD: 5_000.0
|
||||
|
|
|
@ -213,9 +213,21 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
|
||||
// use kline direction to prevent reversing position too soon
|
||||
if diffQty.Sign() > 0 { // && kline.Direction() >= 0
|
||||
s.orderExecutor.OpenPosition(context.Background(), bbgo.OpenPositionOptions{Quantity: diffQty.Abs(), Long: true, LimitOrder: false})
|
||||
_, _ = s.orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
|
||||
Symbol: s.Symbol,
|
||||
Side: types.SideTypeBuy,
|
||||
Quantity: diffQty.Abs(),
|
||||
Type: types.OrderTypeMarket,
|
||||
Tag: "irr buy more",
|
||||
})
|
||||
} else if diffQty.Sign() < 0 { // && kline.Direction() <= 0
|
||||
s.orderExecutor.OpenPosition(context.Background(), bbgo.OpenPositionOptions{Quantity: diffQty.Abs(), Short: true, LimitOrder: false})
|
||||
_, _ = s.orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
|
||||
Symbol: s.Symbol,
|
||||
Side: types.SideTypeSell,
|
||||
Quantity: diffQty.Abs(),
|
||||
Type: types.OrderTypeMarket,
|
||||
Tag: "irr sell more",
|
||||
})
|
||||
}
|
||||
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue
Block a user