You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

54 lines
1.3 KiB

package trading
import (
"sig-pub/pkg/indicator"
"sync"
)
// load indicator plugin
// 热指标 自动加载/实时更新/内存缓存
// 历史指标 实时计算
// 自定义插件化指标
type IndicatorService struct {
indicators map[string]indicator.RSI
}
func NewIndicatorService() *IndicatorService {
return &IndicatorService{
indicators: make(map[string]indicator.RSI),
}
}
func (svc *IndicatorService) GetKlines(start, end int64) {
// Regist(RSI)
// if Indicators[RSI]
}
// 加载热指标
// 订阅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)
// kline -> indicator root -> all indicators ->
type Ind struct {
LiveMu sync.RWMutex // 实时k线锁, k线更新后指标更新时写锁
}