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