Skip to content

Commit 778a3d8

Browse files
committed
strategy:irr: clean up
strategy:irr: clean up strategy:irr: clean up strategy:irr: clean up
1 parent 614209e commit 778a3d8

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

config/irr.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,10 @@ exchangeStrategies:
2222
irr:
2323
symbol: BTCBUSD
2424
# in milliseconds(ms)
25+
# must > 10 ms
2526
hftInterval: 1000
26-
# indicator window
27-
window: 0
28-
# maxima position in USD
29-
amount: 100
27+
# qty per trade
3028
quantity: 0.001
31-
# minProfit pips in USD
32-
pips: 0.0
33-
# alpha1: negative return reversion
34-
NR: true
35-
# alpha2: moving average reversion
36-
MR: true
3729
# Draw pnl
3830
drawGraph: true
3931
graphPNLPath: "./pnl.png"

pkg/strategy/irr/strategy.go

+5-13
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,9 @@ type Strategy struct {
4848
orderExecutor *bbgo.GeneralOrderExecutor
4949

5050
bbgo.QuantityOrAmount
51-
MinProfit float64 `json:"pips"`
5251

53-
Interval int `json:"hftInterval"`
54-
NR bool `json:"NR"`
55-
MR bool `json:"MR"`
52+
Interval int `json:"hftInterval"`
5653

57-
// for back-test
58-
Nrr *NRR
59-
Ma *indicator.SMA
6054
// realtime book ticker to submit order
6155
obBuyPrice uint64
6256
obSellPrice uint64
@@ -399,17 +393,15 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
399393
log.Infof("box ended at price: %f with time length: %d", boxClosePrice, boxCounter)
400394
// box ending, should re-balance position
401395
nirr := fixedpoint.NewFromFloat(((boxOpenPrice - boxClosePrice) / boxOpenPrice) / (float64(boxCounter) + 1))
402-
qty := s.QuantityOrAmount.CalculateQuantity(fixedpoint.Value(boxClosePrice))
403-
qty = qty.Mul(nirr.Abs().Div(fixedpoint.NewFromInt(1000)))
404-
log.Infof("Alpha: %f with Diff Qty: %f", nirr.Float64(), qty.Float64())
396+
log.Infof("Alpha: %f", nirr.Float64())
405397
if nirr.Float64() < 0 {
406398
_, err := s.orderExecutor.SubmitOrders(context.Background(), types.SubmitOrder{
407399
Symbol: s.Symbol,
408400
Side: types.SideTypeSell,
409401
Quantity: s.Quantity,
410402
Type: types.OrderTypeLimitMaker,
411403
Price: fixedpoint.NewFromFloat(float64(s.obSellPrice)),
412-
Tag: "irr re-balance: sell",
404+
Tag: "irrSell",
413405
})
414406
if err != nil {
415407
log.WithError(err)
@@ -421,7 +413,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
421413
Quantity: s.Quantity,
422414
Type: types.OrderTypeLimitMaker,
423415
Price: fixedpoint.NewFromFloat(float64(s.obBuyPrice)),
424-
Tag: "irr re-balance: buy",
416+
Tag: "irrBuy",
425417
})
426418
if err != nil {
427419
log.WithError(err)
@@ -452,7 +444,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
452444
for {
453445
select {
454446
case <-intervalOpenTicker.C:
455-
time.Sleep(time.Duration(s.Interval/10) * time.Millisecond)
447+
time.Sleep(10 * time.Millisecond)
456448
log.Infof("kline open time @ %s", time.Now().Format("2006-01-02 15:04:05.000000"))
457449

458450
if s.currentTradePrice > 0 && s.closePrice > 0 {

0 commit comments

Comments
 (0)