From 4f5e9279f1784d05880d3f5a0af9e9349587f932 Mon Sep 17 00:00:00 2001 From: strange Date: Sun, 30 Nov 2025 22:58:13 +0800 Subject: [PATCH] indicator plot meta --- README.md | 14 +++++++++++++- config/exchange.toml | 4 ++-- pkg/indicator/indicator.go | 1 + pkg/indicator/indicator_plot.go | 33 +++++++++++++++++++++++++++++++++ pkg/indicator/super_trend.go | 5 +++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 pkg/indicator/indicator_plot.go diff --git a/README.md b/README.md index 51ab40b..c654452 100644 --- a/README.md +++ b/README.md @@ -98,5 +98,17 @@ strategy0: 趋势追踪,增长趋势, - trade strategy - 自动测试(因子挖掘): 1. 指标分类 - 2. 指标参数组合迭代 (确定潜在的可调参数) + 2. 指标参数组合迭代 (确定潜在的可调参数)!!! +KlineSeries 替换, copy性能消耗 +macd dif/dea -> state -> plot + +- 金融市场体系 +- 高数 +- 交易系统 +- VWAP/TWAP: 交易分单算法 减少下单对市场冲击 + +系统终极形态: +- 量化交易 +- web3: + - 智能合约 solidity NTF diff --git a/config/exchange.toml b/config/exchange.toml index e65fb93..d5bc355 100644 --- a/config/exchange.toml +++ b/config/exchange.toml @@ -18,8 +18,8 @@ receiveBuffer = 4096 marketSubscribeLimit = 16 consumeBatch = 1024 consumeLater = 2000 # 时间到达later或者数据累计到batch触发consume -httpProxy = "" -# httpProxy = "http://192.168.1.5:7890" +# httpProxy = "" +httpProxy = "http://192.168.1.5:7890" # httpProxy = "http://10.255.183.209:7890" # 模拟盘API交易地址如下: diff --git a/pkg/indicator/indicator.go b/pkg/indicator/indicator.go index 40e85d0..44e0299 100644 --- a/pkg/indicator/indicator.go +++ b/pkg/indicator/indicator.go @@ -15,6 +15,7 @@ type IndicatorMeta struct { Desc string `json:"desc"` // 指标描述 Input []types.InputArg `json:"input"` // 输入参数 State []string `json:"state"` // 向外暴露状态 + Plot Plot `json:"plot"` // 指标绘图属性 } // IIndicator 指标基础计算接口 diff --git a/pkg/indicator/indicator_plot.go b/pkg/indicator/indicator_plot.go new file mode 100644 index 0000000..66aac6a --- /dev/null +++ b/pkg/indicator/indicator_plot.go @@ -0,0 +1,33 @@ +package indicator + +// 绘图属性 +type Plot struct { + Props map[string]any // 长度颜色 + Series []PlotSeries // 需要绘图的时间序列列表 +} + +type PlotSeries struct { + State string `json:"state"` // vector, stateName + Series SeriesType `json:"series"` // 绘图类型 线/柱 + Props map[string]any `json:"props"` // 绘图属性 + SeriesFn func(vector float64, states map[string]float64) map[string]any +} + +// SeriesType 序列值绘图类型 +type SeriesType int32 + +const ( + SeriesNone SeriesType = iota + SeriesLine + SeriesHistogram + SeriesArea +) + +// Series 绘图颜色 +type Color string + +const ( + ColorRed Color = "red" + ColorGreen Color = "green" + ColorYellow Color = "yellow" +) diff --git a/pkg/indicator/super_trend.go b/pkg/indicator/super_trend.go index 02ff500..526aaee 100644 --- a/pkg/indicator/super_trend.go +++ b/pkg/indicator/super_trend.go @@ -14,6 +14,11 @@ func (c SuperTrend) Meta() IndicatorMeta { {Name: "mul", Type: types.InputTypeUInt, Desc: "乘数(建议2-4)"}, }, State: []string{"direction"}, + Plot: Plot{ + Series: []PlotSeries{ + {State: "", Series: SeriesLine, Props: map[string]any{"color": "red"}}, // hist + }, + }, } }