mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 03:23:52 +00:00
deposit2transfer: ignore dust deposits
This commit is contained in:
parent
20f43e4634
commit
70d26ff775
|
@ -55,6 +55,9 @@ type Strategy struct {
|
||||||
Interval types.Duration `json:"interval"`
|
Interval types.Duration `json:"interval"`
|
||||||
TransferDelay types.Duration `json:"transferDelay"`
|
TransferDelay types.Duration `json:"transferDelay"`
|
||||||
|
|
||||||
|
IgnoreDust bool `json:"ignoreDust"`
|
||||||
|
DustAmounts map[string]fixedpoint.Value `json:"dustAmounts"`
|
||||||
|
|
||||||
SlackAlert *SlackAlert `json:"slackAlert"`
|
SlackAlert *SlackAlert `json:"slackAlert"`
|
||||||
|
|
||||||
marginTransferService marginTransferService
|
marginTransferService marginTransferService
|
||||||
|
@ -85,6 +88,15 @@ func (s *Strategy) Defaults() error {
|
||||||
s.TransferDelay = types.Duration(3 * time.Second)
|
s.TransferDelay = types.Duration(3 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.DustAmounts == nil {
|
||||||
|
s.DustAmounts = map[string]fixedpoint.Value{
|
||||||
|
"USDC": fixedpoint.NewFromFloat(1.0),
|
||||||
|
"USDT": fixedpoint.NewFromFloat(1.0),
|
||||||
|
"BTC": fixedpoint.NewFromFloat(0.00001),
|
||||||
|
"ETH": fixedpoint.NewFromFloat(0.00001),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +141,16 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Strategy) isDust(asset string, amount fixedpoint.Value) bool {
|
||||||
|
if s.IgnoreDust {
|
||||||
|
if dustAmount, ok := s.DustAmounts[asset]; ok {
|
||||||
|
return amount.Compare(dustAmount) <= 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Strategy) tickWatcher(ctx context.Context, interval time.Duration) {
|
func (s *Strategy) tickWatcher(ctx context.Context, interval time.Duration) {
|
||||||
ticker := time.NewTicker(interval)
|
ticker := time.NewTicker(interval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
@ -284,6 +306,10 @@ func (s *Strategy) scanDepositHistory(ctx context.Context, asset string, duratio
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.isDust(asset, deposit.Amount) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// if the deposit record is already in the watch list, update it
|
// if the deposit record is already in the watch list, update it
|
||||||
if _, ok := s.watchingDeposits[deposit.TransactionID]; ok {
|
if _, ok := s.watchingDeposits[deposit.TransactionID]; ok {
|
||||||
s.addWatchingDeposit(deposit)
|
s.addWatchingDeposit(deposit)
|
||||||
|
|
|
@ -28,6 +28,7 @@ type StreamBookSetter interface {
|
||||||
type OrderBookBestPriceVolumeSignal struct {
|
type OrderBookBestPriceVolumeSignal struct {
|
||||||
RatioThreshold fixedpoint.Value `json:"ratioThreshold"`
|
RatioThreshold fixedpoint.Value `json:"ratioThreshold"`
|
||||||
MinVolume fixedpoint.Value `json:"minVolume"`
|
MinVolume fixedpoint.Value `json:"minVolume"`
|
||||||
|
MinQuoteVolume fixedpoint.Value `json:"minQuoteVolume"`
|
||||||
|
|
||||||
symbol string
|
symbol string
|
||||||
book *types.StreamOrderBook
|
book *types.StreamOrderBook
|
||||||
|
|
Loading…
Reference in New Issue
Block a user