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) {
|
||||
log.Infof("generated profit: %v", profit)
|
||||
p := s.state.Position.NewProfit(trade, profit, netProfit)
|
||||
p.Strategy = ID
|
||||
p.StrategyInstanceID = instanceID
|
||||
|
||||
s.state.ProfitStats.AddProfit(p)
|
||||
s.Notify(&p)
|
||||
s.Notify(&s.state.ProfitStats)
|
||||
|
|
|
@ -60,30 +60,28 @@ func (p *Position) NewProfit(trade Trade, profit, netProfit fixedpoint.Value) Pr
|
|||
QuoteCurrency: p.QuoteCurrency,
|
||||
BaseCurrency: p.BaseCurrency,
|
||||
AverageCost: p.AverageCost,
|
||||
|
||||
// profit related fields
|
||||
Profit: profit,
|
||||
NetProfit: netProfit,
|
||||
ProfitMargin: profit.Div(trade.QuoteQuantity),
|
||||
NetProfitMargin: netProfit.Div(trade.QuoteQuantity),
|
||||
|
||||
// trade related fields
|
||||
TradeID: trade.ID,
|
||||
Price: trade.Price,
|
||||
Quantity: trade.Quantity,
|
||||
QuoteQuantity: trade.QuoteQuantity,
|
||||
IsMaker: trade.IsMaker,
|
||||
IsBuyer: trade.IsBuyer,
|
||||
Side: trade.Side,
|
||||
|
||||
Fee: trade.Fee,
|
||||
FeeCurrency: trade.FeeCurrency,
|
||||
|
||||
TradedAt: trade.Time.Time(),
|
||||
|
||||
IsFutures: trade.IsFutures,
|
||||
IsMargin: trade.IsMargin,
|
||||
IsIsolated: trade.IsIsolated,
|
||||
TradeID: trade.ID,
|
||||
Side: trade.Side,
|
||||
IsBuyer: trade.IsBuyer,
|
||||
IsMaker: trade.IsMaker,
|
||||
Price: trade.Price,
|
||||
Quantity: trade.Quantity,
|
||||
QuoteQuantity: trade.QuoteQuantity,
|
||||
// FeeInUSD: 0,
|
||||
Fee: trade.Fee,
|
||||
FeeCurrency: trade.FeeCurrency,
|
||||
|
||||
Exchange: trade.Exchange,
|
||||
IsMargin: trade.IsMargin,
|
||||
IsFutures: trade.IsFutures,
|
||||
IsIsolated: trade.IsIsolated,
|
||||
TradedAt: trade.Time.Time(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user