Documentation
¶
Index ¶
- Variables
- func RefreshPairList(timeMS int64) ([]string, *errs.Error)
- func RegisterFilter(name string, factory FilterFactory)
- func Setup() *errs.Error
- type AgeFilter
- type BaseFilter
- type BlockFilter
- type CorrelationFilter
- type FilterFactory
- type IFilter
- type IProducer
- type IdVal
- type OffsetFilter
- type PriceFilter
- type RateOfChangeFilter
- type ShuffleFilter
- type SpreadFilter
- type SymbolVol
- type VolatilityFilter
- type VolumePairFilter
Constants ¶
This section is empty.
Variables ¶
var (
ShowLog = true
)
Functions ¶
func RefreshPairList ¶
RefreshPairList
刷新交易品种,如果alignStart=true,则计算当前时间前一个cron的触发时间对应的交易品种 更新core.Pairs和core.PairsMap
func RegisterFilter ¶ added in v0.2.24
func RegisterFilter(name string, factory FilterFactory)
RegisterFilter registers a custom filter factory with the given name This allows users to create and register their own filters Example:
type MyCustomFilter struct {
goods.BaseFilter
MyParam string `yaml:"my_param" mapstructure:"my_param"`
}
func (f *MyCustomFilter) Filter(pairs []string, timeMS int64) ([]string, *errs.Error) {
// Your custom filter logic here
return pairs, nil
}
func init() {
goods.RegisterFilter("MyCustomFilter", func(base goods.BaseFilter) goods.IFilter {
return &MyCustomFilter{BaseFilter: base}
})
}
Types ¶
type AgeFilter ¶
type AgeFilter struct {
BaseFilter
Min int `yaml:"min" mapstructure:"min,omitempty"` // 最小上市天数
Max int `yaml:"max" mapstructure:"max,omitempty"` // 最大上市天数
}
type BaseFilter ¶
type BaseFilter struct {
Name string `yaml:"name" mapstructure:"name"`
Disable bool `yaml:"disable" mapstructure:"disable,omitempty"`
AllowEmpty bool
}
func (*BaseFilter) GetName ¶
func (f *BaseFilter) GetName() string
func (*BaseFilter) IsDisable ¶
func (f *BaseFilter) IsDisable() bool
type BlockFilter ¶ added in v0.2.17
type BlockFilter struct {
BaseFilter
Pairs []string `yaml:"pairs" mapstructure:"pairs,omitempty"`
// contains filtered or unexported fields
}
type CorrelationFilter ¶
type CorrelationFilter struct {
BaseFilter
Min float64 `yaml:"min" mapstructure:"min,omitempty"`
Max float64 `yaml:"max" mapstructure:"max,omitempty"`
Timeframe string `yaml:"timeframe" mapstructure:"timeframe,omitempty"`
BackNum int `yaml:"back_num" mapstructure:"back_num,omitempty"`
TopN int `yaml:"top_n" mapstructure:"top_n"`
TopRate float64 `yaml:"top_rate" mapstructure:"top_rate"`
Sort string `yaml:"sort" mapstructure:"sort"`
}
type FilterFactory ¶ added in v0.2.24
type FilterFactory func(base BaseFilter) IFilter
FilterFactory is a function that creates a new filter instance
func GetFilterFactory ¶ added in v0.2.24
func GetFilterFactory(name string) (FilterFactory, bool)
GetFilterFactory returns the factory function for a given filter name
type IFilter ¶
type IFilter interface {
GetName() string
IsDisable() bool
Filter(pairs []string, timeMS int64) ([]string, *errs.Error)
}
func CreateFilter ¶ added in v0.2.24
CreateFilter creates a filter instance from config using the registry
func GetPairFilters ¶
type OffsetFilter ¶
type OffsetFilter struct {
BaseFilter
Reverse bool `yaml:"reverse" mapstructure:"reverse,omitempty"`
Offset int `yaml:"offset" mapstructure:"offset,omitempty"`
Limit int `yaml:"limit" mapstructure:"limit,omitempty"`
Rate float64 `yaml:"rate" mapstructure:"rate,omitempty"`
}
type PriceFilter ¶
type PriceFilter struct {
BaseFilter
MaxUnitValue float64 `yaml:"max_unit_value" mapstructure:"max_unit_value,omitempty"`
Precision float64 `yaml:"precision" mapstructure:"precision,omitempty"`
Min float64 `yaml:"min" mapstructure:"min,omitempty"`
Max float64 `yaml:"max" mapstructure:"max,omitempty"`
}
PriceFilter The price filter configuration 价格过滤器配置结构体 Precision: 0.001,Filter trading pairs by price precision, and the minimum unit of price change is 0.1% by default 按价格精度过滤交易对,默认要求价格变动最小单位是0.1% Min: Lowest price 最低价格 Max: Highest price 最高价格 MaxUnitValue: The value of the maximum allowable unit price change (for the pricing currency, it is generally USDT). 最大允许的单位价格变动对应的价值(针对定价货币,一般是USDT)。
type RateOfChangeFilter ¶
type RateOfChangeFilter struct {
BaseFilter
BackDays int `yaml:"back_days" mapstructure:"back_days,omitempty"` // 回顾的K线天数
Min float64 `yaml:"min" mapstructure:"min,omitempty"` // 最小价格变动比率
Max float64 `yaml:"max" mapstructure:"max,omitempty"` // 最大价格变动比率
CacheSecs int `yaml:"cache_secs" mapstructure:"cache_secs,omitempty"` // 缓存时间,秒
}
RateOfChangeFilter 一段时间内(high-low)/low比值
type ShuffleFilter ¶
type ShuffleFilter struct {
BaseFilter
Seed int `yaml:"seed" mapstructure:"seed,omitempty"`
}
type SpreadFilter ¶
type SpreadFilter struct {
BaseFilter
MaxRatio float32 `yaml:"max_ratio" mapstructure:"max_ratio,omitempty"` // 公式:1-bid/ask,买卖价差占价格的最大比率
}
流动性过滤器。
type VolatilityFilter ¶
type VolatilityFilter struct {
BaseFilter
BackDays int `yaml:"back_days" mapstructure:"back_days,omitempty"` // 回顾的K线天数
Max float64 `yaml:"max" mapstructure:"max,omitempty"` // 波动分数最大值
Min float64 `yaml:"min" mapstructure:"min,omitempty"` // 波动分数最小值
}
VolatilityFilter StdDev(ln(close / prev_close)) * sqrt(num)
type VolumePairFilter ¶
type VolumePairFilter struct {
BaseFilter
Limit int `yaml:"limit" mapstructure:"limit,omitempty"` // The number of returned results is limited to the first 100 返回结果的数量限制,取前100个
LimitRate float64 `yaml:"limit_rate" mapstructure:"limit_rate"`
MinValue float64 `yaml:"min_value" mapstructure:"min_value,omitempty"` // Minimum volume value 最低成交量价值
CacheSecs int `yaml:"cache_secs" mapstructure:"cache_secs,omitempty"` // Cache time, in seconds 缓存时间,以秒为单位
BackPeriod string `yaml:"back_period" mapstructure:"back_period,omitempty"` // The time period for calculating the volume 计算成交量的时间周期
}
VolumePairFilter Used to represent a configuration that sorts all trading pairs in reverse order by volume value 用于表示按成交量价值倒序排序所有交易对的配置
func (*VolumePairFilter) GenSymbols ¶
func (f *VolumePairFilter) GenSymbols(timeMS int64) ([]string, *errs.Error)