package trader import "github.com/spf13/cast" // 指标注册/执行器系统分配 // k线频率, 执行时指定 // 指标数据(频率)存储, 实时计算 ? type IndicatorMeta struct { Name string Desc string Args []Arg } type Arg struct { Name string Desc string ArgType ArgType // 参数类型 Options []ArgOption // 单选/多选选项列表 } type ArgOption struct { Name string Desc string } // CastValidate 数据类型校验 func (t Arg) CastValidate(v string) bool { switch t.ArgType { default: return false case ArgTypeString: return true case ArgTypeInt: fallthrough case ArgTypeUInt: if r, e := cast.ToIntE(v); e != nil { return false } else if t.ArgType == ArgTypeUInt { return r >= 0 } return true case ArgTypeFloat: fallthrough case ArgTypeUFloat: if r, e := cast.ToFloat64E(v); e != nil { return false } else if t.ArgType == ArgTypeUFloat { return r >= 0 } return true } } // 参数类型 type ArgType int8 const ( _ ArgType = iota ArgTypeString ArgTypeInt ArgTypeUInt ArgTypeFloat ArgTypeUFloat ArgTypeSelect // 单选 ArgTypeCheckBox // 多选 )