mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
bollmaker: use the new profit generator method
This commit is contained in:
parent
197d750cb4
commit
5fe0b69927
|
@ -571,17 +571,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
s.tradeCollector = bbgo.NewTradeCollector(s.Symbol, s.state.Position, s.orderStore)
|
||||
s.tradeCollector.OnProfit(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {
|
||||
log.Infof("generated profit: %v", profit)
|
||||
p := types.Profit{
|
||||
Symbol: s.Symbol,
|
||||
Profit: profit,
|
||||
NetProfit: netProfit,
|
||||
QuoteQuantity: trade.QuoteQuantity,
|
||||
ProfitMargin: profit.Div(trade.QuoteQuantity),
|
||||
NetProfitMargin: netProfit.Div(trade.QuoteQuantity),
|
||||
QuoteCurrency: s.state.Position.QuoteCurrency,
|
||||
BaseCurrency: s.state.Position.BaseCurrency,
|
||||
TradedAt: trade.Time.Time(),
|
||||
}
|
||||
p := s.state.Position.NewProfit(trade, profit, netProfit)
|
||||
s.state.ProfitStats.AddProfit(p)
|
||||
s.Notify(&p)
|
||||
s.Notify(&s.state.ProfitStats)
|
||||
|
|
|
@ -54,8 +54,8 @@ type Position struct {
|
|||
}
|
||||
|
||||
// NewProfit generates the profit object from the current position
|
||||
func (p *Position) NewProfit(profit, netProfit fixedpoint.Value, trade Trade) *Profit {
|
||||
return &Profit{
|
||||
func (p *Position) NewProfit(trade Trade, profit, netProfit fixedpoint.Value) Profit {
|
||||
return Profit{
|
||||
Symbol: p.Symbol,
|
||||
QuoteCurrency: p.QuoteCurrency,
|
||||
BaseCurrency: p.BaseCurrency,
|
||||
|
|
Loading…
Reference in New Issue
Block a user