goods Package
The goods package provides functionality related to commodities and trading pairs.
Important Structures
IFilter
Filter interface that all filters must implement.
GetName() string- Get filter nameIsDisable() bool- Check if filter is disabledIsNeedTickers() bool- Check if tickers data is neededFilter(pairs []string, tickers map[string]*banexg.Ticker) ([]string, *errs.Error)- Filter method
IProducer
Producer interface that inherits from IFilter, used to generate trading pair lists.
- Inherits all methods from IFilter
GenSymbols(tickers map[string]*banexg.Ticker) ([]string, *errs.Error)- Generate trading pair list
BaseFilter
Base filter structure, the base class for all concrete filters.
Name string- Filter nameDisable bool- Whether disabledNeedTickers bool- Whether tickers data is neededAllowEmpty bool- Whether empty results are allowed
VolumePairFilter
Volume filter that sorts all trading pairs in reverse order by volume value.
Limit int- Limit on number of returned results, takes first 100LimitRate float64- Limit rateMinValue float64- Minimum volume valueRefreshSecs int- Cache time in secondsBackTimeframe string- Time period for calculating volume, defaults to daysBackPeriod int- Multiplier for time range obtained by multiplying with BackTimeframe
PriceFilter
Price filter configuration structure.
MaxUnitValue float64- Maximum allowable unit price change value (for pricing currency, generally USDT)Precision float64- Price precision, default requires minimum price change unit is 0.1%Min float64- Minimum priceMax float64- Maximum price
RateOfChangeFilter
Price change ratio filter, calculates (high-low)/low ratio over a period.
BackDays int- Number of candlestick days to look backMin float64- Minimum price change ratioMax float64- Maximum price change ratioRefreshPeriod int- Cache time in seconds
SpreadFilter
Liquidity filter.
MaxRatio float32- Maximum bid-ask spread ratio relative to price, formula: 1-bid/ask
CorrelationFilter
Correlation filter.
Min float64- Minimum correlationMax float64- Maximum correlationTimeframe string- Time periodBackNum int- Lookback numberTopN int- Take top NSort string- Sort method
VolatilityFilter
Volatility filter using StdDev(ln(close / prev_close)) * sqrt(num).
BackDays int- Number of candlestick days to look backMax float64- Maximum volatility scoreMin float64- Minimum volatility score
AgeFilter
Listing time filter.
Min int- Minimum listing daysMax int- Maximum listing days
BlockFilter
A variety blacklist filter used to filter specified varieties.
Pairs string[]- Varieties to be filtered
OffsetFilter
Offset filter.
Reverse bool- Whether to reverseOffset int- Offset valueLimit int- Limit countRate float64- Rate value
ShuffleFilter
Random shuffle filter.
Seed int- Random seed
Setup
Initialize the goods package configuration. Mainly used for setting up trading pair filters.
Returns:
*errs.Error- Error information during initialization, returns nil if successful
GetPairFilters
Create a list of trading pair filters based on configuration.
Parameters:
items []*config.CommonPairFilter- Filter configuration listwithInvalid bool- Whether to include invalid filters
Returns:
[]IFilter- List of filter interfaces*errs.Error- Error information during creation
RefreshPairList
Refresh trading pair list to get the latest valid trading pairs.
Returns:
[]string- List of valid trading pairs*errs.Error- Error information during refresh