mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
strategy: fix irr
This commit is contained in:
parent
04453c23ea
commit
26d640ff3b
|
@ -13,22 +13,21 @@ sessions:
|
||||||
|
|
||||||
exchangeStrategies:
|
exchangeStrategies:
|
||||||
- on: binance
|
- on: binance
|
||||||
oneliner:
|
irr:
|
||||||
symbol: BTCBUSD
|
symbol: BTCBUSD
|
||||||
interval: 1m
|
interval: 1s
|
||||||
window: 120
|
window: 120
|
||||||
amount: 5_000.0
|
amount: 5_000.0
|
||||||
|
|
||||||
backtest:
|
backtest:
|
||||||
sessions:
|
sessions:
|
||||||
- binance
|
- binance
|
||||||
startTime: "2021-01-01"
|
startTime: "2022-10-01"
|
||||||
endTime: "2022-09-30"
|
endTime: "2022-10-04"
|
||||||
symbols:
|
symbols:
|
||||||
- BTCBUSD
|
- BTCBUSD
|
||||||
accounts:
|
accounts:
|
||||||
binance:
|
binance:
|
||||||
takerFeeRate: 0.0
|
takerFeeRate: 0.0
|
||||||
balances:
|
balances:
|
||||||
# ETH: 1
|
|
||||||
BUSD: 5_000.0
|
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
|
// use kline direction to prevent reversing position too soon
|
||||||
if diffQty.Sign() > 0 { // && kline.Direction() >= 0
|
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
|
} 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