mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
add gin and add trades through the trade service
This commit is contained in:
parent
e2339febc2
commit
891bf50101
|
@ -3,6 +3,7 @@ package bbgo
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/c9s/bbgo/pkg/service"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
"time"
|
||||
|
||||
|
@ -162,6 +163,8 @@ type Trader struct {
|
|||
reportTimer *time.Timer
|
||||
|
||||
ProfitAndLossCalculator *ProfitAndLossCalculator
|
||||
|
||||
TradeService *service.TradeService
|
||||
}
|
||||
|
||||
func (trader *Trader) RunStrategy(ctx context.Context, strategy Strategy) (chan struct{}, error) {
|
||||
|
@ -201,6 +204,10 @@ func (trader *Trader) RunStrategy(ctx context.Context, strategy Strategy) (chan
|
|||
return
|
||||
}
|
||||
|
||||
if err := trader.TradeService.Insert(*trade) ; err != nil {
|
||||
log.WithError(err).Error("trade insert error")
|
||||
}
|
||||
|
||||
trader.ReportTrade(trade)
|
||||
trader.ProfitAndLossCalculator.AddTrade(*trade)
|
||||
_ , err := trader.Context.StockManager.AddTrades([]types.Trade{*trade})
|
||||
|
|
Loading…
Reference in New Issue
Block a user