mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/c9s/bbgo/pkg/service"
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -162,6 +163,8 @@ type Trader struct {
|
||||||
reportTimer *time.Timer
|
reportTimer *time.Timer
|
||||||
|
|
||||||
ProfitAndLossCalculator *ProfitAndLossCalculator
|
ProfitAndLossCalculator *ProfitAndLossCalculator
|
||||||
|
|
||||||
|
TradeService *service.TradeService
|
||||||
}
|
}
|
||||||
|
|
||||||
func (trader *Trader) RunStrategy(ctx context.Context, strategy Strategy) (chan struct{}, error) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := trader.TradeService.Insert(*trade) ; err != nil {
|
||||||
|
log.WithError(err).Error("trade insert error")
|
||||||
|
}
|
||||||
|
|
||||||
trader.ReportTrade(trade)
|
trader.ReportTrade(trade)
|
||||||
trader.ProfitAndLossCalculator.AddTrade(*trade)
|
trader.ProfitAndLossCalculator.AddTrade(*trade)
|
||||||
_ , err := trader.Context.StockManager.AddTrades([]types.Trade{*trade})
|
_ , err := trader.Context.StockManager.AddTrades([]types.Trade{*trade})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user