mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
rebalance: validate symbols
This commit is contained in:
parent
3d0ad010eb
commit
8d9faff859
|
@ -18,5 +18,4 @@ exchangeStrategies:
|
|||
threshold: 2%
|
||||
# max amount to buy or sell per order
|
||||
maxAmount: 10_000
|
||||
verbose: true
|
||||
dryRun: false
|
||||
|
|
|
@ -26,9 +26,9 @@ type Strategy struct {
|
|||
BaseCurrency string `json:"baseCurrency"`
|
||||
TargetWeights fixedpoint.ValueMap `json:"targetWeights"`
|
||||
Threshold fixedpoint.Value `json:"threshold"`
|
||||
Verbose bool `json:"verbose"`
|
||||
DryRun bool `json:"dryRun"`
|
||||
MaxAmount fixedpoint.Value `json:"maxAmount"` // max amount to buy or sell per order
|
||||
// max amount to buy or sell per order
|
||||
MaxAmount fixedpoint.Value `json:"maxAmount"`
|
||||
|
||||
activeOrderBook *bbgo.ActiveOrderBook
|
||||
}
|
||||
|
@ -75,6 +75,13 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
s.activeOrderBook = bbgo.NewActiveOrderBook("")
|
||||
s.activeOrderBook.BindStream(session.UserDataStream)
|
||||
|
||||
markets := session.Markets()
|
||||
for _, symbol := range s.symbols() {
|
||||
if _, ok := markets[symbol]; !ok {
|
||||
return fmt.Errorf("exchange: %s does not supoort matket: %s", session.Exchange.Name(), symbol)
|
||||
}
|
||||
}
|
||||
|
||||
session.MarketDataStream.OnKLineClosed(func(kline types.KLine) {
|
||||
s.rebalance(ctx, orderExecutor, session)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user