hqchart 1.1.12687 → 1.1.12706
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/umychart.vue.js +94 -50
- package/package.json +15 -47
- package/src/jscommon/umychart.resource/js/codemirror/javascript.js +1 -1
- package/src/jscommon/umychart.uniapp.h5/umychart.uniapp.h5.js +409 -115
- package/src/jscommon/umychart.vue/umychart.vue.js +409 -115
- package/.babelrc +0 -6
- package/.vscode/settings.json +0 -4
- package/Makefile +0 -9
- package/README.md +0 -452
- package/index.js +0 -17
- package/postcss.config.js +0 -5
- package/src/index.html +0 -18
- package/src/jscommon/backup/announcement.png +0 -0
- package/src/jscommon/backup/announcement2.png +0 -0
- package/src/jscommon/backup/blocktrading.png +0 -0
- package/src/jscommon/backup/investor.png +0 -0
- package/src/jscommon/backup/pforecast.png +0 -0
- package/src/jscommon/backup/research.png +0 -0
- package/src/jscommon/backup/tradedetail.png +0 -0
- package/src/jscommon/backup/umychart - backup.js +0 -17631
- package/src/jscommon/backup/umychart.macro.js +0 -4
- package/src/jscommon/backup/umychart.macro.vue.js +0 -3
- package/src/jscommon/commonindextree.json +0 -92
- package/src/jscommon/index.html +0 -13
- package/src/jscommon/jschinamapdata.js +0 -3
- package/src/jscommon/umychart.NetworkFilterTest.js +0 -48803
- package/src/jscommon/umychart.aliYunnetwork.js +0 -47
- package/src/jscommon/umychart.cninfo.components/readme.txt +0 -1
- package/src/jscommon/umychart.complier.js +0 -25291
- package/src/jscommon/umychart.complier.node/umychart.complier.controller.js +0 -559
- package/src/jscommon/umychart.complier.node/umychart.complier.node.js +0 -7043
- package/src/jscommon/umychart.complier.node/umychart.data.node.js +0 -816
- package/src/jscommon/umychart.console.js +0 -12
- package/src/jscommon/umychart.deal.js +0 -1452
- package/src/jscommon/umychart.dragdiv.js +0 -48
- package/src/jscommon/umychart.index.data.js +0 -4132
- package/src/jscommon/umychart.js +0 -90257
- package/src/jscommon/umychart.keyboard.js +0 -1659
- package/src/jscommon/umychart.listctrl.js +0 -690
- package/src/jscommon/umychart.mind.js +0 -2203
- package/src/jscommon/umychart.network.js +0 -44
- package/src/jscommon/umychart.news.js +0 -823
- package/src/jscommon/umychart.node.build/buildall.bat +0 -1
- package/src/jscommon/umychart.node.build/umychart.node.bat +0 -1
- package/src/jscommon/umychart.node.build/umychart.node.export.js +0 -40
- package/src/jscommon/umychart.regressiontest.js +0 -400
- package/src/jscommon/umychart.report.js +0 -5803
- package/src/jscommon/umychart.scrollbar.js +0 -1345
- package/src/jscommon/umychart.stock.js +0 -4218
- package/src/jscommon/umychart.style.js +0 -618
- package/src/jscommon/umychart.testdata.js +0 -150
- package/src/jscommon/umychart.uniapp.build/buildall.bat +0 -1
- package/src/jscommon/umychart.uniapp.build/umychart.bat +0 -1
- package/src/jscommon/umychart.uniapp.build/umychart.export.js +0 -70
- package/src/jscommon/umychart.user.js +0 -137
- package/src/jscommon/umychart.version.js +0 -30
- package/src/jscommon/umychart.vue/umychart.aliYunnetwork.vue.js +0 -56
- package/src/jscommon/umychart.vue.build/buildall.bat +0 -4
- package/src/jscommon/umychart.vue.build/copy_codemirror.bat +0 -2
- package/src/jscommon/umychart.vue.build/umychart.aliYunnetwork.vue.export.js +0 -9
- package/src/jscommon/umychart.vue.build/umychart.dragdiv.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.dragdiv.export.js +0 -6
- package/src/jscommon/umychart.vue.build/umychart.index.data.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.index.data.export.js +0 -4
- package/src/jscommon/umychart.vue.build/umychart.listctrl.vue.export.js +0 -15
- package/src/jscommon/umychart.vue.build/umychart.regressiontest.vue.export.js +0 -7
- package/src/jscommon/umychart.vue.build/umychart.regressiontest.wechat.export.js +0 -12
- package/src/jscommon/umychart.vue.build/umychart.stock.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.stock.vue.export.js +0 -16
- package/src/jscommon/umychart.vue.build/umychart.testdata.bat +0 -3
- package/src/jscommon/umychart.vue.build/umychart.testdata.vue.export.js +0 -7
- package/src/jscommon/umychart.vue.build/umychart.vue.bat +0 -8
- package/src/jscommon/umychart.vue.build/umychart.vue.export.js +0 -112
- package/src/jscommon/umychart.vue.components/empyt.vue +0 -51
- package/src/jscommon/umychart.vue.components/historydayline.vue +0 -240
- package/src/jscommon/umychart.vue.components/jsloader.adddialog.vue +0 -315
- package/src/jscommon/umychart.vue.components/jsloader.vue +0 -93
- package/src/jscommon/umychart.vue.components/jsvuecontainer.vue +0 -160
- package/src/jscommon/umychart.vue.components/jsvuecontainer2.0.vue +0 -391
- package/src/jscommon/umychart.vue.components/login.vue +0 -178
- package/src/jscommon/umychart.vue.components/queryContent.vue +0 -750
- package/src/jscommon/umychart.vue.components/readme.txt +0 -8
- package/src/jscommon/umychart.vue.components/searchsymbol.vue +0 -299
- package/src/jscommon/umychart.vue.components/simulatetrade.vue +0 -1471
- package/src/jscommon/umychart.vue.components/stockchart.vue +0 -343
- package/src/jscommon/umychart.vue.components/stockchartV2.vue +0 -195
- package/src/jscommon/umychart.vue.components/stockdeal.vue +0 -358
- package/src/jscommon/umychart.vue.components/stockdealcount.vue +0 -262
- package/src/jscommon/umychart.vue.components/stockdeallastest.vue +0 -316
- package/src/jscommon/umychart.vue.components/stockdrawtool.vue +0 -343
- package/src/jscommon/umychart.vue.components/stockfull.vue +0 -355
- package/src/jscommon/umychart.vue.components/stockinfo.demo.vue +0 -153
- package/src/jscommon/umychart.vue.components/stockinfo.vue +0 -685
- package/src/jscommon/umychart.vue.components/stockkline.demo.vue +0 -1904
- package/src/jscommon/umychart.vue.components/stockmultiorder.vue +0 -174
- package/src/jscommon/umychart.vue.components/stockmultiperiod.vue +0 -222
- package/src/jscommon/umychart.vue.components/stockorder.vue +0 -320
- package/src/jscommon/umychart.vue.components/stocktradeinfo.demo.vue +0 -250
- package/src/jscommon/umychart.vue.components/stocktradeinfo.vue +0 -1907
- package/src/jscommon/umychart.vue.components/test.vue +0 -0
- package/src/jscommon/umychart.wechat/getDate.wechat.js +0 -91
- package/src/jscommon/umychart.wechat/lighter.news.wechat.js +0 -262
- package/src/jscommon/umychart.wechat/readme.txt +0 -3
- package/src/jscommon/umychart.wechat/umychart.analyze.wechat.js +0 -551
- package/src/jscommon/umychart.wechat/umychart.apidraw.wechat.js +0 -126
- package/src/jscommon/umychart.wechat/umychart.bigV.wechat.js +0 -2510
- package/src/jscommon/umychart.wechat/umychart.chartframe.wechat.js +0 -2931
- package/src/jscommon/umychart.wechat/umychart.chartpaint.wechat.js +0 -9752
- package/src/jscommon/umychart.wechat/umychart.charttitle.wechat.js +0 -2023
- package/src/jscommon/umychart.wechat/umychart.complier.wechat.js +0 -14726
- package/src/jscommon/umychart.wechat/umychart.console.wechat.js +0 -8
- package/src/jscommon/umychart.wechat/umychart.coordinatedata.wechat.js +0 -3654
- package/src/jscommon/umychart.wechat/umychart.data.wechat.js +0 -2243
- package/src/jscommon/umychart.wechat/umychart.element.wechart.js +0 -132
- package/src/jscommon/umychart.wechat/umychart.explainer.wechat.js +0 -1077
- package/src/jscommon/umychart.wechat/umychart.extendchart.wechat.js +0 -1140
- package/src/jscommon/umychart.wechat/umychart.framesplit.wechat.js +0 -2247
- package/src/jscommon/umychart.wechat/umychart.hqIndexformula.wechat.js +0 -941
- package/src/jscommon/umychart.wechat/umychart.index.data.wechat.js +0 -3628
- package/src/jscommon/umychart.wechat/umychart.index.wechat.js +0 -4074
- package/src/jscommon/umychart.wechat/umychart.klineinfo.wechat.js +0 -836
- package/src/jscommon/umychart.wechat/umychart.markethot.js +0 -50
- package/src/jscommon/umychart.wechat/umychart.network.wechart.js +0 -62
- package/src/jscommon/umychart.wechat/umychart.news.wechat.js +0 -3568
- package/src/jscommon/umychart.wechat/umychart.regressiontest.wechat.js +0 -412
- package/src/jscommon/umychart.wechat/umychart.report.wechat.js +0 -3983
- package/src/jscommon/umychart.wechat/umychart.resource.wechat.js +0 -919
- package/src/jscommon/umychart.wechat/umychart.shareimage.wechat.js +0 -681
- package/src/jscommon/umychart.wechat/umychart.simulatetrade.wechat.js +0 -238
- package/src/jscommon/umychart.wechat/umychart.stock.wechat.js +0 -4035
- package/src/jscommon/umychart.wechat/umychart.style.wechat.js +0 -419
- package/src/jscommon/umychart.wechat/umychart.uniapp.canvas.helper.js +0 -99
- package/src/jscommon/umychart.wechat/umychart.user.wechat.js +0 -588
- package/src/jscommon/umychart.wechat/umychart.userlog.wechat.js +0 -240
- package/src/jscommon/umychart.wechat/umychart.vedio.wechat.js +0 -112
- package/src/jscommon/umychart.wechat/umychart.version.wechat.js +0 -36
- package/src/jscommon/umychart.wechat/umychart.wechat.3.0.js +0 -12051
- package/src/jscommon/umychart.wechat/umychart.wechat.js +0 -15460
- package/src/jscommon/umychart.worker.js +0 -114
- package/src/jscommon/umychart.ws.stock.js +0 -110
- package/src/jscommon/umychart_python/.vscode/launch.json +0 -15
- package/src/jscommon/umychart_python/__init__.py +0 -4
- package/src/jscommon/umychart_python/build.cmd +0 -2
- package/src/jscommon/umychart_python/setup.py +0 -25
- package/src/jscommon/umychart_python/umychart_cache_testcase.py +0 -165
- package/src/jscommon/umychart_python/umychart_complier_data.py +0 -781
- package/src/jscommon/umychart_python/umychart_complier_help.py +0 -175
- package/src/jscommon/umychart_python/umychart_complier_job.py +0 -193
- package/src/jscommon/umychart_python/umychart_complier_jsalgorithm.py +0 -4144
- package/src/jscommon/umychart_python/umychart_complier_jscomplier.py +0 -177
- package/src/jscommon/umychart_python/umychart_complier_jsexecute.py +0 -517
- package/src/jscommon/umychart_python/umychart_complier_jsparser.py +0 -864
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata.py +0 -1238
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata_cache.py +0 -146
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata_json.py +0 -106
- package/src/jscommon/umychart_python/umychart_complier_pandas_help.py +0 -80
- package/src/jscommon/umychart_python/umychart_complier_scanner.py +0 -554
- package/src/jscommon/umychart_python/umychart_complier_testcase.py +0 -362
- package/src/jscommon/umychart_python/umychart_complier_util.py +0 -30
- package/src/jscommon/umychart_python/umychart_webtemplate.py +0 -131
- package/src/jscommon/umychart_python/updatehqchartweb.bat +0 -5
- package/src/jscommon/vendor.js +0 -2
- package/src/pages/block.list.demo.page/App.vue +0 -117
- package/src/pages/block.list.demo.page/index.js +0 -12
- package/src/pages/brushTool.demo.page/App.vue +0 -19
- package/src/pages/brushTool.demo.page/index.js +0 -12
- package/src/pages/container.demo.page/App.vue +0 -118
- package/src/pages/container.demo.page/index.js +0 -18
- package/src/pages/dataZoom.demo.page/App.vue +0 -265
- package/src/pages/dataZoom.demo.page/components/dataZoom.vue +0 -303
- package/src/pages/dataZoom.demo.page/index.js +0 -12
- package/src/pages/historydayline.demo.page/App.vue +0 -57
- package/src/pages/historydayline.demo.page/index.js +0 -12
- package/src/pages/hq.demo.page/App.vue +0 -163
- package/src/pages/hq.demo.page/index.js +0 -12
- package/src/pages/hqchart.black/App.vue +0 -90
- package/src/pages/hqchart.black/components/searchsymbol.vue +0 -299
- package/src/pages/hqchart.black/components/stockdrawtool.vue +0 -300
- package/src/pages/hqchart.black/components/stockfull.vue +0 -313
- package/src/pages/hqchart.black/components/stockinfo.vue +0 -428
- package/src/pages/hqchart.black/components/stockkline.demo.vue +0 -1652
- package/src/pages/hqchart.black/components/stocktradeinfo.vue +0 -1337
- package/src/pages/hqchart.black/index.js +0 -30
- package/src/pages/hqchart.black/router/candlestickChart.vue +0 -108
- package/src/pages/hqchart.black/router/pricePointsTable.vue +0 -294
- package/src/pages/hqchart.black/router/stockDeallas.vue +0 -417
- package/src/pages/hqchart.black/router/timeShareChart.vue +0 -108
- package/src/pages/hqchart.page/App.vue +0 -101
- package/src/pages/hqchart.page/index.js +0 -18
- package/src/pages/index/App.vue +0 -1408
- package/src/pages/index/index.js +0 -7
- package/src/pages/indexHq/App.vue +0 -110
- package/src/pages/indexHq/index.js +0 -18
- package/src/pages/login.demo.page/App.vue +0 -22
- package/src/pages/login.demo.page/index.js +0 -12
- package/src/pages/queryContent.demo.page/App.vue +0 -29
- package/src/pages/queryContent.demo.page/index.js +0 -18
- package/src/pages/ranking.black/App.vue +0 -199
- package/src/pages/ranking.black/index.js +0 -18
- package/src/pages/search.demo.page/App.vue +0 -28
- package/src/pages/search.demo.page/index.js +0 -12
- package/src/pages/simulatetrade.demo.page/app.vue +0 -121
- package/src/pages/simulatetrade.demo.page/index.js +0 -17
- package/src/pages/stockdeal.demo.page/App.vue +0 -63
- package/src/pages/stockdeal.demo.page/index.js +0 -19
- package/src/pages/stockdealcount.demo.page/App.vue +0 -37
- package/src/pages/stockdealcount.demo.page/index.js +0 -12
- package/src/pages/stockdeallastest.demo.page/App.vue +0 -74
- package/src/pages/stockdeallastest.demo.page/index.js +0 -18
- package/src/pages/stockinfo.demo.page/App.vue +0 -92
- package/src/pages/stockinfo.demo.page/index.html +0 -13
- package/src/pages/stockinfo.demo.page/index.js +0 -19
- package/src/pages/stockkline.demo.page/App.vue +0 -55
- package/src/pages/stockkline.demo.page/index.js +0 -18
- package/src/pages/stockmultiorder.demo.page/App.vue +0 -149
- package/src/pages/stockmultiorder.demo.page/index.js +0 -18
- package/src/pages/stockmultiperiod.demo.page/App.vue +0 -87
- package/src/pages/stockmultiperiod.demo.page/index.js +0 -18
- package/src/pages/stockorder.demo.page/App.vue +0 -69
- package/src/pages/stockorder.demo.page/index.js +0 -18
- package/src/pages/test/App.vue +0 -22
- package/src/pages/test/index.js +0 -7
- package/src/pages/tradeinfopage/app.vue +0 -40
- package/src/pages/tradeinfopage/index.js +0 -7
- package/src/pages/tradeinfopage/tradeinfo.html +0 -12
- package/src/utils/urlObj.js +0 -81
- package/src/vendor.js +0 -2
- package/webpack.config.js +0 -104
|
@@ -1,559 +0,0 @@
|
|
|
1
|
-
/////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// 通达信语法 webapi 处理类
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
var JSComplier=require('./umychart.complier.node').JSCommonComplier.JSComplier;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
////////////////////////////////////////////////////////////////////////////
|
|
9
|
-
// 单脚本 多股票 返回数据>0的股票
|
|
10
|
-
// symbol:[] 股票列表
|
|
11
|
-
// code: 脚本
|
|
12
|
-
// args: 脚本参数 (可选)
|
|
13
|
-
// datecount: 日线数据计算多少天 (可选)
|
|
14
|
-
// daycount: 分钟数据计算多少天 (可选)
|
|
15
|
-
// calccount: 最后统计几天的数据 (可选) 默认1天
|
|
16
|
-
// period: 周期 0=日线 1=周线 2=月线 3=年线 4=1分钟 5=5分钟 6=15分钟 7=30分钟 8=60分钟 (可选)
|
|
17
|
-
// right: 复权 0 不复权 1 前复权 2 后复权(可选)
|
|
18
|
-
//
|
|
19
|
-
/* post 数据:
|
|
20
|
-
{
|
|
21
|
-
"symbol":["600000.sh","000001.sz","000008.sz","000017.sz","000056.sz","000338.sz","000408.sz","000415.sz","000498.sz","000557.sz"],
|
|
22
|
-
"code":"LC:= REF(CLOSE,1);RSI1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;OUT:CROSS(RSI1,20);"
|
|
23
|
-
"args":[{"name":"N1","value":10},{"name":"N2","value":12}],
|
|
24
|
-
"datecount":200,
|
|
25
|
-
"calccount":50
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
返回数据
|
|
29
|
-
{
|
|
30
|
-
"ticket":131,
|
|
31
|
-
"data":
|
|
32
|
-
[
|
|
33
|
-
{"date":20181022,"symbols":["000008.sz"],"values":[1]},
|
|
34
|
-
{"date":20181019,"symbols":["000008.sz"],"values":[1]}
|
|
35
|
-
],
|
|
36
|
-
"code":"VAR2:EVERY(VOL>MA(REF(VOL,1),20)*1.5,3);","error":[]}
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
function JSComplierController(req,res,next)
|
|
40
|
-
{
|
|
41
|
-
this.Request=req;
|
|
42
|
-
this.Response=res;
|
|
43
|
-
this.Next=next;
|
|
44
|
-
|
|
45
|
-
this.DateCount=300;
|
|
46
|
-
this.DayCount=20;
|
|
47
|
-
this.Period=0;
|
|
48
|
-
this.Right=0;
|
|
49
|
-
this.CalculateCount=1;
|
|
50
|
-
|
|
51
|
-
this.StockList;
|
|
52
|
-
this.Code;
|
|
53
|
-
this.StartTime=new Date();
|
|
54
|
-
|
|
55
|
-
this.Result={}; //返回数据
|
|
56
|
-
this.CacheData;
|
|
57
|
-
this.ErrorMessage=[]; //脚本执行错误
|
|
58
|
-
|
|
59
|
-
this.Post=function()
|
|
60
|
-
{
|
|
61
|
-
var postData=this.Request.body;
|
|
62
|
-
if (!postData) return this.Error({Message:'post data is empty'});
|
|
63
|
-
|
|
64
|
-
this.StockList=postData.symbol;
|
|
65
|
-
if (!this.StockList || !this.StockList.length) return this.Error({Message:'symbol is empty'});
|
|
66
|
-
|
|
67
|
-
this.Code=postData.code;
|
|
68
|
-
if (!this.Code) return this.Error({Message:'code is empty'});
|
|
69
|
-
|
|
70
|
-
var args=[];
|
|
71
|
-
if (postData.args)
|
|
72
|
-
{
|
|
73
|
-
for(let i in postData.args) //变量全部转成大写
|
|
74
|
-
{
|
|
75
|
-
var item=postData.args[i];
|
|
76
|
-
if (item.name) args.push({Name:item.name, Value:parseFloat(item.value)}); //变量值转数值型
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (postData.datecount) this.DateCount=postData.datecount;
|
|
81
|
-
if (postData.daycount) this.DayCount=postData.daycount;
|
|
82
|
-
if (postData.period) this.Period=postData.period;
|
|
83
|
-
if (postData.right) this.Right=postData.right;
|
|
84
|
-
if (postData.calccount) this.CalculateCount=postData.calccount;
|
|
85
|
-
|
|
86
|
-
var self=this;
|
|
87
|
-
this.CacheData=new Map();
|
|
88
|
-
|
|
89
|
-
for(let i in this.StockList)
|
|
90
|
-
{
|
|
91
|
-
var symbol=this.StockList[i];
|
|
92
|
-
let option=
|
|
93
|
-
{
|
|
94
|
-
HQDataType:0,
|
|
95
|
-
Symbol:symbol, Name:null,Data:null,
|
|
96
|
-
MaxReqeustDataCount:this.DateCount, MaxRequestMinuteDayCount:this.DayCount,
|
|
97
|
-
Right:this.Right, Period:this.Period,
|
|
98
|
-
Arguments:args,
|
|
99
|
-
CallbackParam: { Symbol:symbol },
|
|
100
|
-
Callback:function(data,param) //数据计算完成回调
|
|
101
|
-
{
|
|
102
|
-
self.RecvExecuteData(data,param);
|
|
103
|
-
},
|
|
104
|
-
ErrorCallback:function(e,param)
|
|
105
|
-
{
|
|
106
|
-
self.ErrorExecute(e,param);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
var run=JSComplier.Execute(this.Code,option);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
next();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
this.Get=function()
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//执行脚本返回数据
|
|
122
|
-
this.RecvExecuteData=function(data,param)
|
|
123
|
-
{
|
|
124
|
-
console.log(data); //单个股票计算结果
|
|
125
|
-
this.CacheData.set(param.Symbol,data);
|
|
126
|
-
|
|
127
|
-
if (this.CacheData.size==this.StockList.length) //等所有股票计算完了 返回数据 result
|
|
128
|
-
{
|
|
129
|
-
this.SendResult();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
//执行脚本错误
|
|
134
|
-
this.ErrorExecute=function(e,param)
|
|
135
|
-
{
|
|
136
|
-
this.CacheData.set(param.Symbol,null);
|
|
137
|
-
|
|
138
|
-
this.ErrorMessage.push({Symbol:param.Symbol, Error:e}); //错误信息保存
|
|
139
|
-
|
|
140
|
-
if (this.CacheData.size==this.StockList.length) //等所有股票计算完了 返回数据 result
|
|
141
|
-
{
|
|
142
|
-
this.SendResult();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
//统计结果
|
|
147
|
-
this.AnalysisData=function(data)
|
|
148
|
-
{
|
|
149
|
-
var result=new Map(); //key=日期 Value={Symbol:, Value:}
|
|
150
|
-
for(let item of data)
|
|
151
|
-
{
|
|
152
|
-
var stockData=item[1];
|
|
153
|
-
if (stockData==null || !stockData.length) continue;
|
|
154
|
-
|
|
155
|
-
var outData=stockData[0];
|
|
156
|
-
if (!outData.Data || !outData.Data.length) continue;
|
|
157
|
-
|
|
158
|
-
var klineData=null;
|
|
159
|
-
for(let i in stockData)
|
|
160
|
-
{
|
|
161
|
-
var itemData=stockData[i];
|
|
162
|
-
if (itemData.Type===100 && itemData.Name==='TradeDate' && itemData.Data.length>outData.Data.length-1)
|
|
163
|
-
{
|
|
164
|
-
klineData=itemData;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (!klineData || !klineData.Data || !klineData.Data.length) continue;
|
|
169
|
-
if (klineData.Data.length!=outData.Data.length) continue;
|
|
170
|
-
|
|
171
|
-
for(let i=outData.Data.length-1, j=0; i>=0 && j<this.CalculateCount; --i, ++j)
|
|
172
|
-
{
|
|
173
|
-
var value=outData.Data[i];
|
|
174
|
-
if (!value) continue;
|
|
175
|
-
var date=klineData.Data[i];
|
|
176
|
-
if (!date) continue;
|
|
177
|
-
|
|
178
|
-
if (result.has(date))
|
|
179
|
-
{
|
|
180
|
-
var temp=result.get(date);
|
|
181
|
-
temp.Symbols.push(item[0]);
|
|
182
|
-
temp.Values.push(value);
|
|
183
|
-
}
|
|
184
|
-
else
|
|
185
|
-
{
|
|
186
|
-
result.set(date, { Symbols:[item[0]], Values:[value] });
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return result;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
this.SendResult=function()
|
|
195
|
-
{
|
|
196
|
-
this.Result.Data=this.AnalysisData(this.CacheData);
|
|
197
|
-
var nowDate=new Date();
|
|
198
|
-
this.Result.Ticket=nowDate.getTime() - this.StartTime.getTime();
|
|
199
|
-
|
|
200
|
-
var data=[];
|
|
201
|
-
for(let item of this.Result.Data)
|
|
202
|
-
{
|
|
203
|
-
data.push({date:item[0], symbols:item[1].Symbols, values:item[1].Values});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
//字段全部小写
|
|
207
|
-
var result={ ticket:this.Result.Ticket, data:data, code:this.Code, error:this.ErrorMessage };
|
|
208
|
-
this.Response.header("Access-Control-Allow-Origin", "*");
|
|
209
|
-
this.Response.send(result);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
this.Error=function(e)
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
JSComplierController.Post=function(req, res, next)
|
|
219
|
-
{
|
|
220
|
-
var controller=new JSComplierController(req,res,next);
|
|
221
|
-
controller.Post();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
///////////////////////////////////////////////////////////////////////
|
|
226
|
-
// 多脚本 多股票 交集|并集 开发中
|
|
227
|
-
// symbol:[] 股票列表
|
|
228
|
-
// script[{code:脚本,args:[]脚本参数 (可选)}]: 脚本列表
|
|
229
|
-
// datecount: 日线数据计算多少天 (可选)
|
|
230
|
-
// daycount: 分钟数据计算多少天 (可选)
|
|
231
|
-
// calccount:50 最后统计几天的数据 (可选) 默认1天
|
|
232
|
-
// period: 周期 0=日线 1=周线 2=月线 3=年线 4=1分钟 5=5分钟 6=15分钟 7=30分钟 8=60分钟 (可选)
|
|
233
|
-
// right: 复权 0 不复权 1 前复权 2 后复权(可选)
|
|
234
|
-
// mergetype: 0 脚本都满足 1 有1个脚本满足
|
|
235
|
-
//
|
|
236
|
-
/* post 数据:
|
|
237
|
-
{
|
|
238
|
-
"symbol":["600000.sh","000001.sz","000008.sz","000017.sz","000056.sz","000338.sz","000408.sz","000415.sz","000498.sz","000557.sz"],
|
|
239
|
-
script:
|
|
240
|
-
[
|
|
241
|
-
{
|
|
242
|
-
"code":"LC:= REF(CLOSE,1);RSI1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(ABS(CLOSE-LC),6,1)*100;OUT:CROSS(RSI1,20);"
|
|
243
|
-
"args":[{"name":"N1","value":10},{"name":"N2","value":12}
|
|
244
|
-
},
|
|
245
|
-
],
|
|
246
|
-
"datecount":200,
|
|
247
|
-
"mergetype": 0
|
|
248
|
-
}
|
|
249
|
-
*/
|
|
250
|
-
function JSCommonMultiComplier(req,res,next)
|
|
251
|
-
{
|
|
252
|
-
this.Request=req;
|
|
253
|
-
this.Response=res;
|
|
254
|
-
this.Next=next;
|
|
255
|
-
|
|
256
|
-
this.DateCount=300;
|
|
257
|
-
this.DayCount=20;
|
|
258
|
-
this.Period=0;
|
|
259
|
-
this.Right=0;
|
|
260
|
-
this.CalculateCount=1;
|
|
261
|
-
|
|
262
|
-
this.StockList;
|
|
263
|
-
this.Script=[];
|
|
264
|
-
this.StartTime=new Date();
|
|
265
|
-
this.MergeType=0; //0 脚本都满足 1 有1个脚本满足
|
|
266
|
-
|
|
267
|
-
this.Result={}; //返回数据
|
|
268
|
-
this.CacheData;
|
|
269
|
-
|
|
270
|
-
this.SetScript=function(script)
|
|
271
|
-
{
|
|
272
|
-
if (!script || !script.length) return false;
|
|
273
|
-
|
|
274
|
-
for(let i in script)
|
|
275
|
-
{
|
|
276
|
-
var item=script[i];
|
|
277
|
-
if (!item.code) continue;
|
|
278
|
-
|
|
279
|
-
var args=[];
|
|
280
|
-
if (item.args && item.args.length)
|
|
281
|
-
{
|
|
282
|
-
var argItem=item.args[i];
|
|
283
|
-
if (argItem.name) args.push({Name:argItem.name, Value:parseFloat(argItem.value)}); //变量值转数值型
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
this.Script.push({Code:item.code, Arguments:args});
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return this.Script.length>0;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
this.Post=function()
|
|
294
|
-
{
|
|
295
|
-
var postData=this.Request.body;
|
|
296
|
-
if (!postData) return this.Error({Message:'post data is empty'});
|
|
297
|
-
|
|
298
|
-
this.StockList=postData.symbol;
|
|
299
|
-
if (!this.StockList || !this.StockList.length) return this.Error({Message:'symbol is empty'});
|
|
300
|
-
|
|
301
|
-
if (!this.SetScript(postData.script)) return this.Error({Message:'code is empty'});
|
|
302
|
-
|
|
303
|
-
if (postData.mergetype>=0) this.MergeType=postData.mergetype;
|
|
304
|
-
if (postData.datecount) this.DateCount=postData.datecount;
|
|
305
|
-
if (postData.daycount) this.DayCount=postData.daycount;
|
|
306
|
-
if (postData.period) this.Period=postData.period;
|
|
307
|
-
if (postData.right) this.Right=postData.right;
|
|
308
|
-
if (postData.calccount) this.CalculateCount=postData.calccount;
|
|
309
|
-
|
|
310
|
-
var self=this;
|
|
311
|
-
this.CacheData=new Map();
|
|
312
|
-
var scriptID=0;
|
|
313
|
-
for(let i in this.StockList)
|
|
314
|
-
{
|
|
315
|
-
var symbol=this.StockList[i];
|
|
316
|
-
let option=
|
|
317
|
-
{
|
|
318
|
-
HQDataType:0,
|
|
319
|
-
Symbol:symbol, Name:null,Data:null,
|
|
320
|
-
MaxReqeustDataCount:this.DateCount, MaxRequestMinuteDayCount:this.DayCount,
|
|
321
|
-
Right:this.Right, Period:this.Period,
|
|
322
|
-
Arguments:this.Script[scriptID].Arguments,
|
|
323
|
-
CallbackParam: { Symbol:symbol, ScriptID:scriptID, Cache:null }, //脚本索引, 数据缓存
|
|
324
|
-
Callback:function(data,param) //数据计算完成回调
|
|
325
|
-
{
|
|
326
|
-
self.RecvExecuteData(data,param);
|
|
327
|
-
},
|
|
328
|
-
ErrorCallback:function(e,param)
|
|
329
|
-
{
|
|
330
|
-
self.ErrorExecute(e,param);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
var run=JSComplier.Execute(this.Script[scriptID].Code,option);
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
next();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
this.RecvExecuteData=function(data,param)
|
|
341
|
-
{
|
|
342
|
-
var analysis=this.AnalysisExecuteData(data,param);
|
|
343
|
-
|
|
344
|
-
if (!analysis && this.MergeType===0)
|
|
345
|
-
{
|
|
346
|
-
this.CacheData.set(param.Symbol,null);
|
|
347
|
-
}
|
|
348
|
-
else if (param.ScriptID>=this.Script.length-1) //脚本都跑完了
|
|
349
|
-
{
|
|
350
|
-
this.CacheData.set(param.Symbol,param.Cache);
|
|
351
|
-
}
|
|
352
|
-
else
|
|
353
|
-
{
|
|
354
|
-
this.RunNextScript(param);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (this.CacheData.size==this.StockList.length) //等所有股票计算完了 返回数据 result
|
|
359
|
-
{
|
|
360
|
-
this.SendResult();
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
next();
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
//执行下一个脚本
|
|
368
|
-
this.RunNextScript=function(param)
|
|
369
|
-
{
|
|
370
|
-
var self=this;
|
|
371
|
-
param.ScriptID+=1;
|
|
372
|
-
|
|
373
|
-
let option=
|
|
374
|
-
{
|
|
375
|
-
HQDataType:0,
|
|
376
|
-
Symbol:param.Symbol, Name:null,Data:null,
|
|
377
|
-
MaxReqeustDataCount:this.DateCount, MaxRequestMinuteDayCount:this.DayCount,
|
|
378
|
-
Right:this.Right, Period:this.Period,
|
|
379
|
-
Arguments:this.Script[param.ScriptID].Arguments,
|
|
380
|
-
CallbackParam: param, //脚本索引
|
|
381
|
-
Callback:function(data,param) //数据计算完成回调
|
|
382
|
-
{
|
|
383
|
-
self.RecvExecuteData(data,param);
|
|
384
|
-
},
|
|
385
|
-
ErrorCallback:function(e,param)
|
|
386
|
-
{
|
|
387
|
-
self.ErrorExecute(e,param);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
var run=JSComplier.Execute(this.Script[param.ScriptID].Code,option);
|
|
392
|
-
|
|
393
|
-
next();
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
//执行脚本错误
|
|
397
|
-
this.ErrorExecute=function(e,param)
|
|
398
|
-
{
|
|
399
|
-
this.RecvExecuteData(null,param)
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
//分析单个脚本执行结果
|
|
403
|
-
this.AnalysisExecuteData=function(data, param)
|
|
404
|
-
{
|
|
405
|
-
if (!data || !data.length) return null;
|
|
406
|
-
|
|
407
|
-
var outData=data[0];
|
|
408
|
-
if (!outData || !outData.Data.length) return null;
|
|
409
|
-
|
|
410
|
-
var klineData=null;
|
|
411
|
-
for(let i in data)
|
|
412
|
-
{
|
|
413
|
-
var item=data[i];
|
|
414
|
-
if (item.Type===100 && item.Name==='TradeDate')
|
|
415
|
-
{
|
|
416
|
-
klineData=item;
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
if (!klineData || !klineData.Data.length) return null;
|
|
421
|
-
if (outData.Data.length!=klineData.Data.length) return null;
|
|
422
|
-
|
|
423
|
-
var analysisData=[];
|
|
424
|
-
for(let i=outData.Data.length-1, j=0; i>0 && j<this.CalculateCount; ++j, --i)
|
|
425
|
-
{
|
|
426
|
-
var value=outData.Data[i];
|
|
427
|
-
if (!value) continue;
|
|
428
|
-
var date=klineData.Data[i];
|
|
429
|
-
if (!date) continue;
|
|
430
|
-
|
|
431
|
-
analysisData.push({Date:date,Value:value});
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
if (!param.Cache)
|
|
435
|
-
{
|
|
436
|
-
param.Cache=new Map();
|
|
437
|
-
for(let i in analysisData)
|
|
438
|
-
{
|
|
439
|
-
var item=analysisData[i];
|
|
440
|
-
param.Cache.set(item.Date, { Date:item.Date, ScriptID:[param.ScriptID] } );
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
else
|
|
444
|
-
{
|
|
445
|
-
if (this.mergetype==0)
|
|
446
|
-
{
|
|
447
|
-
var mergeData=new Map(); //合并数据
|
|
448
|
-
for(let i in analysisData) //取交集
|
|
449
|
-
{
|
|
450
|
-
var item=analysisData[i];
|
|
451
|
-
if (param.Cache.has(item.Date))
|
|
452
|
-
{
|
|
453
|
-
var value=param.Cache.get(item.Date);
|
|
454
|
-
value.Script.push(param.ScriptID);
|
|
455
|
-
mergeData.set(item.Date, value);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
param.Cache=mergeData;
|
|
459
|
-
}
|
|
460
|
-
else
|
|
461
|
-
{
|
|
462
|
-
for(let i in analysisData) //取并集
|
|
463
|
-
{
|
|
464
|
-
var item=analysisData[i];
|
|
465
|
-
if (param.Cache.has(item.Date))
|
|
466
|
-
{
|
|
467
|
-
var value=param.Cache.get(item.Date);
|
|
468
|
-
value.ScriptID.push(param.ScriptID);
|
|
469
|
-
}
|
|
470
|
-
else
|
|
471
|
-
{
|
|
472
|
-
param.Cache.set(item.Date, { Date:item.Date, ScriptID:[param.ScriptID] });
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
return param.Cache.size;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
this.SendResult=function()
|
|
483
|
-
{
|
|
484
|
-
var dateMap=new Map(); // Key=日期 [Value={Symbol:, ScriptID:[], Value:[]}
|
|
485
|
-
for(let item of this.CacheData)
|
|
486
|
-
{
|
|
487
|
-
var stockData=item[1];
|
|
488
|
-
if (!stockData) continue;
|
|
489
|
-
|
|
490
|
-
for(let dateitem of stockData)
|
|
491
|
-
{
|
|
492
|
-
if (dateMap.has(dateitem[0]))
|
|
493
|
-
{
|
|
494
|
-
var temp=dateMap.get(dateitem[0]);
|
|
495
|
-
temp.push({Symbol:item[0], ScriptID:dateitem[1].ScriptID});
|
|
496
|
-
}
|
|
497
|
-
else
|
|
498
|
-
{
|
|
499
|
-
dateMap.set(dateitem[0], [{Symbol:item[0], ScriptID:dateitem[1].ScriptID}]);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
var resultData=[];
|
|
505
|
-
for(let item of dateMap)
|
|
506
|
-
{
|
|
507
|
-
var symbols=[];
|
|
508
|
-
for(let i in item[1])
|
|
509
|
-
{
|
|
510
|
-
symbols.push(item[1][i].Symbol);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
resultData.push({date:item[0], symbols:symbols});
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
var nowDate=new Date();
|
|
517
|
-
this.Result.Ticket=nowDate.getTime() - this.StartTime.getTime();
|
|
518
|
-
|
|
519
|
-
//字段全部小写
|
|
520
|
-
var result={ ticket:this.Result.Ticket, data:resultData };
|
|
521
|
-
this.Response.header("Access-Control-Allow-Origin", "*");
|
|
522
|
-
this.Response.send(result);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
JSCommonMultiComplier.Post=function(req, res, next)
|
|
527
|
-
{
|
|
528
|
-
var controller=new JSCommonMultiComplier(req,res,next);
|
|
529
|
-
controller.Post();
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
//导出统一使用JSCommon命名空间名
|
|
534
|
-
module.exports =
|
|
535
|
-
{
|
|
536
|
-
JSCommonComplierController:
|
|
537
|
-
{
|
|
538
|
-
JSComplierController: JSComplierController,
|
|
539
|
-
JSCommonMultiComplier: JSCommonMultiComplier,
|
|
540
|
-
},
|
|
541
|
-
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
/*
|
|
546
|
-
//测试用例
|
|
547
|
-
var server = restify.createServer({name:'jccomplier.testserver'});
|
|
548
|
-
server.use(restify.plugins.bodyParser()); //支持json post
|
|
549
|
-
server.use(restify.plugins.fullResponse()); //跨域
|
|
550
|
-
server.use(restify.plugins.gzipResponse()); //支持压缩
|
|
551
|
-
|
|
552
|
-
server.post('/api/jscomplier',JSComplierController.Post);
|
|
553
|
-
server.post('/api/jsmcomplier',JSCommonMultiComplier.Post);
|
|
554
|
-
|
|
555
|
-
server.listen(18080, function()
|
|
556
|
-
{
|
|
557
|
-
console.log('%s listening at %s', server.name, server.url);
|
|
558
|
-
});
|
|
559
|
-
*/
|