mm_maths 1.2.0 → 1.2.1
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/README.md +28 -12
- package/index.js +6 -410
- package/lib/maths.js +429 -0
- package/package.json +42 -33
- package/tool/math/index.js +83 -0
- package/tool/math/tool.json +60 -0
- package/.gitattributes +0 -5
- package/convert/format_multiply/index.js +0 -40
- package/convert/format_multiply/test.js +0 -5
- package/convert/format_plus/index.js +0 -42
- package/convert/format_plus/test.js +0 -4
- package/convert/four_run/convert.json +0 -8
- package/convert/four_run/index.js +0 -20
- package/convert/four_run/test.js +0 -7
- package/convert/multiply_divide/index.js +0 -197
- package/convert/multiply_divide/test.js +0 -14
- package/convert/plus_subtract/index.js +0 -160
- package/convert/plus_subtract/test.js +0 -15
- package/convert/readme.md +0 -2
- package/doc/mm_math.doc +0 -0
- package/doc//345/207/275/346/225/260/347/254/246/345/217/267/344/270/200/350/247/210/350/241/250.xls +0 -0
- package/express/README.md +0 -2
- package/identities/chemistry/readme.md +0 -1
- package/identities/equation/readme.md +0 -2
- package/identities/geometry/readme.md +0 -1
- package/identities/geometry/rectangle/readme.md +0 -1
- package/identities/geometry/string/readme.md +0 -1
- package/identities/physics/readme.md +0 -1
- package/identities/readme.md +0 -2
- package/math/array/average/index.js +0 -10
- package/math/array/average/math.json +0 -8
- package/math/array/average/test.js +0 -3
- package/math/array/col/index.js +0 -17
- package/math/array/col/math.json +0 -8
- package/math/array/col/test.js +0 -4
- package/math/array/composite/index.js +0 -35
- package/math/array/composite/math.json +0 -8
- package/math/array/composite/test.js +0 -4
- package/math/array/deviations/index.js +0 -15
- package/math/array/deviations/math.json +0 -8
- package/math/array/deviations/test.js +0 -3
- package/math/array/difference/index.js +0 -9
- package/math/array/difference/math.json +0 -8
- package/math/array/difference/test.js +0 -7
- package/math/array/distinct/index.js +0 -20
- package/math/array/distinct/math.json +0 -8
- package/math/array/distinct/test.js +0 -8
- package/math/array/distributive/index.js +0 -24
- package/math/array/distributive/math.json +0 -8
- package/math/array/distributive/test.js +0 -3
- package/math/array/divisor/index.js +0 -17
- package/math/array/divisor/math.json +0 -8
- package/math/array/divisor/test.js +0 -6
- package/math/array/intersect/index.js +0 -9
- package/math/array/intersect/math.json +0 -8
- package/math/array/intersect/test.js +0 -7
- package/math/array/max/index.js +0 -17
- package/math/array/max/math.json +0 -8
- package/math/array/max/test.js +0 -8
- package/math/array/median/index.js +0 -34
- package/math/array/median/math.json +0 -8
- package/math/array/median/test.js +0 -4
- package/math/array/min/index.js +0 -16
- package/math/array/min/math.json +0 -8
- package/math/array/min/test.js +0 -8
- package/math/array/multiple/index.js +0 -17
- package/math/array/multiple/math.json +0 -8
- package/math/array/multiple/test.js +0 -7
- package/math/array/natural/index.js +0 -17
- package/math/array/natural/math.json +0 -8
- package/math/array/natural/test.js +0 -9
- package/math/array/pos/index.js +0 -21
- package/math/array/pos/math.json +0 -8
- package/math/array/pos/test.js +0 -41
- package/math/array/prime/index.js +0 -35
- package/math/array/prime/math.json +0 -8
- package/math/array/prime/test.js +0 -4
- package/math/array/readme.md +0 -5
- package/math/array/reduction/index.js +0 -57
- package/math/array/reduction/math.json +0 -8
- package/math/array/reduction/test.js +0 -42
- package/math/array/rising/index.js +0 -8
- package/math/array/rising/math.json +0 -8
- package/math/array/rising/test.js +0 -3
- package/math/array/row/index.js +0 -11
- package/math/array/row/math.json +0 -8
- package/math/array/row/test.js +0 -4
- package/math/array/square/index.js +0 -12
- package/math/array/square/math.json +0 -8
- package/math/array/square/test.js +0 -3
- package/math/array/stddev/index.js +0 -17
- package/math/array/stddev/math.json +0 -8
- package/math/array/stddev/test.js +0 -4
- package/math/array/sum/index.js +0 -13
- package/math/array/sum/math.json +0 -8
- package/math/array/sum/test.js +0 -3
- package/math/array/sumproduct/index.js +0 -13
- package/math/array/sumproduct/math.json +0 -8
- package/math/array/sumproduct/test.js +0 -3
- package/math/array/union/index.js +0 -11
- package/math/array/union/math.json +0 -8
- package/math/array/union/test.js +0 -7
- package/math/base/abs/index.js +0 -8
- package/math/base/abs/math.json +0 -8
- package/math/base/abs/test.js +0 -3
- package/math/base/ceil/index.js +0 -8
- package/math/base/ceil/math.json +0 -8
- package/math/base/ceil/test.js +0 -3
- package/math/base/denominator/index.js +0 -17
- package/math/base/denominator/math.json +0 -9
- package/math/base/denominator/test.js +0 -3
- package/math/base/diff/index.js +0 -9
- package/math/base/diff/math.json +0 -8
- package/math/base/diff/test.js +0 -6
- package/math/base/exp/index.js +0 -8
- package/math/base/exp/math.json +0 -8
- package/math/base/exp/test.js +0 -6
- package/math/base/floor/index.js +0 -8
- package/math/base/floor/math.json +0 -8
- package/math/base/floor/test.js +0 -3
- package/math/base/int/index.js +0 -8
- package/math/base/int/math.json +0 -8
- package/math/base/int/test.js +0 -2
- package/math/base/log/index.js +0 -8
- package/math/base/log/math.json +0 -8
- package/math/base/log/test.js +0 -4
- package/math/base/max_divisor/index.js +0 -10
- package/math/base/max_divisor/math.json +0 -9
- package/math/base/max_divisor/test.js +0 -3
- package/math/base/min_multiple/index.js +0 -11
- package/math/base/min_multiple/math.json +0 -9
- package/math/base/min_multiple/test.js +0 -3
- package/math/base/mod/index.js +0 -8
- package/math/base/mod/math.json +0 -8
- package/math/base/mod/test.js +0 -3
- package/math/base/pow/index.js +0 -9
- package/math/base/pow/math.json +0 -8
- package/math/base/pow/test.js +0 -3
- package/math/base/rand/index.js +0 -21
- package/math/base/rand/math.json +0 -8
- package/math/base/rand/test.js +0 -3
- package/math/base/random/index.js +0 -12
- package/math/base/random/math.json +0 -8
- package/math/base/random/test.js +0 -4
- package/math/base/readme.md +0 -1
- package/math/base/round/index.js +0 -14
- package/math/base/round/math.json +0 -8
- package/math/base/round/test.js +0 -4
- package/math/base/sqrt/index.js +0 -8
- package/math/base/sqrt/math.json +0 -8
- package/math/base/sqrt/test.js +0 -5
- package/math/readme.md +0 -1
- package/math/stock/AMOUNT/index.js +0 -7
- package/math/stock/AMOUNT/math.json +0 -8
- package/math/stock/AMOUNT/test.js +0 -4
- package/math/stock/AP/index.js +0 -20
- package/math/stock/AP/math.json +0 -8
- package/math/stock/AP/test.js +0 -5
- package/math/stock/AROON/index.js +0 -14
- package/math/stock/ARR/index.js +0 -10
- package/math/stock/ARR/math.json +0 -8
- package/math/stock/ARR/test.js +0 -45
- package/math/stock/ASTAR/index.js +0 -20
- package/math/stock/ASTAR/math.json +0 -8
- package/math/stock/ASTAR/test.js +0 -4
- package/math/stock/AVERAGE/index.js +0 -14
- package/math/stock/AVERAGE/math.json +0 -8
- package/math/stock/AVERAGE/test.js +0 -5
- package/math/stock/AYANG/index.js +0 -18
- package/math/stock/AYANG/math.json +0 -8
- package/math/stock/AYANG/test.js +0 -4
- package/math/stock/AYIN/index.js +0 -18
- package/math/stock/AYIN/math.json +0 -8
- package/math/stock/AYIN/test.js +0 -4
- package/math/stock/BBANDS/index.js +0 -0
- package/math/stock/BETWEEN/index.js +0 -24
- package/math/stock/BETWEEN/math.json +0 -8
- package/math/stock/BETWEEN/test.js +0 -4
- package/math/stock/CLOSE/c.js +0 -0
- package/math/stock/CLOSE/index.js +0 -11
- package/math/stock/CLOSE/math.json +0 -8
- package/math/stock/CLOSE/test.js +0 -45
- package/math/stock/CP/index.js +0 -35
- package/math/stock/CP/math.json +0 -8
- package/math/stock/CP/test.js +0 -5
- package/math/stock/CROSS/index.js +0 -29
- package/math/stock/CROSS/math.json +0 -8
- package/math/stock/CROSS/test.js +0 -6
- package/math/stock/DATE/index.js +0 -14
- package/math/stock/DATE/math.json +0 -8
- package/math/stock/DATE/test.js +0 -45
- package/math/stock/DOWN/index.js +0 -19
- package/math/stock/DOWN/math.json +0 -8
- package/math/stock/DOWN/test.js +0 -8
- package/math/stock/DOWNNDAY/index.js +0 -27
- package/math/stock/DOWNNDAY/math.json +0 -8
- package/math/stock/DOWNNDAY/test.js +0 -10
- package/math/stock/EMA/index.js +0 -30
- package/math/stock/EMA/math.json +0 -8
- package/math/stock/EMA/test.js +0 -4
- package/math/stock/HHV/index.js +0 -16
- package/math/stock/HHV/math.json +0 -8
- package/math/stock/HHV/test.js +0 -4
- package/math/stock/HIGH/h.js +0 -0
- package/math/stock/HIGH/index.js +0 -11
- package/math/stock/HIGH/math.json +0 -8
- package/math/stock/HIGH/test.js +0 -45
- package/math/stock/LEFT/index.js +0 -13
- package/math/stock/LEFT/math.json +0 -8
- package/math/stock/LEFT/test.js +0 -4
- package/math/stock/LLV/index.js +0 -16
- package/math/stock/LLV/math.json +0 -8
- package/math/stock/LLV/test.js +0 -4
- package/math/stock/LOW/index.js +0 -11
- package/math/stock/LOW/l.js +0 -0
- package/math/stock/LOW/math.json +0 -8
- package/math/stock/LOW/test.js +0 -47
- package/math/stock/MA/index.js +0 -30
- package/math/stock/MA/math.json +0 -8
- package/math/stock/MA/test.js +0 -5
- package/math/stock/MACD/index.js +0 -29
- package/math/stock/MACD/math.json +0 -8
- package/math/stock/MACD/test.js +0 -4
- package/math/stock/MFI/index.js +0 -33
- package/math/stock/NMA/index.js +0 -23
- package/math/stock/NMA/math.json +0 -8
- package/math/stock/NMA/test.js +0 -5
- package/math/stock/NOT/index.js +0 -7
- package/math/stock/NOT/math.json +0 -8
- package/math/stock/NOT/test.js +0 -10
- package/math/stock/OPEN/index.js +0 -11
- package/math/stock/OPEN/math.json +0 -8
- package/math/stock/OPEN/o.js +0 -0
- package/math/stock/OPEN/test.js +0 -45
- package/math/stock/PERCPRICEOSC/index.js +0 -19
- package/math/stock/REF/index.js +0 -15
- package/math/stock/REF/math.json +0 -8
- package/math/stock/REF/test.js +0 -5
- package/math/stock/RIGHT/index.js +0 -13
- package/math/stock/RIGHT/math.json +0 -8
- package/math/stock/RIGHT/test.js +0 -4
- package/math/stock/RSI/index.js +0 -36
- package/math/stock/SMA/index.js +0 -12
- package/math/stock/STAR/index.js +0 -19
- package/math/stock/STAR/math.json +0 -8
- package/math/stock/STAR/test.js +0 -4
- package/math/stock/STOCHRSI/index.js +0 -19
- package/math/stock/SUM/index.js +0 -19
- package/math/stock/SUM/math.json +0 -8
- package/math/stock/SUM/test.js +0 -7
- package/math/stock/TIME/index.js +0 -14
- package/math/stock/TIME/math.json +0 -8
- package/math/stock/TIME/test.js +0 -45
- package/math/stock/TRUERANGE/index.js +0 -19
- package/math/stock/UP/index.js +0 -19
- package/math/stock/UP/math.json +0 -8
- package/math/stock/UP/test.js +0 -9
- package/math/stock/UPNDAY/index.js +0 -28
- package/math/stock/UPNDAY/math.json +0 -8
- package/math/stock/UPNDAY/test.js +0 -10
- package/math/stock/VMA/index.js +0 -41
- package/math/stock/VMA/math.json +0 -8
- package/math/stock/VMA/test.js +0 -7
- package/math/stock/VOL/index.js +0 -11
- package/math/stock/VOL/math.json +0 -8
- package/math/stock/VOL/test.js +0 -45
- package/math/stock/WILLR/index.js +0 -22
- package/math/stock/YANG/index.js +0 -16
- package/math/stock/YANG/math.json +0 -8
- package/math/stock/YANG/test.js +0 -4
- package/math/stock/YIN/index.js +0 -16
- package/math/stock/YIN/math.json +0 -8
- package/math/stock/YIN/test.js +0 -4
- package/math/stock/readme.md +0 -294
- package/math/trigonometric/cos/index.js +0 -8
- package/math/trigonometric/cos/math.json +0 -20
- package/math/trigonometric/cot/index.js +0 -8
- package/math/trigonometric/cot/math.json +0 -17
- package/math/trigonometric/csc/index.js +0 -8
- package/math/trigonometric/csc/math.json +0 -20
- package/math/trigonometric/readme.md +0 -2
- package/math/trigonometric/sec/index.js +0 -8
- package/math/trigonometric/sec/math.json +0 -20
- package/math/trigonometric/sin/index.js +0 -8
- package/math/trigonometric/sin/math.json +0 -20
- package/math/trigonometric/tan/index.js +0 -8
- package/math/trigonometric/tan/math.json +0 -18
- package/symbol/brackets/index.js +0 -46
- package/symbol/brackets/symbol.json +0 -8
- package/symbol/brackets/test.js +0 -12
- package/symbol/decimal/index.js +0 -41
- package/symbol/decimal/symbol.json +0 -8
- package/symbol/decimal/test.js +0 -2
- package/symbol/percentage/index.js +0 -48
- package/symbol/percentage/symbol.json +0 -8
- package/symbol/percentage/test.js +0 -2
- package/symbol/pi/index.js +0 -20
- package/symbol/pi/symbol.json +0 -9
- package/symbol/pi/test.js +0 -2
- package/symbol/power/index.js +0 -111
- package/symbol/power/symbol.json +0 -8
- package/symbol/power/test.js +0 -10
- package/symbol/readme.md +0 -2
- package/test.js +0 -32
- package/test2.js +0 -47
package/math/stock/HHV/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const max = require('../../array/max');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 最高价(周期性) 注意, 数值是按时间倒序的
|
|
5
|
-
* @param {Array} arr 数组
|
|
6
|
-
* @param {Number} period 周期时长
|
|
7
|
-
* @return {Number}
|
|
8
|
-
*/
|
|
9
|
-
module.exports = function HHV(arr, period = 5) {
|
|
10
|
-
var len = arr.length;
|
|
11
|
-
if(period > len){
|
|
12
|
-
period = len
|
|
13
|
-
}
|
|
14
|
-
var ar = arr.slice(0, period);
|
|
15
|
-
return max(ar);
|
|
16
|
-
}
|
package/math/stock/HHV/math.json
DELETED
package/math/stock/HHV/test.js
DELETED
package/math/stock/HIGH/h.js
DELETED
|
File without changes
|
package/math/stock/HIGH/index.js
DELETED
package/math/stock/HIGH/test.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var OPEN = require('./index');
|
|
2
|
-
|
|
3
|
-
var list = [{
|
|
4
|
-
// 股票编码
|
|
5
|
-
"gid": "sh601009",
|
|
6
|
-
// 股票名称
|
|
7
|
-
"name": "南京银行",
|
|
8
|
-
// 昨日收盘价
|
|
9
|
-
"close": 11,
|
|
10
|
-
// 今日开盘价
|
|
11
|
-
"open": 3,
|
|
12
|
-
// 今日最高价
|
|
13
|
-
"high": 0,
|
|
14
|
-
// 今日最低价
|
|
15
|
-
"low": 0,
|
|
16
|
-
// 当前价
|
|
17
|
-
"now": 0,
|
|
18
|
-
// 日期时间
|
|
19
|
-
"datetime": "",
|
|
20
|
-
// 成交量
|
|
21
|
-
"vol": 0
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// 股票编码
|
|
25
|
-
"gid": "sh601009",
|
|
26
|
-
// 股票名称
|
|
27
|
-
"name": "南京银行",
|
|
28
|
-
// 昨日收盘价
|
|
29
|
-
"close": 10,
|
|
30
|
-
// 今日开盘价
|
|
31
|
-
"open": 4,
|
|
32
|
-
// 今日最高价
|
|
33
|
-
"high": 0,
|
|
34
|
-
// 今日最低价
|
|
35
|
-
"low": 0,
|
|
36
|
-
// 当前价
|
|
37
|
-
"now": 0,
|
|
38
|
-
// 日期时间
|
|
39
|
-
"datetime": "",
|
|
40
|
-
// 成交量
|
|
41
|
-
"vol": 0
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
console.log(OPEN(list));
|
package/math/stock/LEFT/index.js
DELETED
package/math/stock/LEFT/test.js
DELETED
package/math/stock/LLV/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const min = require('../../array/min');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 最低价(周期性) 注意, 数值是按时间倒序的
|
|
5
|
-
* @param {Array} arr 数组
|
|
6
|
-
* @param {Number} period 周期时长
|
|
7
|
-
* @return {Number}
|
|
8
|
-
*/
|
|
9
|
-
module.exports = function LLV(arr, period = 5) {
|
|
10
|
-
var len = arr.length;
|
|
11
|
-
if (period > len) {
|
|
12
|
-
period = len
|
|
13
|
-
}
|
|
14
|
-
var ar = arr.slice(0, period);
|
|
15
|
-
return min(ar);
|
|
16
|
-
}
|
package/math/stock/LLV/math.json
DELETED
package/math/stock/LLV/test.js
DELETED
package/math/stock/LOW/index.js
DELETED
package/math/stock/LOW/l.js
DELETED
|
File without changes
|
package/math/stock/LOW/math.json
DELETED
package/math/stock/LOW/test.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
var OPEN = require('./index');
|
|
2
|
-
|
|
3
|
-
var list = [{
|
|
4
|
-
// 股票编码
|
|
5
|
-
"gid": "sh601009",
|
|
6
|
-
// 股票名称
|
|
7
|
-
"name": "南京银行",
|
|
8
|
-
// 昨日收盘价
|
|
9
|
-
"close": 11,
|
|
10
|
-
// 今日开盘价
|
|
11
|
-
"open": 3,
|
|
12
|
-
// 今日最高价
|
|
13
|
-
"high": 0,
|
|
14
|
-
// 今日最低价
|
|
15
|
-
"low": 0,
|
|
16
|
-
// 当前价
|
|
17
|
-
"now": 0,
|
|
18
|
-
// 日期时间
|
|
19
|
-
"datetime": "",
|
|
20
|
-
// 成交量
|
|
21
|
-
"vol": 0
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// 股票编码
|
|
25
|
-
"gid": "sh601009",
|
|
26
|
-
// 股票名称
|
|
27
|
-
"name": "南京银行",
|
|
28
|
-
// 昨日收盘价
|
|
29
|
-
"close": 10,
|
|
30
|
-
// 今日开盘价
|
|
31
|
-
"open": 4,
|
|
32
|
-
// 今日最高价
|
|
33
|
-
"high": 0,
|
|
34
|
-
// 今日最低价
|
|
35
|
-
"low": 0,
|
|
36
|
-
// 当前价
|
|
37
|
-
"now": 0,
|
|
38
|
-
// 日期
|
|
39
|
-
"datetime": "",
|
|
40
|
-
// 时间
|
|
41
|
-
"time": "",
|
|
42
|
-
// 成交量
|
|
43
|
-
"vol": 0
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
console.log(OPEN(list));
|
package/math/stock/MA/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function add(arr, i, period) {
|
|
3
|
-
var num = 0.0000;
|
|
4
|
-
for (var n = 0; n < period; n++) {
|
|
5
|
-
num += arr[i - n] + 0.0;
|
|
6
|
-
}
|
|
7
|
-
return num / period;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 末日加权移动平均值
|
|
12
|
-
* @param {Array} arr 数组
|
|
13
|
-
* @param {Number} i 当前索引
|
|
14
|
-
* @param {Number} period 周期
|
|
15
|
-
* @return {Array} 返回平均值数组
|
|
16
|
-
*/
|
|
17
|
-
module.exports = function MA(arr, period = 5) {
|
|
18
|
-
if (arr.length < period) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
var ma = [];
|
|
22
|
-
|
|
23
|
-
for (var i = 0; i < period - 1; i++) {
|
|
24
|
-
ma.push(NaN);
|
|
25
|
-
}
|
|
26
|
-
for (var i = period - 1; i < arr.length; i++) {
|
|
27
|
-
ma.push(add(arr, i, period));
|
|
28
|
-
}
|
|
29
|
-
return ma;
|
|
30
|
-
}
|
package/math/stock/MA/math.json
DELETED
package/math/stock/MA/test.js
DELETED
package/math/stock/MACD/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const EMA = require('../EMA');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 异同移动平均线
|
|
5
|
-
* @param {Array} arr
|
|
6
|
-
* @param {Number} i12
|
|
7
|
-
* @param {Number} i26
|
|
8
|
-
* @param {Number} i9 DIF周期时长
|
|
9
|
-
* @return {type}
|
|
10
|
-
*/
|
|
11
|
-
module.exports = function MACD(arr, i12 = 12, i26 = 26, i9 = 9) {
|
|
12
|
-
var ema12 = EMA(arr, i12);
|
|
13
|
-
var ema26 = EMA(arr, i26);
|
|
14
|
-
var DIF = [];
|
|
15
|
-
for(var i = 0; i < ema26.length; i++){
|
|
16
|
-
DIF.push(ema26[i] - ema12[i]);
|
|
17
|
-
}
|
|
18
|
-
DEA = EMA(DIF, i9);
|
|
19
|
-
var MACD = [];
|
|
20
|
-
for(var i = 0; i < DEA.length; i++){
|
|
21
|
-
var val = ema26[i] - DEA[i];
|
|
22
|
-
MACD.push(val * 2);
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
DEA,
|
|
26
|
-
DIF,
|
|
27
|
-
MACD
|
|
28
|
-
};
|
|
29
|
-
}
|
package/math/stock/MACD/test.js
DELETED
package/math/stock/MFI/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Object} higharray
|
|
3
|
-
* @param {Object} lowarray
|
|
4
|
-
* @param {Object} closearray
|
|
5
|
-
* @param {Object} volarray
|
|
6
|
-
* @param {Object} period
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function MFI(higharray, lowarray, closearray, volarray, period) {
|
|
9
|
-
var harr = higharray.slice(0, period).reverse(),
|
|
10
|
-
larr = lowarray.slice(0, period).reverse(),
|
|
11
|
-
clarr = closearray.slice(0, period).reverse(),
|
|
12
|
-
vlarr = volarray.slice(0, period).reverse(),
|
|
13
|
-
lasttp = 0,
|
|
14
|
-
first = true,
|
|
15
|
-
posmf = 0,
|
|
16
|
-
negmf = 0,
|
|
17
|
-
i, tp;
|
|
18
|
-
for (i = 0; i < closearray.length; i++) {
|
|
19
|
-
if (first) {
|
|
20
|
-
lasttp = (harr[i] + larr[i] + clarr[i]) / 3;
|
|
21
|
-
first = false;
|
|
22
|
-
} else {
|
|
23
|
-
tp = (harr[i] + larr[i] + clarr[i]) / 3;
|
|
24
|
-
if (tp > lasttp) {
|
|
25
|
-
posmf += (tp * vlarr[0]);
|
|
26
|
-
} else if (tp < lasttp) {
|
|
27
|
-
negmf += (tp * vlarr[0]);
|
|
28
|
-
}
|
|
29
|
-
lasttp = tp;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return (100 - (100 / (1 + (posmf / negmf))));
|
|
33
|
-
}
|
package/math/stock/NMA/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 纯真移动平均值(历史加量平均线)
|
|
3
|
-
* @param {Array} arr_p 价格
|
|
4
|
-
* @param {Array} arr_v 数组
|
|
5
|
-
* @return {Array} 返回平均值数组
|
|
6
|
-
*/
|
|
7
|
-
module.exports = function NMA(arr_p, arr_v) {
|
|
8
|
-
if (arr_p.length !== arr_v.length) {
|
|
9
|
-
console.log("The number of array members is not equal!");
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
var arr = [arr_p[0]];
|
|
14
|
-
var vol = arr_v[0];
|
|
15
|
-
|
|
16
|
-
for (var i = 1; i < arr_p.length; i++) {
|
|
17
|
-
// 求出总值
|
|
18
|
-
var price = arr_p[i] * arr_v[i] + arr[arr.length - 1] * vol;
|
|
19
|
-
vol += arr_v[i];
|
|
20
|
-
arr.push(price / vol);
|
|
21
|
-
}
|
|
22
|
-
return arr;
|
|
23
|
-
}
|
package/math/stock/NMA/math.json
DELETED
package/math/stock/NMA/test.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const NMA = require('./index');
|
|
2
|
-
console.log(NMA([1, 2, 3], [100, 100, 200]));
|
|
3
|
-
console.log(NMA([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], [100, 210, 200, 300, 500, 600, 700, 210, 300, 210]));
|
|
4
|
-
console.log(NMA([2, 4, 6, 8, 16, 2, 4, 6, 8, 16], [100, 210, 200, 300, 500, 600, 700, 210, 300, 210]));
|
|
5
|
-
console.log(NMA([21, 37, 25, 36, 30.5, 21, 37, 25, 36, 30.5], [100, 210, 200, 300, 500, 600, 700, 210, 300, 210]));
|
package/math/stock/NOT/index.js
DELETED
package/math/stock/NOT/math.json
DELETED
package/math/stock/NOT/test.js
DELETED
package/math/stock/OPEN/index.js
DELETED
package/math/stock/OPEN/o.js
DELETED
|
File without changes
|
package/math/stock/OPEN/test.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var OPEN = require('./index');
|
|
2
|
-
|
|
3
|
-
var list = [{
|
|
4
|
-
// 股票编码
|
|
5
|
-
"gid": "sh601009",
|
|
6
|
-
// 股票名称
|
|
7
|
-
"name": "南京银行",
|
|
8
|
-
// 昨日收盘价
|
|
9
|
-
"close": 11,
|
|
10
|
-
// 今日开盘价
|
|
11
|
-
"open": 3,
|
|
12
|
-
// 今日最高价
|
|
13
|
-
"high": 0,
|
|
14
|
-
// 今日最低价
|
|
15
|
-
"low": 0,
|
|
16
|
-
// 当前价
|
|
17
|
-
"now": 0,
|
|
18
|
-
// 日期时间
|
|
19
|
-
"datetime": "",
|
|
20
|
-
// 成交量
|
|
21
|
-
"vol": 0
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// 股票编码
|
|
25
|
-
"gid": "sh601009",
|
|
26
|
-
// 股票名称
|
|
27
|
-
"name": "南京银行",
|
|
28
|
-
// 昨日收盘价
|
|
29
|
-
"close": 10,
|
|
30
|
-
// 今日开盘价
|
|
31
|
-
"open": 4,
|
|
32
|
-
// 今日最高价
|
|
33
|
-
"high": 0,
|
|
34
|
-
// 今日最低价
|
|
35
|
-
"low": 0,
|
|
36
|
-
// 当前价
|
|
37
|
-
"now": 0,
|
|
38
|
-
// 日期时间
|
|
39
|
-
"datetime": "",
|
|
40
|
-
// 成交量
|
|
41
|
-
"vol": 0
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
console.log(OPEN(list));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module.exports = function PERCPRICEOSC(array, i12, i26, i9) {
|
|
2
|
-
var ema12 = EMA(array, 12),
|
|
3
|
-
ema26 = EMA(array, 26),
|
|
4
|
-
ppo = [],
|
|
5
|
-
i, signal, histogram;
|
|
6
|
-
for (i = 0; i < ema12.length; i++) {
|
|
7
|
-
ppo.push((ema12[i] - ema26[i]) / ema26[i] * 100);
|
|
8
|
-
}
|
|
9
|
-
signal = EMA(ppo, 9);
|
|
10
|
-
histogram = [];
|
|
11
|
-
for (i = 0; i < ppo.length; i++) {
|
|
12
|
-
histogram.push(ppo[i] - signal[i]);
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
ppo: ppo,
|
|
16
|
-
signal: signal,
|
|
17
|
-
histogram: histogram
|
|
18
|
-
};
|
|
19
|
-
}
|
package/math/stock/REF/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 过去某刻值
|
|
3
|
-
* @param {Array} arr 数组
|
|
4
|
-
* @param {Number} n 前N刻
|
|
5
|
-
* @return {Array} 返回平均值数组
|
|
6
|
-
*/
|
|
7
|
-
module.exports = function REF(arr, n = 1) {
|
|
8
|
-
var len = arr.length;
|
|
9
|
-
if (len <= n) {
|
|
10
|
-
return 0;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
return arr[len - n - 1];
|
|
14
|
-
}
|
|
15
|
-
}
|
package/math/stock/REF/math.json
DELETED
package/math/stock/REF/test.js
DELETED
package/math/stock/RIGHT/test.js
DELETED
package/math/stock/RSI/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module.exports = function RSI(array, rsiperiod) {
|
|
2
|
-
var rsi = [],
|
|
3
|
-
i, j, loss, gain, diff, avggain, avgloss, first = true;
|
|
4
|
-
for (i = rsiperiod - 1; i >= 0; i--) {
|
|
5
|
-
loss = gain = 0;
|
|
6
|
-
if (first) {
|
|
7
|
-
for (j = i + rsiperiod - 1; j >= i; j--) {
|
|
8
|
-
diff = array[j + 1] - array[j];
|
|
9
|
-
if (diff > 0) {
|
|
10
|
-
loss += Math.abs(diff);
|
|
11
|
-
} else {
|
|
12
|
-
gain += Math.abs(diff);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
first = false;
|
|
16
|
-
avggain = gain / rsiperiod;
|
|
17
|
-
avgloss = loss / rsiperiod;
|
|
18
|
-
} else {
|
|
19
|
-
diff = array[i + 1] - array[i];
|
|
20
|
-
if (diff > 0) {
|
|
21
|
-
loss += Math.abs(diff);
|
|
22
|
-
} else {
|
|
23
|
-
gain += Math.abs(diff);
|
|
24
|
-
}
|
|
25
|
-
avggain = ((avggain * (rsiperiod - 1)) + gain) / rsiperiod;
|
|
26
|
-
avgloss = ((avgloss * (rsiperiod - 1)) + loss) / rsiperiod;
|
|
27
|
-
}
|
|
28
|
-
//console.log("g", avggain, "l", avgloss);
|
|
29
|
-
if (avgloss == 0) {
|
|
30
|
-
rsi[i] = 100;
|
|
31
|
-
} else {
|
|
32
|
-
rsi[i] = 100 - (100 / (1 + (avggain / avgloss)));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return rsi;
|
|
36
|
-
}
|
package/math/stock/SMA/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = function SMA(arr, smaLength) {
|
|
3
|
-
var array, sma = [],
|
|
4
|
-
i;
|
|
5
|
-
for (i = smaLength - 1; i >= 0; i--) {
|
|
6
|
-
array = arr.slice(i, i + smaLength);
|
|
7
|
-
sma[i] = array.reduce(function(a, b) {
|
|
8
|
-
return a + b;
|
|
9
|
-
}) / array.length;
|
|
10
|
-
}
|
|
11
|
-
return sma;
|
|
12
|
-
}
|
package/math/stock/STAR/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 判断是否十字星
|
|
3
|
-
* @param {Number} open 开盘价
|
|
4
|
-
* @param {Number} close 收盘价
|
|
5
|
-
* @param {Number} heig 最高价
|
|
6
|
-
* @param {Number} low 最低价
|
|
7
|
-
* @param {Number} n 幅度
|
|
8
|
-
* @return {Number} 判断正确返回1,否则返回0
|
|
9
|
-
*/
|
|
10
|
-
module.exports = function STAR(open, close, heig, low, n = 0.02) {
|
|
11
|
-
if (heig > open && heig > close) {
|
|
12
|
-
if (low < open && low < close) {
|
|
13
|
-
if (close <= open * (1 + n) && close >= open * (1 - n)) {
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return 0;
|
|
19
|
-
}
|