From 778a3d8be100143b5e838e391c5b30dcc6b20621 Mon Sep 17 00:00:00 2001 From: austin362667 Date: Wed, 19 Oct 2022 17:24:27 +0800 Subject: [PATCH] strategy:irr: clean up strategy:irr: clean up strategy:irr: clean up strategy:irr: clean up --- config/irr.yaml | 12 ++---------- pkg/strategy/irr/strategy.go | 18 +++++------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/config/irr.yaml b/config/irr.yaml index eb899c093..302980d28 100644 --- a/config/irr.yaml +++ b/config/irr.yaml @@ -22,18 +22,10 @@ exchangeStrategies: irr: symbol: BTCBUSD # in milliseconds(ms) + # must > 10 ms hftInterval: 1000 - # indicator window - window: 0 - # maxima position in USD - amount: 100 + # qty per trade quantity: 0.001 - # minProfit pips in USD - pips: 0.0 - # alpha1: negative return reversion - NR: true - # alpha2: moving average reversion - MR: true # Draw pnl drawGraph: true graphPNLPath: "./pnl.png" diff --git a/pkg/strategy/irr/strategy.go b/pkg/strategy/irr/strategy.go index 8eb010440..dbdf30c82 100644 --- a/pkg/strategy/irr/strategy.go +++ b/pkg/strategy/irr/strategy.go @@ -48,15 +48,9 @@ type Strategy struct { orderExecutor *bbgo.GeneralOrderExecutor bbgo.QuantityOrAmount - MinProfit float64 `json:"pips"` - Interval int `json:"hftInterval"` - NR bool `json:"NR"` - MR bool `json:"MR"` + Interval int `json:"hftInterval"` - // for back-test - Nrr *NRR - Ma *indicator.SMA // realtime book ticker to submit order obBuyPrice uint64 obSellPrice uint64 @@ -399,9 +393,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se log.Infof("box ended at price: %f with time length: %d", boxClosePrice, boxCounter) // box ending, should re-balance position nirr := fixedpoint.NewFromFloat(((boxOpenPrice - boxClosePrice) / boxOpenPrice) / (float64(boxCounter) + 1)) - qty := s.QuantityOrAmount.CalculateQuantity(fixedpoint.Value(boxClosePrice)) - qty = qty.Mul(nirr.Abs().Div(fixedpoint.NewFromInt(1000))) - log.Infof("Alpha: %f with Diff Qty: %f", nirr.Float64(), qty.Float64()) + log.Infof("Alpha: %f", nirr.Float64()) if nirr.Float64() < 0 { _, err := s.orderExecutor.SubmitOrders(context.Background(), types.SubmitOrder{ Symbol: s.Symbol, @@ -409,7 +401,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se Quantity: s.Quantity, Type: types.OrderTypeLimitMaker, Price: fixedpoint.NewFromFloat(float64(s.obSellPrice)), - Tag: "irr re-balance: sell", + Tag: "irrSell", }) if err != nil { log.WithError(err) @@ -421,7 +413,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se Quantity: s.Quantity, Type: types.OrderTypeLimitMaker, Price: fixedpoint.NewFromFloat(float64(s.obBuyPrice)), - Tag: "irr re-balance: buy", + Tag: "irrBuy", }) if err != nil { log.WithError(err) @@ -452,7 +444,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se for { select { case <-intervalOpenTicker.C: - time.Sleep(time.Duration(s.Interval/10) * time.Millisecond) + time.Sleep(10 * time.Millisecond) log.Infof("kline open time @ %s", time.Now().Format("2006-01-02 15:04:05.000000")) if s.currentTradePrice > 0 && s.closePrice > 0 {