Skip to content

Commit

Permalink
scmaker: basic prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jun 14, 2023
1 parent 3f4cc0b commit 80f1b46
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 1 deletion.
50 changes: 50 additions & 0 deletions config/scmaker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
sessions:
binance:
exchange: max
envVarPrefix: max


exchangeStrategies:
- on: max
scmaker:
symbol: USDCUSDT

## adjustmentUpdateInterval is the interval for adjusting position
adjustmentUpdateInterval: 1m

## liquidityUpdateInterval is the interval for updating liquidity orders
liquidityUpdateInterval: 1h

midPriceEMA:
interval: 1h
window: 99

## priceRangeBollinger is used for the liquidity price range
priceRangeBollinger:
interval: 1h
window: 10
k: 1.0

numOfLiquidityLayers: 10

liquidityLayerTick: 0.01

strengthInterval: 1m

liquidityScale:
exp:
domain: [0, 10]
range: [100, 500]

backtest:
sessions:
- max
startTime: "2023-05-01"
endTime: "2023-06-01"
symbols:
- USDCUSDT
account:
max:
balances:
USDC: 5000
USDT: 5000
1 change: 1 addition & 0 deletions pkg/cmd/strategy/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
_ "github.com/c9s/bbgo/pkg/strategy/rebalance"
_ "github.com/c9s/bbgo/pkg/strategy/rsmaker"
_ "github.com/c9s/bbgo/pkg/strategy/schedule"
_ "github.com/c9s/bbgo/pkg/strategy/scmaker"
_ "github.com/c9s/bbgo/pkg/strategy/skeleton"
_ "github.com/c9s/bbgo/pkg/strategy/supertrend"
_ "github.com/c9s/bbgo/pkg/strategy/support"
Expand Down
44 changes: 44 additions & 0 deletions pkg/strategy/scmaker/intensity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package scmaker

import (
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/indicator"
"github.com/c9s/bbgo/pkg/types"
)

type IntensityStream struct {
*indicator.Float64Series

Buy, Sell *indicator.RMAStream
window int
}

func Intensity(source indicator.KLineSubscription, window int) *IntensityStream {
s := &IntensityStream{
Float64Series: indicator.NewFloat64Series(),
window: window,

Buy: indicator.RMA2(indicator.NewFloat64Series(), window, false),
Sell: indicator.RMA2(indicator.NewFloat64Series(), window, false),
}

threshold := fixedpoint.NewFromFloat(100.0)
source.AddSubscriber(func(k types.KLine) {
volume := k.Volume.Float64()

// ignore zero volume events or <= 10usd events
if volume == 0.0 || k.Close.Mul(k.Volume).Compare(threshold) <= 0 {
return
}

c := k.Close.Compare(k.Open)
if c > 0 {
s.Buy.PushAndEmit(volume)
} else if c < 0 {
s.Sell.PushAndEmit(volume)
}
s.Float64Series.PushAndEmit(k.High.Sub(k.Low).Float64())
})

return s
}
Loading

0 comments on commit 80f1b46

Please sign in to comment.