add TradeCollector.Process() log message

This commit is contained in:
c9s 2023-07-12 17:16:46 +08:00
parent 885c58f77e
commit b9616a0805
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 9 additions and 4 deletions

View File

@ -203,9 +203,10 @@ func (e *GeneralOrderExecutor) SubmitOrders(ctx context.Context, submitOrders ..
orderCreateCallback := func(createdOrder types.Order) {
e.orderStore.Add(createdOrder)
e.activeMakerOrders.Add(createdOrder)
e.tradeCollector.Process()
}
defer e.tradeCollector.Process()
if e.maxRetries == 0 {
createdOrders, _, err := BatchPlaceOrder(ctx, e.session.Exchange, orderCreateCallback, formattedOrders...)
return createdOrders, err

View File

@ -385,9 +385,11 @@ func (session *ExchangeSession) initSymbol(ctx context.Context, environ *Environ
session.Trades[symbol] = &types.TradeSlice{Trades: trades}
session.UserDataStream.OnTradeUpdate(func(trade types.Trade) {
if trade.Symbol == symbol {
session.Trades[symbol].Append(trade)
if trade.Symbol != symbol {
return
}
session.Trades[symbol].Append(trade)
})
position := &types.Position{

View File

@ -529,7 +529,8 @@ var BacktestCmd = &cobra.Command{
profitFactor := tradeState.ProfitFactor
winningRatio := tradeState.WinningRatio
intervalProfits := tradeState.IntervalProfits[types.Interval1d]
symbolReport, err := createSymbolReport(userConfig, session, symbol, trades.Trades, intervalProfits, profitFactor, winningRatio)
symbolReport, err := createSymbolReport(userConfig, session, symbol, trades.Copy(), intervalProfits, profitFactor, winningRatio)
if err != nil {
return err
}

View File

@ -117,6 +117,7 @@ func (c *TradeCollector) setDone(key types.TradeKey) {
// if we have the order in the order store, then the trade will be considered for the position.
// profit will also be calculated.
func (c *TradeCollector) Process() bool {
logrus.Debugf("TradeCollector.Process()")
positionChanged := false
c.tradeStore.Filter(func(trade types.Trade) bool {