-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
damon
committed
Dec 30, 2021
1 parent
ee2caf3
commit 066084f
Showing
3 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# TradingView 对官方文档的相关理解 | ||
|
||
TradingView自带包含前端/后台的一套规范 | ||
|
||
## 数据绑定 | ||
|
||
因公司后台的接口和调用方式与官方例子有所偏差,服务端相关的设计可忽略,重点放在前端实现逻辑(3.2) | ||
|
||
### 3-2.JS Api | ||
|
||
对应本地代码 [udf-compatible-datafeed-base.js](/src/components/tradingview/datafeeds/udf/lib/udf-compatible-datafeed-base.js) | ||
|
||
### 图表定制 | ||
|
||
#### 4-2 构造器 | ||
|
||
通过new TradingView.widget实例化,相关配置参数参考官网文档 | ||
|
||
#### 4-3 实例方法 | ||
|
||
可订阅实例状态/数据、修改语言/产品/周期、启用/禁用部分功能、移除实例、导入导出数据、自定义UI控件/对话框等 | ||
|
||
#### 4-4 图表方法 | ||
|
||
和实例方法不同,是图表内部的方法,可订阅获取图表K线状态/周期/类型、修改产品/视口数据范围、放大缩小、修改指标/模版、导出数据等 | ||
|
||
#### 4-5 功能集 | ||
|
||
图表交互相关的功能集合 | ||
|
||
其中有一个连接“功能集互动地图”, 可显示图表中的功能位置,并且可以在构造参数的disabled_features、enabled_features字段进行配置 | ||
|
||
#### 覆盖/指标覆盖/样式覆盖 | ||
|
||
均可在文档附录内,查到相应的属性配置 | ||
|
||
## 创建自定义指标 | ||
|
||
官方示例代码在目录7 | ||
|
||
也可参考本地自定义指标,在[customIndicators文件夹](/src/components/tradingview/datafeeds/userConfig/customIndicators/index.js)中 | ||
|
||
本地[KDJ指标](/src/components/tradingview/datafeeds/userConfig/customIndicators/KDJ.js)是基于公司产品提供的公式算法所自定义的(因官方kdj指标未内置到库文件中) | ||
|
||
其它指标基本是拷贝官方内置指标的源码,仅对配置作更改,而不修改算法,例如MA.js可一次增加6个ma指标(原ma指标是一个指标一根线)或更改颜色、数字值等 | ||
|
||
备注: | ||
|
||
- 构造参数的custom_indicators_getter字段可导入自定义指标配置 | ||
|
||
- 图表通过createStudy创建指标并显示在图表内 | ||
|
||
- 可拷贝源码修改并创建新的自定义指标(名称、颜色、数字、背景,新的计算公式等) | ||
|
||
- createStudy的参数可覆盖指标默认值(颜色、数字、背景等) | ||
|
||
- 构造参数studies_overrides也可以覆盖指标默认值 ,参考官方文档[指标覆盖](https://zlq4863947.gitbook.io/tradingview/fu-lu/studies-overrides) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# WP 关于行情插件事项 | ||
|
||
[原型地址](https://3w5ky2.axshare.com/#g=1&p=行情界面的插件&c=1) | ||
之前是在_7接口联调的 | ||
|
||
## 需求 | ||
|
||
## 分支说明 | ||
|
||
- easy_quote 已经开发完成的 wp 插件(增加行情样式的配置,每个板块/玩法都可以) | ||
|
||
- quote 未完成的 wp 插件(终极目标是在 wp 可实时预览板块修改,并通过拖拽插件形式,绑定对应的样式和产品) | ||
|
||
- 可能遇到的问题有 | ||
|
||
- wp预览模块和配置模块的通信 | ||
- 全局数据的修改 | ||
- 行情数据结构的变化 | ||
- C端适配新数据结构 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# tradingview | ||
|
||
[tradingview 翻译文档地址](https://zlq4863947.gitbook.io/tradingview/) | ||
|
||
[tradingview 翻译文档的理解.md](./tradingview翻译文档的理解.md) | ||
|
||
## 对 tradingview 的封装 | ||
|
||
使用说明:[README.md](/src/components/tradingview/README.md) | ||
|
||
组件:[tv.vue](/src/components/tradingview/tv.vue)(该组件依赖于[chart.js](/src/components/tradingview/chart.js)) | ||
|
||
### 封装思路 | ||
|
||
1. 进入 tv.vue | ||
2. 调用 createChart 方法创建实例 | ||
|
||
a. 传入构造函数,包括容器 id、产品初始信息、图表属性/指标以及扩展字段、回调函数等 | ||
|
||
c. 更新图表属性/指标、添加买卖价格框、绑定事件、判断横竖屏等 | ||
|
||
b. 实例化成功后,调用回调函数,通知外部 | ||
|
||
3. 组件内定义图表常用方法提供给父层,避免开发者直接调用 chart.js 文件内的方法 | ||
|
||
4. 组件使用方法看[md](/src/components/tradingview/README.md) | ||
|
||
### 文件重点 | ||
|
||
#### chart.js | ||
|
||
- 创建 tradingview 实例后,包装原框架方法,丰富公共功能,提供给开发者使用 | ||
|
||
#### history-provider.js | ||
|
||
- 该文件是 tradingview 框架默认调用的模块之一,尤其是该模块导出的 getBars,用于历史 K 线 | ||
|
||
- getBars:当初始化/周期切换/屏幕滑动等,getBars 会被调用,并传入请求 K 线的相关参数 | ||
|
||
- 价格实时更新是通过在 chart.js 调用 history-provider 中的实例方法 onTick 实现的 | ||
|
||
### 图表升级须知 | ||
|
||
- 自定义 CSS(通过[custom_css_url](https://zlq4863947.gitbook.io/tradingview/4-tu-biao-ding-zhi/widget-constructor#custom_css_url)字段引入的 css 文件) | ||
|
||
- 横屏的买卖价框和横竖屏按钮([chart.js](/src/components/tradingview/chart.js)的 appendPriceBoxToIframe 方法) | ||
|
||
- 官方提供的是压缩源码,升级时需根据官方升级文档,且需对datafeeds文件夹内的文件进行调整 | ||
|
||
### 备注 | ||
|
||
- tradingview 不支持模块导入,须通过全局引入 script,相关变量函数挂载到 window 上后,再进行实例初始化 | ||
|
||
- tradingview 实例过程,代码执行逻辑会按顺序进入以下文件(仅强调对项目影响比较大的部分) | ||
|
||
- [udf-compatible-datafeed.js](/src/components/tradingview/datafeeds/udf/lib/udf-compatible-datafeed.js) | ||
- [udf-compatible-datafeed-base.js](/src/components/tradingview/datafeeds/udf/lib/udf-compatible-datafeed-base.js) 增加 otherConfig 参数,修改产品数据部分参数 | ||
- [history-provider.js](/src/components/tradingview/datafeeds/udf/lib/history-provider.js) 对接口请求逻辑进行封装,按照规范提供给 tradingview 框架调用 | ||
- [requestKData.js](/src/components/tradingview/datafeeds/userConfig/requestKData.js) 对 K 线接口的封装 | ||
|
||
- 图表自带现价线有重复显示的 bug,因此改成手动创建现价线 | ||
|
||
- 横竖屏切换按钮、横屏状态显示在左上侧的买卖价格框均有涉及动态获取图表 iframe 内的 dom 节点,并插入自定义节点 | ||
|
||
- 买卖价格框,避免覆盖到高开低收或指标栏,将其插入到指标相关的节点附近 | ||
|
||
- 图表升级可能会导致 dom 节点的类名有变化,需随之进行调整 | ||
|
||
- [行情接口文档](http://8.210.6.134/read/cats-doc-c/date-2021.03.01.17.20.22) |