mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xdepthmaker: set converter manager
This commit is contained in:
parent
1ad2bc5f34
commit
473a6bc108
|
@ -49,6 +49,9 @@ type CrossExchangeMarketMakingStrategy struct {
|
|||
Position *types.Position `json:"position,omitempty" persistence:"position"`
|
||||
ProfitStats *types.ProfitStats `json:"profitStats,omitempty" persistence:"profit_stats"`
|
||||
CoveredPosition fixedpoint.Value `json:"coveredPosition,omitempty" persistence:"covered_position"`
|
||||
|
||||
core.ConverterManager
|
||||
|
||||
mu sync.Mutex
|
||||
|
||||
MakerOrderExecutor, HedgeOrderExecutor *bbgo.GeneralOrderExecutor
|
||||
|
@ -107,6 +110,10 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
|||
s.makerMarket.Symbol,
|
||||
strategyID, instanceID,
|
||||
s.Position)
|
||||
|
||||
// update converter manager
|
||||
s.MakerOrderExecutor.TradeCollector().ConverterManager = s.ConverterManager
|
||||
|
||||
s.MakerOrderExecutor.BindEnvironment(environ)
|
||||
s.MakerOrderExecutor.BindProfitStats(s.ProfitStats)
|
||||
s.MakerOrderExecutor.Bind()
|
||||
|
@ -122,6 +129,9 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
|||
s.HedgeOrderExecutor.BindEnvironment(environ)
|
||||
s.HedgeOrderExecutor.BindProfitStats(s.ProfitStats)
|
||||
s.HedgeOrderExecutor.Bind()
|
||||
|
||||
s.HedgeOrderExecutor.TradeCollector().ConverterManager = s.ConverterManager
|
||||
|
||||
s.HedgeOrderExecutor.TradeCollector().OnPositionUpdate(func(position *types.Position) {
|
||||
// bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
@ -148,8 +158,6 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
|||
type Strategy struct {
|
||||
*CrossExchangeMarketMakingStrategy
|
||||
|
||||
*core.ConverterManager
|
||||
|
||||
Environment *bbgo.Environment
|
||||
|
||||
Symbol string `json:"symbol"`
|
||||
|
|
|
@ -19,16 +19,19 @@ const (
|
|||
PositionClosed = PositionType("Closed")
|
||||
)
|
||||
|
||||
// ExchangeFee stores the exchange fee rate
|
||||
type ExchangeFee struct {
|
||||
MakerFeeRate fixedpoint.Value
|
||||
TakerFeeRate fixedpoint.Value
|
||||
}
|
||||
|
||||
// PositionRisk stores the position risk data
|
||||
type PositionRisk struct {
|
||||
Leverage fixedpoint.Value `json:"leverage"`
|
||||
LiquidationPrice fixedpoint.Value `json:"liquidationPrice"`
|
||||
Leverage fixedpoint.Value `json:"leverage,omitempty"`
|
||||
LiquidationPrice fixedpoint.Value `json:"liquidationPrice,omitempty"`
|
||||
}
|
||||
|
||||
// Position stores the position data
|
||||
type Position struct {
|
||||
Symbol string `json:"symbol" db:"symbol"`
|
||||
BaseCurrency string `json:"baseCurrency" db:"base"`
|
||||
|
@ -281,8 +284,14 @@ type FuturesPosition struct {
|
|||
ExchangeFeeRates map[ExchangeName]ExchangeFee `json:"exchangeFeeRates"`
|
||||
|
||||
// Futures data fields
|
||||
// -------------------
|
||||
// Isolated margin mode
|
||||
Isolated bool `json:"isolated"`
|
||||
|
||||
// UpdateTime is the time when the position is updated
|
||||
UpdateTime int64 `json:"updateTime"`
|
||||
|
||||
// PositionRisk stores the position risk data
|
||||
PositionRisk *PositionRisk
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user