hqchart 1.1.12693 → 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/package.json +15 -47
- package/src/jscommon/umychart.resource/js/codemirror/javascript.js +1 -1
- 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 -25293
- 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 -90542
- 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 -625
- 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 -2942
- 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 -12055
- 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 +0,0 @@
|
|
|
1
|
-
call umychart.node.bat
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
copy ..\umychart.index.data.js+..\umychart.js+..\umychart.complier.js+umychart.node.export.js ..\umychart.node\umychart.node.js /b
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
////////////////////////////////////////////////////////////////////
|
|
4
|
-
// 后台不能用ajax, 改用request
|
|
5
|
-
//
|
|
6
|
-
///////////////////////////////////////////////////////////////////
|
|
7
|
-
const clientHttp = require('request');
|
|
8
|
-
|
|
9
|
-
function JSNetwork() { }
|
|
10
|
-
JSNetwork.HttpRequest=function(obj) //对请求进行封装
|
|
11
|
-
{
|
|
12
|
-
var options =
|
|
13
|
-
{
|
|
14
|
-
url: obj.url,
|
|
15
|
-
method: obj.type,
|
|
16
|
-
body: obj.data,
|
|
17
|
-
json: true, // Use,If you are sending JSON data
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
clientHttp(options, function (err, res, recvData)
|
|
21
|
-
{
|
|
22
|
-
if (err)
|
|
23
|
-
{
|
|
24
|
-
if (obj.error) obj.error(null,res,err);
|
|
25
|
-
}
|
|
26
|
-
else
|
|
27
|
-
{
|
|
28
|
-
obj.success(recvData);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//把给外界调用的方法暴露出来
|
|
35
|
-
module.exports={
|
|
36
|
-
//指标编译器
|
|
37
|
-
ScriptIndexConsole:ScriptIndexConsole, //指标执行 无UI
|
|
38
|
-
HQ_DATA_TYPE:HQ_DATA_TYPE,
|
|
39
|
-
JSIndexScript:JSIndexScript, //系统指标
|
|
40
|
-
}
|
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2018 jones
|
|
3
|
-
|
|
4
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
-
|
|
6
|
-
开源项目 https://github.com/jones2000/HQChart
|
|
7
|
-
|
|
8
|
-
jones_2000@163.com
|
|
9
|
-
|
|
10
|
-
个股指标回测
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
指标回测
|
|
16
|
-
计算: Trade: {Count 交易次数 Days:交易天数 Success:成功交易次数 Fail:失败交易次数}
|
|
17
|
-
Day: {Count:总运行 Max:最长运行 Min:最短运行 Average:平均运行}
|
|
18
|
-
Profit: 总收益 StockProfit:个股收益 Excess:超额收益 MaxDropdown:最大回撤 Beta:β(Beta)系数(指标里面需要又大盘数据)
|
|
19
|
-
NetValue: [ {Date:日期, Net:净值, Close:股票收盘价, IndexClose:大盘的收盘价}, ]
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function RegressionTest()
|
|
24
|
-
{
|
|
25
|
-
//只读数据不能修改
|
|
26
|
-
this.HistoryData; //K线数据
|
|
27
|
-
this.BuyData; //策略买数据
|
|
28
|
-
this.SellData; //策略卖数据
|
|
29
|
-
this.IndexClose; //大盘收盘价
|
|
30
|
-
this.NetCalculateModel=0; //净值及收益计算模型 0=使用B点开盘价计算 1=使用B点下一天的开盘价计算
|
|
31
|
-
|
|
32
|
-
this.InitialCapital=10000; //初始资金1W
|
|
33
|
-
|
|
34
|
-
//计算结果数据
|
|
35
|
-
this.Data=new Map(); //key:DATA_NAME value:数据
|
|
36
|
-
|
|
37
|
-
this.SetPolicyData=function(obj) //设置策略结果的数据 {KLineData:个股K线数据, BuyData:策略买数据, SellData:策略卖数据, IndexClose:大盘收盘价}
|
|
38
|
-
{
|
|
39
|
-
this.HistoryData=obj.KLineData; //K线数据
|
|
40
|
-
this.BuyData=obj.BuyData; //策略买数据
|
|
41
|
-
this.SellData=obj.SellData; //策略卖数据
|
|
42
|
-
if (obj.IndexClose) this.IndexClose=obj.IndexClose; //大盘收盘价 如果没有大盘数据 就不计算β(Beta)系数 和指数涨幅数据
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.ClearData=function() //清空所有的结果数据
|
|
46
|
-
{
|
|
47
|
-
this.Data=new Map()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
this.GetBSData=function(startDate) //BS点配对 { B:[{Data:K线数据, Count:天数, NextOpen:下一天的开盘价 }], S:{Data:K线数据}}
|
|
51
|
-
{
|
|
52
|
-
var index=null;
|
|
53
|
-
for(var i=0;i<this.HistoryData.length;++i)
|
|
54
|
-
{
|
|
55
|
-
var item=this.HistoryData[i];
|
|
56
|
-
if (item.Date>=startDate)
|
|
57
|
-
{
|
|
58
|
-
index=i;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (index===null) return null;
|
|
63
|
-
|
|
64
|
-
console.log(`[RegressionTest::GetBSData] startDate=${startDate} index=${index}`);
|
|
65
|
-
var aryBS=[];
|
|
66
|
-
var bsItem=null;
|
|
67
|
-
for(var i=index;i<this.HistoryData.length;++i)
|
|
68
|
-
{
|
|
69
|
-
var buyItem=this.BuyData[i];
|
|
70
|
-
var sellItem=this.SellData[i];
|
|
71
|
-
var kLineItem=this.HistoryData[i];
|
|
72
|
-
if (bsItem===null)
|
|
73
|
-
{
|
|
74
|
-
if (buyItem>0)
|
|
75
|
-
{
|
|
76
|
-
var bItem={Data:kLineItem, Count:0 };
|
|
77
|
-
if (i+1<this.HistoryData.length) bItem.NextOpen=this.HistoryData[i+1].Open; //获取下一天的开盘价
|
|
78
|
-
bsItem={ B:[bItem], S:null}; //B可以多个,S一个
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else
|
|
82
|
-
{
|
|
83
|
-
for(var j in bsItem.B) ++bsItem.B[j].Count; //天数+1
|
|
84
|
-
if (buyItem>0)
|
|
85
|
-
{
|
|
86
|
-
var bItem={Data:kLineItem, Count:0};
|
|
87
|
-
if (i+1<this.HistoryData.length) bItem.NextOpen=this.HistoryData[i+1].Open; //获取下一天的开盘价
|
|
88
|
-
bsItem.B.push(bItem);
|
|
89
|
-
}
|
|
90
|
-
else if (sellItem>0)
|
|
91
|
-
{
|
|
92
|
-
bsItem.S={Data:kLineItem};
|
|
93
|
-
aryBS.push(bsItem);
|
|
94
|
-
bsItem=null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var data={StartDate:this.HistoryData[index].Date, StartIndex:index, Count:this.HistoryData.length-index, BSData:aryBS };
|
|
100
|
-
|
|
101
|
-
console.log('[RegressionTest::GetBSData] data',data);
|
|
102
|
-
return data;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this.Calculate=function(data)
|
|
106
|
-
{
|
|
107
|
-
var day={ Count:data.Count, Max:null, Min:null, Average:null }; //Count:总运行 Max:最长运行 Min:最短运行 Average:平均运行
|
|
108
|
-
var trade={Count:0, Days:0, Success:0 , Fail:0, SuccessRate:0}; //Count 交易次数 Days:交易天数 Success:成功交易次数 Fail:失败交易次数
|
|
109
|
-
|
|
110
|
-
for(var i in data.BSData)
|
|
111
|
-
{
|
|
112
|
-
var item=data.BSData[i];
|
|
113
|
-
for(var j in item.B)
|
|
114
|
-
{
|
|
115
|
-
var bItem=item.B[j];
|
|
116
|
-
if (day.Max===null) day.Max=bItem.Count;
|
|
117
|
-
else if (day.Max<bItem.Count) day.Max=bItem.Count;
|
|
118
|
-
|
|
119
|
-
if (day.Min===null) day.Min=bItem.Count;
|
|
120
|
-
else if (day.Min>bItem.Count) day.Min=bItem.Count;
|
|
121
|
-
|
|
122
|
-
++trade.Count;
|
|
123
|
-
trade.Days+=bItem.Count;
|
|
124
|
-
|
|
125
|
-
if (item.S.Data.Close>bItem.Data.Open) ++trade.Success;
|
|
126
|
-
else ++trade.Fail;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (trade.Count>0)
|
|
131
|
-
{
|
|
132
|
-
day.Average=trade.Days/trade.Count;
|
|
133
|
-
trade.SuccessRate=trade.Success/trade.Count;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//计算收益(总收益)
|
|
137
|
-
var profit=1,buyPrice;
|
|
138
|
-
for(var i in data.BSData)
|
|
139
|
-
{
|
|
140
|
-
var item=data.BSData[i];
|
|
141
|
-
if (this.NetCalculateModel===1 && item.B[0].NextOpen>0 ) buyPrice=item.B[0].NextOpen;
|
|
142
|
-
else buyPrice=item.B[0].Data.Open;
|
|
143
|
-
var sellPrice=item.S.Data.Close;
|
|
144
|
-
var value=(sellPrice-buyPrice)/buyPrice+1;
|
|
145
|
-
profit*=value;
|
|
146
|
-
}
|
|
147
|
-
profit-=1; //公式:[(1+收益1)*(1+收益2)*(1+收益3)……(1+收益n)-1] x 100%
|
|
148
|
-
|
|
149
|
-
//标的证券收益
|
|
150
|
-
var yClose=this.HistoryData[data.StartIndex].Close; //使用前收盘
|
|
151
|
-
var close=this.HistoryData[this.HistoryData.length-1].Close; //最后一个大盘收盘价
|
|
152
|
-
var stockProfit=(close-yClose)/yClose;
|
|
153
|
-
|
|
154
|
-
console.log(`[RegressionTest::Calculate] stock profit first[${this.HistoryData[data.StartIndex].Date}, YClose=${this.HistoryData[data.StartIndex].YClose}] end[${this.HistoryData[this.HistoryData.length-1].Date}, Close=${this.HistoryData[this.HistoryData.length-1].Close}]`);
|
|
155
|
-
|
|
156
|
-
var netValue=this.CaclulateNetValue(data);
|
|
157
|
-
var maxDropdown=null, beta=null;
|
|
158
|
-
if (netValue && netValue.length>0)
|
|
159
|
-
{
|
|
160
|
-
maxDropdown=this.CaclulateMaxDropdown(netValue);
|
|
161
|
-
if (this.IndexClose) beta=this.CaclulateBeta(netValue);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
//Profit:收益 StockProfit:标的证券收益 Excess:超额收益(加上BS配对的数据)
|
|
165
|
-
var result={ Day:day, Trade:trade, Profit:profit, StockProfit:stockProfit, Excess:profit-stockProfit, NetValue:netValue, MaxDropdown:maxDropdown, Beta:beta,BSDataPair:data.BSData};
|
|
166
|
-
|
|
167
|
-
console.log('[RegressionTest::Calculate] NetCalculateModel, result ',this.NetCalculateModel, result);
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
this.CaclulateNetValue=function(data) //计算净值
|
|
172
|
-
{
|
|
173
|
-
var index=data.StartIndex;
|
|
174
|
-
|
|
175
|
-
var aryDay=[]; //{Close:收盘 , Open:开盘, Position:持仓数量, Cache:现金 , MarketValue:总市值}
|
|
176
|
-
var lastDayItem={Position:0, Cache:this.InitialCapital };
|
|
177
|
-
var bsItem=null, buyPrice;
|
|
178
|
-
for(var i=index;i<this.HistoryData.length;++i)
|
|
179
|
-
{
|
|
180
|
-
var buyItem=this.BuyData[i];
|
|
181
|
-
var sellItem=this.SellData[i];
|
|
182
|
-
var kLineItem=this.HistoryData[i];
|
|
183
|
-
var dayItem={Date:kLineItem.Date, Position:lastDayItem.Position, Cache:lastDayItem.Cache, Open:kLineItem.Open, Close:kLineItem.Close};
|
|
184
|
-
dayItem.MarketValue=dayItem.Position*dayItem.Close+dayItem.Cache; //市值 股票+现金
|
|
185
|
-
|
|
186
|
-
if (bsItem===null)
|
|
187
|
-
{
|
|
188
|
-
if (buyItem>0) //买
|
|
189
|
-
{
|
|
190
|
-
bsItem={ B:{Data:kLineItem}, S:null};
|
|
191
|
-
if (this.NetCalculateModel===1 && i+1<this.HistoryData.length && this.HistoryData[i+1].Open>0)
|
|
192
|
-
buyPrice=this.HistoryData[i+1].Open; //使用B点下一天的开盘价买
|
|
193
|
-
else
|
|
194
|
-
buyPrice=dayItem.Open;
|
|
195
|
-
|
|
196
|
-
let position=parseInt(dayItem.Cache/buyPrice); //开盘价买
|
|
197
|
-
let cache=dayItem.Cache-buyPrice*position; //剩余的现金
|
|
198
|
-
|
|
199
|
-
dayItem.Position=position;
|
|
200
|
-
dayItem.Cache=cache;
|
|
201
|
-
dayItem.MarketValue=dayItem.Position*dayItem.Close+dayItem.Cache; //市值 股票+现金
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else
|
|
205
|
-
{
|
|
206
|
-
if (sellItem>0) //卖
|
|
207
|
-
{
|
|
208
|
-
bsItem.S={Data:kLineItem};
|
|
209
|
-
bsItem=null;
|
|
210
|
-
|
|
211
|
-
let stockValue=dayItem.Position*dayItem.Close; //卖掉的股票钱
|
|
212
|
-
dayItem.Position=0;
|
|
213
|
-
dayItem.Cache+=stockValue; //卖掉的钱放到现金里面
|
|
214
|
-
dayItem.MarketValue=dayItem.Position*dayItem.Close+dayItem.Cache; //市值 股票+现金
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
//缓存上一天的数据
|
|
219
|
-
lastDayItem.Position=dayItem.Position;
|
|
220
|
-
lastDayItem.Cache=dayItem.Cache;
|
|
221
|
-
|
|
222
|
-
dayItem.Net=dayItem.MarketValue/this.InitialCapital; //净值
|
|
223
|
-
if (this.IndexClose) dayItem.IndexClose=this.IndexClose[i]; //指数收盘价
|
|
224
|
-
aryDay.push(dayItem);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
//console.log('[RegressionTest::CaclulateNetValue] aryDay',aryDay);
|
|
228
|
-
if (aryDay.length<=0) return [];
|
|
229
|
-
|
|
230
|
-
var netValue=[]; //净值 {Date:日期, Net:净值, Close:股票收盘价, IndexClose:大盘的收盘价}
|
|
231
|
-
for(var i=0;i<aryDay.length;++i)
|
|
232
|
-
{
|
|
233
|
-
var item=aryDay[i];
|
|
234
|
-
var dataItem={ Net:item.Net, Date:item.Date, Close:item.Close };
|
|
235
|
-
if (item.IndexClose) dataItem.IndexClose=item.IndexClose;
|
|
236
|
-
netValue.push(dataItem);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
//console.log('[RegressionTest::CaclulateNetValue] netValue',netValue);
|
|
240
|
-
|
|
241
|
-
return netValue;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
this.CaclulateMaxDropdown=function(data) //最大回撤
|
|
245
|
-
{
|
|
246
|
-
var maxNet=data[0].Net; //最大净值
|
|
247
|
-
var maxValue=0;
|
|
248
|
-
var maxDay;
|
|
249
|
-
for(var i=1;i<data.length;++i)
|
|
250
|
-
{
|
|
251
|
-
var item=data[i];
|
|
252
|
-
var value=1-(item.Net/maxNet); //1-策略当日净值 / 当日之前策略最大净值
|
|
253
|
-
if (maxValue<value)
|
|
254
|
-
{
|
|
255
|
-
maxValue=value;
|
|
256
|
-
maxDay=item;
|
|
257
|
-
}
|
|
258
|
-
if (maxNet<item.Net) maxNet=item.Net; //取当前最大的净值
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
console.log('[RegressionTest::CaclulateMaxDropdown] maxDay',maxDay);
|
|
262
|
-
return maxValue;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
this.CaclulateBeta=function(data) //β(Beta)系数,参数是净值数组NetValue
|
|
266
|
-
{
|
|
267
|
-
var lastItem=data[0]; //上一天的数据
|
|
268
|
-
var indexProfit=[]; //大盘涨幅
|
|
269
|
-
var bsProfit=[]; //策略涨幅
|
|
270
|
-
var indexProfitTotal=0, bsProfitTotal=0;
|
|
271
|
-
for(var i=1; i<data.length; ++i)
|
|
272
|
-
{
|
|
273
|
-
indexProfit[i-1]=0;
|
|
274
|
-
bsProfit[i-1]=0;
|
|
275
|
-
|
|
276
|
-
var item=data[i];
|
|
277
|
-
|
|
278
|
-
if (item.IndexClose>0 && lastItem.IndexClose>0) indexProfit[i-1]=(item.IndexClose-lastItem.IndexClose)/lastItem.IndexClose;
|
|
279
|
-
if (item.Net>0 && lastItem.Net>0) bsProfit[i-1]=(item.Net-lastItem.Net)/lastItem.Net;
|
|
280
|
-
//if (item.Close>0 && lastItem.Close>0) bsProfit[i-1]=(item.Close-lastItem.Close)/lastItem.Close;
|
|
281
|
-
|
|
282
|
-
indexProfitTotal+=indexProfit[i-1];
|
|
283
|
-
bsProfitTotal+=bsProfit[i-1];
|
|
284
|
-
|
|
285
|
-
lastItem=item;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
var averageIndexProfit=indexProfitTotal/indexProfit.length;
|
|
289
|
-
var averageBSProfit=bsProfitTotal/bsProfit.length;
|
|
290
|
-
|
|
291
|
-
var betaCOV=0; //协方差
|
|
292
|
-
for(var i=0;i<indexProfit.length;++i)
|
|
293
|
-
{
|
|
294
|
-
betaCOV+=(bsProfit[i]-averageBSProfit)*(indexProfit[i]-averageIndexProfit);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
var betaVAR=0; //标准差:方差的开2次方
|
|
298
|
-
for(var i=0;i<indexProfit.length;++i)
|
|
299
|
-
{
|
|
300
|
-
betaVAR+=(indexProfit[i]-averageIndexProfit)*(indexProfit[i]-averageIndexProfit);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return betaCOV/betaVAR;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
this.Execute=function(obj) //开始计算[ { Name:名字 , Date:起始日期 格式(20180101) }, ....]
|
|
307
|
-
{
|
|
308
|
-
|
|
309
|
-
for(var i in obj )
|
|
310
|
-
{
|
|
311
|
-
var item=obj[i];
|
|
312
|
-
if (this.Data.has(item.Name)) //已经计算过了不计算
|
|
313
|
-
{
|
|
314
|
-
console.log(`[RegressionTest::Execute] id=${i} Name=${item.Name} Date:${item.Date} is exsit.`);
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
console.log(`[RegressionTest::Execute] id=${i} Name=${item.Name} Date:${item.Date}`);
|
|
319
|
-
var data=this.GetBSData(item.Date);
|
|
320
|
-
var result=this.Calculate(data);
|
|
321
|
-
this.Data.set(item.Name, result);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
//计算叠加数据 (日期必须匹配)
|
|
329
|
-
RegressionTest.CaclulateOverlayData=function(obj) //{Main:主数据, Sub:[]//多组叠加数据}
|
|
330
|
-
{
|
|
331
|
-
if (!obj.Main || !obj.Sub) return null;
|
|
332
|
-
var count=obj.Main.length;
|
|
333
|
-
for(var i in obj.Sub)
|
|
334
|
-
{
|
|
335
|
-
var item=obj.Sub[i];
|
|
336
|
-
if (item.length!=count)
|
|
337
|
-
{
|
|
338
|
-
console.log(`[RegressionTest::OverlayData] id=${i} data count not match. MainData count=${count}`);
|
|
339
|
-
return null;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
var result=[]; //[0]:主数据 , [1...]:叠加数据
|
|
344
|
-
|
|
345
|
-
var firstData={Sub:[]};
|
|
346
|
-
firstData.Main=obj.Main[0];
|
|
347
|
-
result.push([]);
|
|
348
|
-
for(var i=0;i<obj.Sub.length;++i)
|
|
349
|
-
{
|
|
350
|
-
var subData=obj.Sub[i];
|
|
351
|
-
firstData.Sub[i]=subData[0];
|
|
352
|
-
result.push([]);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
for(var i=0;i<obj.Main.length;++i)
|
|
356
|
-
{
|
|
357
|
-
var value=obj.Main[i];
|
|
358
|
-
var valuePer=(value-firstData.Main)/firstData.Main;
|
|
359
|
-
result[0][i]=valuePer;
|
|
360
|
-
|
|
361
|
-
for(var j=0;j<obj.Sub.length;++j)
|
|
362
|
-
{
|
|
363
|
-
var subData=obj.Sub[j];
|
|
364
|
-
var subValue=subData[i];
|
|
365
|
-
var subValuePer=(subValue-firstData.Sub[j])/firstData.Sub[j];
|
|
366
|
-
result[j+1][i]=subValuePer;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
return result;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
RegressionTest.GetPolicyData=function(data) //获取指标数据里面需要计算回测的数据
|
|
375
|
-
{
|
|
376
|
-
var policyData={KLineData:null, IndexClose:null, BuyData:null, SellData:null};
|
|
377
|
-
policyData.KLineData=data.HistoryData.Data; //个股K线数据,
|
|
378
|
-
|
|
379
|
-
for(var i in data.OutVar)
|
|
380
|
-
{
|
|
381
|
-
var item=data.OutVar[i];
|
|
382
|
-
if (item.Name=='INDEXCLOSE')
|
|
383
|
-
{
|
|
384
|
-
policyData.IndexClose=item.Data; //绑定大盘收盘数据
|
|
385
|
-
}
|
|
386
|
-
else if (item.Name=='DRAWICON') //买卖盘BS函数
|
|
387
|
-
{
|
|
388
|
-
if (item.Draw && item.Draw.Icon)
|
|
389
|
-
{
|
|
390
|
-
if (item.Draw.Icon.ID===13) policyData.BuyData=item.Draw.DrawData; //买
|
|
391
|
-
else if (item.Draw.Icon.ID===14) policyData.SellData=item.Draw.DrawData; //卖
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (policyData.KLineData && policyData.BuyData && policyData.SellData) return policyData;
|
|
397
|
-
|
|
398
|
-
return null;
|
|
399
|
-
}
|
|
400
|
-
|