mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
core: add Initialize() method to the converter interface
This commit is contained in:
parent
df8d52adda
commit
1ad2bc5f34
|
@ -5,6 +5,7 @@ import "github.com/c9s/bbgo/pkg/types"
|
|||
type Converter interface {
|
||||
OrderConverter
|
||||
TradeConverter
|
||||
Initialize() error
|
||||
}
|
||||
|
||||
// OrderConverter converts the order to another order
|
||||
|
@ -29,6 +30,10 @@ func NewDynamicConverter(orderConverter OrderConvertFunc, tradeConverter TradeCo
|
|||
return &DynamicConverter{orderConverter: orderConverter, tradeConverter: tradeConverter}
|
||||
}
|
||||
|
||||
func (c *DynamicConverter) Initialize() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *DynamicConverter) ConvertOrder(order types.Order) (types.Order, error) {
|
||||
return c.orderConverter(order)
|
||||
}
|
||||
|
@ -47,6 +52,10 @@ func NewSymbolConverter(fromSymbol, toSymbol string) *SymbolConverter {
|
|||
return &SymbolConverter{FromSymbol: fromSymbol, ToSymbol: toSymbol}
|
||||
}
|
||||
|
||||
func (c *SymbolConverter) Initialize() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *SymbolConverter) ConvertOrder(order types.Order) (types.Order, error) {
|
||||
if order.Symbol == c.FromSymbol {
|
||||
order.Symbol = c.ToSymbol
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"golang.org/x/time/rate"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/core"
|
||||
"github.com/c9s/bbgo/pkg/exchange/retry"
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/c9s/bbgo/pkg/strategy/common"
|
||||
|
@ -147,6 +148,8 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
|||
type Strategy struct {
|
||||
*CrossExchangeMarketMakingStrategy
|
||||
|
||||
*core.ConverterManager
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
||||
Symbol string `json:"symbol"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user