package indicator import ( vmts "sig-pub/pkg/storage/tsdb/victoria_metrics" "sync" ) // load indicator plugin // 热指标 自动加载/实时更新/内存缓存 // 历史指标 实时计算 // 自定义插件化指标 type IndicatorService struct { vmdb vmts.VictoriaMetricsTSDB } func NewIndicatorService(vmdb vmts.VictoriaMetricsTSDB) *IndicatorService { return &IndicatorService{ vmdb: vmdb, } } // 加载热指标 // 订阅k线数据 更新指标 func (svc *IndicatorService) Init() { // Regist(RSI) // if Indicators[RSI] } // 注册 func (svc *IndicatorService) Register(indicatorName string, indicatorInterface any) { } // Indicator 获取指标 // key: 指标名称-指标参数hash // args: 策略参数(柯里化), 如 window, 6, round, 14... func (svc *IndicatorService) Indicator(indicatorName string, args ...any) { // 调用方: strategy, webview, other indicator // strategy: IsCross(RSI6[10:1], RSI14[10:1])... // webview: RSI6(stime, etime, interval) // other indicator: RSI6[10] * MACD[10] } // kline -> indicator root -> /internal/force_flush -> all indicators (wg concurrent) -> all strategy (concurrent) type Ind struct { LiveMu sync.RWMutex // 实时k线锁, k线更新后指标更新时写锁 }