mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
cmd: skip reports for session has no trade
This commit is contained in:
parent
3d4a128bab
commit
470eb7dc09
|
@ -528,6 +528,11 @@ var BacktestCmd = &cobra.Command{
|
|||
|
||||
for _, session := range environ.Sessions() {
|
||||
for symbol, trades := range session.Trades {
|
||||
if len(trades.Trades) == 0 {
|
||||
log.Warnf("session has no %s trades", symbol)
|
||||
continue
|
||||
}
|
||||
|
||||
tradeState := sessionTradeStats[session.Name][symbol]
|
||||
profitFactor := tradeState.ProfitFactor
|
||||
winningRatio := tradeState.WinningRatio
|
||||
|
@ -598,8 +603,11 @@ var BacktestCmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
func createSymbolReport(userConfig *bbgo.Config, session *bbgo.ExchangeSession, symbol string, trades []types.Trade, intervalProfit *types.IntervalProfitCollector,
|
||||
profitFactor, winningRatio fixedpoint.Value) (
|
||||
func createSymbolReport(
|
||||
userConfig *bbgo.Config, session *bbgo.ExchangeSession, symbol string, trades []types.Trade,
|
||||
intervalProfit *types.IntervalProfitCollector,
|
||||
profitFactor, winningRatio fixedpoint.Value,
|
||||
) (
|
||||
*backtest.SessionSymbolReport,
|
||||
error,
|
||||
) {
|
||||
|
@ -669,7 +677,10 @@ func createSymbolReport(userConfig *bbgo.Config, session *bbgo.ExchangeSession,
|
|||
return &symbolReport, nil
|
||||
}
|
||||
|
||||
func verify(userConfig *bbgo.Config, backtestService *service.BacktestService, sourceExchanges map[types.ExchangeName]types.Exchange, startTime, endTime time.Time) error {
|
||||
func verify(
|
||||
userConfig *bbgo.Config, backtestService *service.BacktestService,
|
||||
sourceExchanges map[types.ExchangeName]types.Exchange, startTime, endTime time.Time,
|
||||
) error {
|
||||
for _, sourceExchange := range sourceExchanges {
|
||||
err := backtestService.Verify(sourceExchange, userConfig.Backtest.Symbols, startTime, endTime)
|
||||
if err != nil {
|
||||
|
@ -709,7 +720,10 @@ func getExchangeIntervals(ex types.Exchange) types.IntervalMap {
|
|||
return types.SupportedIntervals
|
||||
}
|
||||
|
||||
func sync(ctx context.Context, userConfig *bbgo.Config, backtestService *service.BacktestService, sourceExchanges map[types.ExchangeName]types.Exchange, syncFrom, syncTo time.Time) error {
|
||||
func sync(
|
||||
ctx context.Context, userConfig *bbgo.Config, backtestService *service.BacktestService,
|
||||
sourceExchanges map[types.ExchangeName]types.Exchange, syncFrom, syncTo time.Time,
|
||||
) error {
|
||||
for _, symbol := range userConfig.Backtest.Symbols {
|
||||
for _, sourceExchange := range sourceExchanges {
|
||||
var supportIntervals = getExchangeIntervals(sourceExchange)
|
||||
|
|
Loading…
Reference in New Issue
Block a user