mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
replace threshold with minBaseBalance
This commit is contained in:
parent
e953a04638
commit
4dc28ec16a
|
@ -5,7 +5,7 @@ exchangeStrategies:
|
||||||
autobuy:
|
autobuy:
|
||||||
symbol: MAXTWD
|
symbol: MAXTWD
|
||||||
schedule: "@every 1s"
|
schedule: "@every 1s"
|
||||||
threshold: 200
|
minBaseBalance: 200
|
||||||
# price type: LAST, BUY, SELL, MID, TAKER, MAKER
|
# price type: LAST, BUY, SELL, MID, TAKER, MAKER
|
||||||
priceType: BUY
|
priceType: BUY
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,15 @@ type Strategy struct {
|
||||||
Environment *bbgo.Environment
|
Environment *bbgo.Environment
|
||||||
Market types.Market
|
Market types.Market
|
||||||
|
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
Schedule string `json:"schedule"`
|
Schedule string `json:"schedule"`
|
||||||
Threshold fixedpoint.Value `json:"threshold"`
|
MinBaseBalance fixedpoint.Value `json:"minBaseBalance"`
|
||||||
PriceType types.PriceType `json:"priceType"`
|
PriceType types.PriceType `json:"priceType"`
|
||||||
Bollinger *types.BollingerSetting `json:"bollinger"`
|
Bollinger *types.BollingerSetting `json:"bollinger"`
|
||||||
DryRun bool `json:"dryRun"`
|
DryRun bool `json:"dryRun"`
|
||||||
|
|
||||||
|
// Deprecated, to be replaced by MinBaseBalance
|
||||||
|
Threshold fixedpoint.Value `json:"threshold"`
|
||||||
|
|
||||||
bbgo.QuantityOrAmount
|
bbgo.QuantityOrAmount
|
||||||
|
|
||||||
|
@ -45,6 +48,10 @@ func (s *Strategy) Initialize() error {
|
||||||
if s.Strategy == nil {
|
if s.Strategy == nil {
|
||||||
s.Strategy = &common.Strategy{}
|
s.Strategy = &common.Strategy{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.Threshold.Sign() > 0 && s.MinBaseBalance.IsZero() {
|
||||||
|
s.MinBaseBalance = s.Threshold
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +94,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
||||||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
s.cancelOrders(ctx)
|
s.cancelOrders(ctx)
|
||||||
bbgo.Sync(ctx, s)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
s.cron = cron.New()
|
s.cron = cron.New()
|
||||||
|
@ -129,11 +135,11 @@ func (s *Strategy) autobuy(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if balance.Available.Compare(s.Threshold) > 0 {
|
if balance.Available.Compare(s.MinBaseBalance) > 0 {
|
||||||
log.Infof("balance %s is higher than threshold %s", balance.Available.String(), s.Threshold.String())
|
log.Infof("balance %s is higher than minBaseBalance %s", balance.Available.String(), s.MinBaseBalance.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Infof("balance %s is lower than threshold %s", balance.Available.String(), s.Threshold.String())
|
log.Infof("balance %s is lower than minBaseBalance %s", balance.Available.String(), s.MinBaseBalance.String())
|
||||||
|
|
||||||
quantity := s.CalculateQuantity(price)
|
quantity := s.CalculateQuantity(price)
|
||||||
submitOrder := types.SubmitOrder{
|
submitOrder := types.SubmitOrder{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user