mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
Merge pull request #1452 from c9s/refactor/strategy/common
This commit is contained in:
commit
4a54611d18
|
@ -20,7 +20,7 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -62,7 +62,6 @@ func (s *Strategy) Defaults() error {
|
|||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
|
||||
atr := session.Indicators(s.Symbol).ATR(s.Interval, s.Window)
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -101,7 +101,6 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
|||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
instanceID := s.InstanceID()
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
|
||||
// Fixed spread market making strategy
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -77,7 +77,6 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
|||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
|
||||
s.activeOrderBook = bbgo.NewActiveOrderBook(s.Symbol)
|
||||
|
|
|
@ -32,7 +32,7 @@ func init() {
|
|||
// - place enough total liquidity amount on the order book, for example, 20k USDT value liquidity on both sell and buy
|
||||
// - ensure the spread by placing the orders from the mid price (or the last trade price)
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -81,7 +81,6 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
|||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
|
||||
s.orderGenerator = &LiquidityOrderGenerator{
|
||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -67,7 +67,6 @@ func (s *Strategy) Validate() error {
|
|||
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, s.ID(), s.InstanceID())
|
||||
|
||||
session.UserDataStream.OnStart(func() {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/c9s/bbgo/pkg/indicator/v2"
|
||||
indicatorv2 "github.com/c9s/bbgo/pkg/indicator/v2"
|
||||
"github.com/c9s/bbgo/pkg/strategy/common"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -49,7 +49,6 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
|||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
|
||||
fastRsi := session.Indicators(s.Symbol).RSI(types.IntervalWindow{Interval: s.Interval, Window: s.FastWindow})
|
||||
|
|
|
@ -34,7 +34,7 @@ func init() {
|
|||
|
||||
// Strategy scmaker is a stable coin market maker
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -88,7 +88,6 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
|||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
|
||||
s.book = types.NewStreamBook(s.Symbol)
|
||||
|
|
|
@ -30,7 +30,7 @@ func init() {
|
|||
}
|
||||
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
Market types.Market
|
||||
|
@ -235,7 +235,6 @@ func (s *Strategy) placeWallOrders(ctx context.Context, orderExecutor bbgo.Order
|
|||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
|
||||
// initial required information
|
||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
|
||||
// Fixed spread market making strategy
|
||||
type Strategy struct {
|
||||
*common.Strategy
|
||||
common.Strategy
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
||||
|
@ -109,7 +109,6 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
|||
}
|
||||
s.market = market
|
||||
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, tradingSession, s.market, ID, s.InstanceID())
|
||||
|
||||
s.orderPriceRiskControl = NewOrderPriceRiskControl(
|
||||
|
|
Loading…
Reference in New Issue
Block a user