mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
bollmaker: assign strategy id and instance id
This commit is contained in:
parent
f6ec2e78e6
commit
8fa0e6702c
|
@ -566,6 +566,9 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
s.tradeCollector.OnProfit(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {
|
s.tradeCollector.OnProfit(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {
|
||||||
log.Infof("generated profit: %v", profit)
|
log.Infof("generated profit: %v", profit)
|
||||||
p := s.state.Position.NewProfit(trade, profit, netProfit)
|
p := s.state.Position.NewProfit(trade, profit, netProfit)
|
||||||
|
p.Strategy = ID
|
||||||
|
p.StrategyInstanceID = instanceID
|
||||||
|
|
||||||
s.state.ProfitStats.AddProfit(p)
|
s.state.ProfitStats.AddProfit(p)
|
||||||
s.Notify(&p)
|
s.Notify(&p)
|
||||||
s.Notify(&s.state.ProfitStats)
|
s.Notify(&s.state.ProfitStats)
|
||||||
|
|
|
@ -60,30 +60,28 @@ func (p *Position) NewProfit(trade Trade, profit, netProfit fixedpoint.Value) Pr
|
||||||
QuoteCurrency: p.QuoteCurrency,
|
QuoteCurrency: p.QuoteCurrency,
|
||||||
BaseCurrency: p.BaseCurrency,
|
BaseCurrency: p.BaseCurrency,
|
||||||
AverageCost: p.AverageCost,
|
AverageCost: p.AverageCost,
|
||||||
|
|
||||||
// profit related fields
|
// profit related fields
|
||||||
Profit: profit,
|
Profit: profit,
|
||||||
NetProfit: netProfit,
|
NetProfit: netProfit,
|
||||||
ProfitMargin: profit.Div(trade.QuoteQuantity),
|
ProfitMargin: profit.Div(trade.QuoteQuantity),
|
||||||
NetProfitMargin: netProfit.Div(trade.QuoteQuantity),
|
NetProfitMargin: netProfit.Div(trade.QuoteQuantity),
|
||||||
|
|
||||||
// trade related fields
|
// trade related fields
|
||||||
TradeID: trade.ID,
|
TradeID: trade.ID,
|
||||||
Price: trade.Price,
|
Side: trade.Side,
|
||||||
Quantity: trade.Quantity,
|
IsBuyer: trade.IsBuyer,
|
||||||
QuoteQuantity: trade.QuoteQuantity,
|
IsMaker: trade.IsMaker,
|
||||||
IsMaker: trade.IsMaker,
|
Price: trade.Price,
|
||||||
IsBuyer: trade.IsBuyer,
|
Quantity: trade.Quantity,
|
||||||
Side: trade.Side,
|
QuoteQuantity: trade.QuoteQuantity,
|
||||||
|
// FeeInUSD: 0,
|
||||||
Fee: trade.Fee,
|
Fee: trade.Fee,
|
||||||
FeeCurrency: trade.FeeCurrency,
|
FeeCurrency: trade.FeeCurrency,
|
||||||
|
|
||||||
TradedAt: trade.Time.Time(),
|
Exchange: trade.Exchange,
|
||||||
|
IsMargin: trade.IsMargin,
|
||||||
IsFutures: trade.IsFutures,
|
IsFutures: trade.IsFutures,
|
||||||
IsMargin: trade.IsMargin,
|
IsIsolated: trade.IsIsolated,
|
||||||
IsIsolated: trade.IsIsolated,
|
TradedAt: trade.Time.Time(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user