mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 03:23:52 +00:00
xmaker: fix profit fixer fee settings
This commit is contained in:
parent
2cdd9072c2
commit
969e813c7f
|
@ -1453,6 +1453,20 @@ func (s *Strategy) CrossRun(
|
||||||
s.Position.StrategyInstanceID = instanceID
|
s.Position.StrategyInstanceID = instanceID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.makerSession.MakerFeeRate.Sign() > 0 || s.makerSession.TakerFeeRate.Sign() > 0 {
|
||||||
|
s.Position.SetExchangeFeeRate(types.ExchangeName(s.MakerExchange), types.ExchangeFee{
|
||||||
|
MakerFeeRate: s.makerSession.MakerFeeRate,
|
||||||
|
TakerFeeRate: s.makerSession.TakerFeeRate,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.sourceSession.MakerFeeRate.Sign() > 0 || s.sourceSession.TakerFeeRate.Sign() > 0 {
|
||||||
|
s.Position.SetExchangeFeeRate(types.ExchangeName(s.SourceExchange), types.ExchangeFee{
|
||||||
|
MakerFeeRate: s.sourceSession.MakerFeeRate,
|
||||||
|
TakerFeeRate: s.sourceSession.TakerFeeRate,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
s.Position.UpdateMetrics()
|
s.Position.UpdateMetrics()
|
||||||
bbgo.Notify("xmaker: %s position is restored", s.Symbol, s.Position)
|
bbgo.Notify("xmaker: %s position is restored", s.Symbol, s.Position)
|
||||||
|
|
||||||
|
@ -1469,20 +1483,6 @@ func (s *Strategy) CrossRun(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.makerSession.MakerFeeRate.Sign() > 0 || s.makerSession.TakerFeeRate.Sign() > 0 {
|
|
||||||
s.Position.SetExchangeFeeRate(types.ExchangeName(s.MakerExchange), types.ExchangeFee{
|
|
||||||
MakerFeeRate: s.makerSession.MakerFeeRate,
|
|
||||||
TakerFeeRate: s.makerSession.TakerFeeRate,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.sourceSession.MakerFeeRate.Sign() > 0 || s.sourceSession.TakerFeeRate.Sign() > 0 {
|
|
||||||
s.Position.SetExchangeFeeRate(types.ExchangeName(s.SourceExchange), types.ExchangeFee{
|
|
||||||
MakerFeeRate: s.sourceSession.MakerFeeRate,
|
|
||||||
TakerFeeRate: s.sourceSession.TakerFeeRate,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
s.priceSolver = pricesolver.NewSimplePriceResolver(sourceMarkets)
|
s.priceSolver = pricesolver.NewSimplePriceResolver(sourceMarkets)
|
||||||
s.priceSolver.BindStream(s.sourceSession.MarketDataStream)
|
s.priceSolver.BindStream(s.sourceSession.MarketDataStream)
|
||||||
|
|
||||||
|
@ -1492,7 +1492,6 @@ func (s *Strategy) CrossRun(
|
||||||
}
|
}
|
||||||
|
|
||||||
s.sourceSession.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(k types.KLine) {
|
s.sourceSession.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(k types.KLine) {
|
||||||
s.priceSolver.Update(k.Symbol, k.Close)
|
|
||||||
feeToken := s.sourceSession.Exchange.PlatformFeeCurrency()
|
feeToken := s.sourceSession.Exchange.PlatformFeeCurrency()
|
||||||
if feePrice, ok := s.priceSolver.ResolvePrice(feeToken, "USDT"); ok {
|
if feePrice, ok := s.priceSolver.ResolvePrice(feeToken, "USDT"); ok {
|
||||||
s.Position.SetFeeAverageCost(feeToken, feePrice)
|
s.Position.SetFeeAverageCost(feeToken, feePrice)
|
||||||
|
@ -1509,6 +1508,11 @@ func (s *Strategy) CrossRun(
|
||||||
}
|
}
|
||||||
|
|
||||||
position := types.NewPositionFromMarket(s.makerMarket)
|
position := types.NewPositionFromMarket(s.makerMarket)
|
||||||
|
position.ExchangeFeeRates = s.Position.ExchangeFeeRates
|
||||||
|
position.FeeRate = s.Position.FeeRate
|
||||||
|
position.StrategyInstanceID = s.Position.StrategyInstanceID
|
||||||
|
position.Strategy = s.Position.Strategy
|
||||||
|
|
||||||
profitStats := types.NewProfitStats(s.makerMarket)
|
profitStats := types.NewProfitStats(s.makerMarket)
|
||||||
|
|
||||||
fixer := common.NewProfitFixer()
|
fixer := common.NewProfitFixer()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user