mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
inject market into the skeleton strategy
This commit is contained in:
parent
4afabd92ed
commit
f0681177f9
|
@ -15,17 +15,17 @@ func init() {
|
|||
|
||||
type Strategy struct {
|
||||
Symbol string `json:"symbol"`
|
||||
|
||||
types.Market
|
||||
}
|
||||
|
||||
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
||||
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"})
|
||||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"})
|
||||
session.Stream.OnKLineClosed(func(kline types.KLine) {
|
||||
market, ok := session.Market(s.Symbol)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
quoteBalance, ok := session.Account.Balance(market.QuoteCurrency)
|
||||
quoteBalance, ok := session.Account.Balance(s.Market.QuoteCurrency)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user