mm_maths 1.1.9 → 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.
Files changed (305) hide show
  1. package/README.md +156 -0
  2. package/index.js +6 -410
  3. package/lib/maths.js +429 -0
  4. package/package.json +42 -33
  5. package/tool/math/index.js +83 -0
  6. package/tool/math/tool.json +60 -0
  7. package/.gitattributes +0 -5
  8. package/convert/format_multiply/index.js +0 -40
  9. package/convert/format_multiply/test.js +0 -5
  10. package/convert/format_plus/index.js +0 -42
  11. package/convert/format_plus/test.js +0 -4
  12. package/convert/four_run/convert.json +0 -8
  13. package/convert/four_run/index.js +0 -20
  14. package/convert/four_run/test.js +0 -7
  15. package/convert/multiply_divide/index.js +0 -197
  16. package/convert/multiply_divide/test.js +0 -14
  17. package/convert/plus_subtract/index.js +0 -160
  18. package/convert/plus_subtract/test.js +0 -15
  19. package/convert/readme.md +0 -2
  20. package/doc/mm_math.doc +0 -0
  21. 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
  22. package/express/README.md +0 -2
  23. package/identities/chemistry/readme.md +0 -1
  24. package/identities/equation/readme.md +0 -2
  25. package/identities/geometry/readme.md +0 -1
  26. package/identities/geometry/rectangle/readme.md +0 -1
  27. package/identities/geometry/string/readme.md +0 -1
  28. package/identities/physics/readme.md +0 -1
  29. package/identities/readme.md +0 -2
  30. package/math/array/average/index.js +0 -10
  31. package/math/array/average/math.json +0 -8
  32. package/math/array/average/test.js +0 -3
  33. package/math/array/col/index.js +0 -17
  34. package/math/array/col/math.json +0 -8
  35. package/math/array/col/test.js +0 -4
  36. package/math/array/composite/index.js +0 -35
  37. package/math/array/composite/math.json +0 -8
  38. package/math/array/composite/test.js +0 -4
  39. package/math/array/deviations/index.js +0 -15
  40. package/math/array/deviations/math.json +0 -8
  41. package/math/array/deviations/test.js +0 -3
  42. package/math/array/difference/index.js +0 -9
  43. package/math/array/difference/math.json +0 -8
  44. package/math/array/difference/test.js +0 -7
  45. package/math/array/distinct/index.js +0 -20
  46. package/math/array/distinct/math.json +0 -8
  47. package/math/array/distinct/test.js +0 -8
  48. package/math/array/distributive/index.js +0 -24
  49. package/math/array/distributive/math.json +0 -8
  50. package/math/array/distributive/test.js +0 -3
  51. package/math/array/divisor/index.js +0 -17
  52. package/math/array/divisor/math.json +0 -8
  53. package/math/array/divisor/test.js +0 -6
  54. package/math/array/intersect/index.js +0 -9
  55. package/math/array/intersect/math.json +0 -8
  56. package/math/array/intersect/test.js +0 -7
  57. package/math/array/max/index.js +0 -17
  58. package/math/array/max/math.json +0 -8
  59. package/math/array/max/test.js +0 -8
  60. package/math/array/median/index.js +0 -34
  61. package/math/array/median/math.json +0 -8
  62. package/math/array/median/test.js +0 -4
  63. package/math/array/min/index.js +0 -16
  64. package/math/array/min/math.json +0 -8
  65. package/math/array/min/test.js +0 -8
  66. package/math/array/multiple/index.js +0 -17
  67. package/math/array/multiple/math.json +0 -8
  68. package/math/array/multiple/test.js +0 -7
  69. package/math/array/natural/index.js +0 -17
  70. package/math/array/natural/math.json +0 -8
  71. package/math/array/natural/test.js +0 -9
  72. package/math/array/pos/index.js +0 -21
  73. package/math/array/pos/math.json +0 -8
  74. package/math/array/pos/test.js +0 -41
  75. package/math/array/prime/index.js +0 -35
  76. package/math/array/prime/math.json +0 -8
  77. package/math/array/prime/test.js +0 -4
  78. package/math/array/readme.md +0 -5
  79. package/math/array/reduction/index.js +0 -57
  80. package/math/array/reduction/math.json +0 -8
  81. package/math/array/reduction/test.js +0 -42
  82. package/math/array/rising/index.js +0 -8
  83. package/math/array/rising/math.json +0 -8
  84. package/math/array/rising/test.js +0 -3
  85. package/math/array/row/index.js +0 -11
  86. package/math/array/row/math.json +0 -8
  87. package/math/array/row/test.js +0 -4
  88. package/math/array/square/index.js +0 -12
  89. package/math/array/square/math.json +0 -8
  90. package/math/array/square/test.js +0 -3
  91. package/math/array/stddev/index.js +0 -17
  92. package/math/array/stddev/math.json +0 -8
  93. package/math/array/stddev/test.js +0 -4
  94. package/math/array/sum/index.js +0 -13
  95. package/math/array/sum/math.json +0 -8
  96. package/math/array/sum/test.js +0 -3
  97. package/math/array/sumproduct/index.js +0 -13
  98. package/math/array/sumproduct/math.json +0 -8
  99. package/math/array/sumproduct/test.js +0 -3
  100. package/math/array/union/index.js +0 -11
  101. package/math/array/union/math.json +0 -8
  102. package/math/array/union/test.js +0 -7
  103. package/math/base/abs/index.js +0 -8
  104. package/math/base/abs/math.json +0 -8
  105. package/math/base/abs/test.js +0 -3
  106. package/math/base/ceil/index.js +0 -8
  107. package/math/base/ceil/math.json +0 -8
  108. package/math/base/ceil/test.js +0 -3
  109. package/math/base/denominator/index.js +0 -17
  110. package/math/base/denominator/math.json +0 -9
  111. package/math/base/denominator/test.js +0 -3
  112. package/math/base/diff/index.js +0 -9
  113. package/math/base/diff/math.json +0 -8
  114. package/math/base/diff/test.js +0 -6
  115. package/math/base/exp/index.js +0 -8
  116. package/math/base/exp/math.json +0 -8
  117. package/math/base/exp/test.js +0 -6
  118. package/math/base/floor/index.js +0 -8
  119. package/math/base/floor/math.json +0 -8
  120. package/math/base/floor/test.js +0 -3
  121. package/math/base/int/index.js +0 -8
  122. package/math/base/int/math.json +0 -8
  123. package/math/base/int/test.js +0 -2
  124. package/math/base/log/index.js +0 -8
  125. package/math/base/log/math.json +0 -8
  126. package/math/base/log/test.js +0 -4
  127. package/math/base/max_divisor/index.js +0 -10
  128. package/math/base/max_divisor/math.json +0 -9
  129. package/math/base/max_divisor/test.js +0 -3
  130. package/math/base/min_multiple/index.js +0 -11
  131. package/math/base/min_multiple/math.json +0 -9
  132. package/math/base/min_multiple/test.js +0 -3
  133. package/math/base/mod/index.js +0 -8
  134. package/math/base/mod/math.json +0 -8
  135. package/math/base/mod/test.js +0 -3
  136. package/math/base/pow/index.js +0 -9
  137. package/math/base/pow/math.json +0 -8
  138. package/math/base/pow/test.js +0 -3
  139. package/math/base/rand/index.js +0 -21
  140. package/math/base/rand/math.json +0 -8
  141. package/math/base/rand/test.js +0 -3
  142. package/math/base/random/index.js +0 -12
  143. package/math/base/random/math.json +0 -8
  144. package/math/base/random/test.js +0 -4
  145. package/math/base/readme.md +0 -1
  146. package/math/base/round/index.js +0 -14
  147. package/math/base/round/math.json +0 -8
  148. package/math/base/round/test.js +0 -4
  149. package/math/base/sqrt/index.js +0 -8
  150. package/math/base/sqrt/math.json +0 -8
  151. package/math/base/sqrt/test.js +0 -5
  152. package/math/readme.md +0 -1
  153. package/math/stock/AMOUNT/index.js +0 -7
  154. package/math/stock/AMOUNT/math.json +0 -8
  155. package/math/stock/AMOUNT/test.js +0 -4
  156. package/math/stock/AP/index.js +0 -20
  157. package/math/stock/AP/math.json +0 -8
  158. package/math/stock/AP/test.js +0 -5
  159. package/math/stock/AROON/index.js +0 -14
  160. package/math/stock/ARR/index.js +0 -10
  161. package/math/stock/ARR/math.json +0 -8
  162. package/math/stock/ARR/test.js +0 -45
  163. package/math/stock/ASTAR/index.js +0 -20
  164. package/math/stock/ASTAR/math.json +0 -8
  165. package/math/stock/ASTAR/test.js +0 -4
  166. package/math/stock/AVERAGE/index.js +0 -14
  167. package/math/stock/AVERAGE/math.json +0 -8
  168. package/math/stock/AVERAGE/test.js +0 -5
  169. package/math/stock/AYANG/index.js +0 -18
  170. package/math/stock/AYANG/math.json +0 -8
  171. package/math/stock/AYANG/test.js +0 -4
  172. package/math/stock/AYIN/index.js +0 -18
  173. package/math/stock/AYIN/math.json +0 -8
  174. package/math/stock/AYIN/test.js +0 -4
  175. package/math/stock/BBANDS/index.js +0 -0
  176. package/math/stock/BETWEEN/index.js +0 -24
  177. package/math/stock/BETWEEN/math.json +0 -8
  178. package/math/stock/BETWEEN/test.js +0 -4
  179. package/math/stock/CLOSE/c.js +0 -0
  180. package/math/stock/CLOSE/index.js +0 -11
  181. package/math/stock/CLOSE/math.json +0 -8
  182. package/math/stock/CLOSE/test.js +0 -45
  183. package/math/stock/CP/index.js +0 -35
  184. package/math/stock/CP/math.json +0 -8
  185. package/math/stock/CP/test.js +0 -5
  186. package/math/stock/CROSS/index.js +0 -29
  187. package/math/stock/CROSS/math.json +0 -8
  188. package/math/stock/CROSS/test.js +0 -6
  189. package/math/stock/DATE/index.js +0 -14
  190. package/math/stock/DATE/math.json +0 -8
  191. package/math/stock/DATE/test.js +0 -45
  192. package/math/stock/DOWN/index.js +0 -19
  193. package/math/stock/DOWN/math.json +0 -8
  194. package/math/stock/DOWN/test.js +0 -8
  195. package/math/stock/DOWNNDAY/index.js +0 -27
  196. package/math/stock/DOWNNDAY/math.json +0 -8
  197. package/math/stock/DOWNNDAY/test.js +0 -10
  198. package/math/stock/EMA/index.js +0 -30
  199. package/math/stock/EMA/math.json +0 -8
  200. package/math/stock/EMA/test.js +0 -4
  201. package/math/stock/HHV/index.js +0 -16
  202. package/math/stock/HHV/math.json +0 -8
  203. package/math/stock/HHV/test.js +0 -4
  204. package/math/stock/HIGH/h.js +0 -0
  205. package/math/stock/HIGH/index.js +0 -11
  206. package/math/stock/HIGH/math.json +0 -8
  207. package/math/stock/HIGH/test.js +0 -45
  208. package/math/stock/LEFT/index.js +0 -13
  209. package/math/stock/LEFT/math.json +0 -8
  210. package/math/stock/LEFT/test.js +0 -4
  211. package/math/stock/LLV/index.js +0 -16
  212. package/math/stock/LLV/math.json +0 -8
  213. package/math/stock/LLV/test.js +0 -4
  214. package/math/stock/LOW/index.js +0 -11
  215. package/math/stock/LOW/l.js +0 -0
  216. package/math/stock/LOW/math.json +0 -8
  217. package/math/stock/LOW/test.js +0 -47
  218. package/math/stock/MA/index.js +0 -30
  219. package/math/stock/MA/math.json +0 -8
  220. package/math/stock/MA/test.js +0 -5
  221. package/math/stock/MACD/index.js +0 -29
  222. package/math/stock/MACD/math.json +0 -8
  223. package/math/stock/MACD/test.js +0 -4
  224. package/math/stock/MFI/index.js +0 -33
  225. package/math/stock/NMA/index.js +0 -23
  226. package/math/stock/NMA/math.json +0 -8
  227. package/math/stock/NMA/test.js +0 -5
  228. package/math/stock/NOT/index.js +0 -7
  229. package/math/stock/NOT/math.json +0 -8
  230. package/math/stock/NOT/test.js +0 -10
  231. package/math/stock/OPEN/index.js +0 -11
  232. package/math/stock/OPEN/math.json +0 -8
  233. package/math/stock/OPEN/o.js +0 -0
  234. package/math/stock/OPEN/test.js +0 -45
  235. package/math/stock/PERCPRICEOSC/index.js +0 -19
  236. package/math/stock/REF/index.js +0 -15
  237. package/math/stock/REF/math.json +0 -8
  238. package/math/stock/REF/test.js +0 -5
  239. package/math/stock/RIGHT/index.js +0 -13
  240. package/math/stock/RIGHT/math.json +0 -8
  241. package/math/stock/RIGHT/test.js +0 -4
  242. package/math/stock/RSI/index.js +0 -36
  243. package/math/stock/SMA/index.js +0 -12
  244. package/math/stock/STAR/index.js +0 -19
  245. package/math/stock/STAR/math.json +0 -8
  246. package/math/stock/STAR/test.js +0 -4
  247. package/math/stock/STOCHRSI/index.js +0 -19
  248. package/math/stock/SUM/index.js +0 -19
  249. package/math/stock/SUM/math.json +0 -8
  250. package/math/stock/SUM/test.js +0 -7
  251. package/math/stock/TIME/index.js +0 -14
  252. package/math/stock/TIME/math.json +0 -8
  253. package/math/stock/TIME/test.js +0 -45
  254. package/math/stock/TRUERANGE/index.js +0 -19
  255. package/math/stock/UP/index.js +0 -19
  256. package/math/stock/UP/math.json +0 -8
  257. package/math/stock/UP/test.js +0 -9
  258. package/math/stock/UPNDAY/index.js +0 -28
  259. package/math/stock/UPNDAY/math.json +0 -8
  260. package/math/stock/UPNDAY/test.js +0 -10
  261. package/math/stock/VMA/index.js +0 -41
  262. package/math/stock/VMA/math.json +0 -8
  263. package/math/stock/VMA/test.js +0 -7
  264. package/math/stock/VOL/index.js +0 -11
  265. package/math/stock/VOL/math.json +0 -8
  266. package/math/stock/VOL/test.js +0 -45
  267. package/math/stock/WILLR/index.js +0 -22
  268. package/math/stock/YANG/index.js +0 -16
  269. package/math/stock/YANG/math.json +0 -8
  270. package/math/stock/YANG/test.js +0 -4
  271. package/math/stock/YIN/index.js +0 -16
  272. package/math/stock/YIN/math.json +0 -8
  273. package/math/stock/YIN/test.js +0 -4
  274. package/math/stock/readme.md +0 -294
  275. package/math/trigonometric/cos/index.js +0 -8
  276. package/math/trigonometric/cos/math.json +0 -20
  277. package/math/trigonometric/cot/index.js +0 -8
  278. package/math/trigonometric/cot/math.json +0 -17
  279. package/math/trigonometric/csc/index.js +0 -8
  280. package/math/trigonometric/csc/math.json +0 -20
  281. package/math/trigonometric/readme.md +0 -2
  282. package/math/trigonometric/sec/index.js +0 -8
  283. package/math/trigonometric/sec/math.json +0 -20
  284. package/math/trigonometric/sin/index.js +0 -8
  285. package/math/trigonometric/sin/math.json +0 -20
  286. package/math/trigonometric/tan/index.js +0 -8
  287. package/math/trigonometric/tan/math.json +0 -18
  288. package/symbol/brackets/index.js +0 -46
  289. package/symbol/brackets/symbol.json +0 -8
  290. package/symbol/brackets/test.js +0 -12
  291. package/symbol/decimal/index.js +0 -41
  292. package/symbol/decimal/symbol.json +0 -8
  293. package/symbol/decimal/test.js +0 -2
  294. package/symbol/percentage/index.js +0 -48
  295. package/symbol/percentage/symbol.json +0 -8
  296. package/symbol/percentage/test.js +0 -2
  297. package/symbol/pi/index.js +0 -20
  298. package/symbol/pi/symbol.json +0 -9
  299. package/symbol/pi/test.js +0 -2
  300. package/symbol/power/index.js +0 -111
  301. package/symbol/power/symbol.json +0 -8
  302. package/symbol/power/test.js +0 -10
  303. package/symbol/readme.md +0 -2
  304. package/test.js +0 -32
  305. package/test2.js +0 -47
@@ -1,8 +0,0 @@
1
- {
2
- "key": "AP",
3
- "name": "approximation",
4
- "title": "是否相近值",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,5 +0,0 @@
1
- const AP = require('./index');
2
- console.log(AP([3.1, 3.3], 0.05));
3
- console.log(AP([3, 4], 0.1));
4
- console.log(AP([1.33, 1.45], 0.05));
5
- console.log(AP([1.48, 2.21], 0.1));
@@ -1,14 +0,0 @@
1
- const min = require('../array/min');
2
-
3
- module.exports = function AROON(higharray, lowarray, period) {
4
- var harr = higharray.slice(0, period),
5
- larr = lowarray.slice(0, period),
6
- hh = min(harr),
7
- hday = harr.indexOf(hh),
8
- ll = min(larr),
9
- lday = larr.indexOf(ll);
10
- return {
11
- up: ((period - hday) / period) * 100,
12
- down: ((period - lday) / period) * 100
13
- };
14
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * 推前N个成员
3
- * @param {Array} arr 数组
4
- * @param {Number} n 推前成员数
5
- * @return {Array} 返回数组
6
- */
7
- module.exports = function ARR(arr, n = 0) {
8
- var ar = arr.slice(0, arr.length - n - 1);
9
- return ar;
10
- }
@@ -1,8 +0,0 @@
1
- {
2
- "key": "ARR",
3
- "name": "ahead array",
4
- "title": "推前N个成员",
5
- "group": "array",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,45 +0,0 @@
1
- var ARR = require('./index');
2
-
3
- var list = [{
4
- // 股票编码
5
- "gid": "sh601009",
6
- // 股票名称
7
- "name": "南京银行",
8
- // 昨日收盘价
9
- "close": 11,
10
- // 今日开盘价
11
- "open": 0,
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": 0,
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(ARR(list, 1));
@@ -1,20 +0,0 @@
1
- const REF = require('../REF');
2
- const STAR = require('../STAR');
3
-
4
- /**
5
- * 判断是否十字星
6
- * @param {Array} arr_open 开盘价数组
7
- * @param {Array} arr_close 收盘价数组
8
- * @param {Array} arr_heig 最高价数组
9
- * @param {Array} arr_low 最低价数组
10
- * @param {Number} idx 索引
11
- * @param {Number} n 幅度
12
- * @return {Number} 判断正确返回1,否则返回0
13
- */
14
- module.exports = function ASTAR(arr_open, arr_close, arr_heig, arr_low, idx, n) {
15
- var open = REF(arr_open, idx);
16
- var close = REF(arr_close, idx);
17
- var heig = REF(arr_heig, idx);
18
- var low = REF(arr_low, idx);
19
- return STAR(open, close, heig, low, n);
20
- }
@@ -1,8 +0,0 @@
1
- {
2
- "key": "ASTAR",
3
- "name": "Array is STAR line",
4
- "title": "十字星线",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const STAR = require('./index');
2
- console.log(STAR([1, 1], [1.01, 1.01], [1.06, 1.06], [0.9], 1));
3
- console.log(STAR([1, 1], [1.03,1.03], [1.04,1.04], [0.92,0.92], 1, 0.01));
4
- console.log(STAR([1, 1], [1.02,1.02], [0.02,0.02], [1.02,1.02], 1));
@@ -1,14 +0,0 @@
1
-
2
- /**
3
- * 求平均值
4
- * @param {Array} arr 数组
5
- * @return {Number} 返回平均值
6
- */
7
- module.exports = function AVERAGE(arr) {
8
- var num = 0;
9
- var len = arr.length;
10
- for (var i = 0; i < len; i++) {
11
- num += arr[i];
12
- }
13
- return num / arr.length;
14
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "AVERAGE",
3
- "name": "average",
4
- "title": "平均值",
5
- "group": "number",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,5 +0,0 @@
1
- const CP = require('./index');
2
- console.log(CP([3, 4], "<", [3,5]));
3
- console.log(CP([3, 4], ">", [3,5]));
4
- console.log(CP([1, 5], "=", [2,5]));
5
- console.log(CP([1, 5.21], "~=", [2,5.3]));
@@ -1,18 +0,0 @@
1
- const YANG = require('../YANG');
2
- const REF = require('../REF');
3
-
4
- /**
5
- * 判断是否阳线
6
- * @param {Array} arr_open 开盘价数组
7
- * @param {Array} arr_close 收盘价数组
8
- * @param {Array} arr_chg 涨跌幅数组
9
- * @param {Number} idx 索引
10
- * @param {Number} n 幅度, 如果大阳线则设0.05
11
- * @return {Number} 判断正确返回1, 否则返回0
12
- */
13
- module.exports = function AYANG(arr_open, arr_close, arr_chg, idx, n = 0.02) {
14
- var open = REF(arr_open, idx);
15
- var close = REF(arr_close, idx);
16
- var chg = REF(arr_chg, idx);
17
- return YANG(open, close, chg, n);
18
- }
@@ -1,8 +0,0 @@
1
- {
2
- "key": "AYANG",
3
- "name": "Array Get YANG line",
4
- "title": "某日是否阳线",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const AYANG = require('./index');
2
- console.log(AYANG([1], [1.1], [0.1], 0, 0.02));
3
- console.log(AYANG([1], [1.01], [0.97], 0, 0.02));
4
- console.log(AYANG([1], [1.02], [0.02], 0, 0.02));
@@ -1,18 +0,0 @@
1
- const YIN = require('../YIN');
2
- const REF = require('../REF');
3
-
4
- /**
5
- * 判断是否阴线
6
- * @param {Array} arr_open 开盘价数组
7
- * @param {Array} arr_close 收盘价数组
8
- * @param {Array} arr_chg 涨跌幅数组
9
- * @param {Number} idx 索引
10
- * @param {Number} n 幅度, 如果大阳线则设0.05
11
- * @return {Number} 判断正确返回1, 否则返回0
12
- */
13
- module.exports = function AYIN(arr_open, arr_close, arr_chg, idx, n) {
14
- var open = REF(arr_open, idx);
15
- var close = REF(arr_close, idx);
16
- var chg = REF(arr_chg, idx);
17
- return YIN(open, close, chg, n);
18
- }
@@ -1,8 +0,0 @@
1
- {
2
- "key": "AYIN",
3
- "name": "Array Get YIN line",
4
- "title": "某日是否阴线",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const YIN = require('./index');
2
- console.log(YIN([1], [1.1], [0.1], 0, 0.02));
3
- console.log(YIN([1], [1.01], [-0.97], 0, 0.05));
4
- console.log(YIN([1], [0.95], [-0.02], 0, 0.05));
File without changes
@@ -1,24 +0,0 @@
1
- /**
2
- * 取数组左边成员
3
- * @param {Array} arr 数组
4
- * @param {Number} l 取成员起始
5
- * @param {Number} r 取成员个数
6
- * @return {Array} 返回数组
7
- */
8
- module.exports = function BETWEEN(arr, l, r) {
9
- if (l > r) {
10
- return [];
11
- }
12
-
13
- if (l < 1) {
14
- l > 1;
15
- } else if (l > arr.length) {
16
- l = arr.length;
17
- }
18
-
19
- if (r > arr.length) {
20
- r = arr.length;
21
- }
22
-
23
- return arr.slice(l, r);
24
- }
@@ -1,8 +0,0 @@
1
- {
2
- "key": "BETWEEN",
3
- "name": "array between",
4
- "title": "取数日之内 ",
5
- "group": "array",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const BETWEEN = require('./index');
2
- console.log(BETWEEN([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], 3, 3));
3
- console.log(BETWEEN([2, 4, 6, 8, 16, 2, 4, 6, 8, 16], 4, 3));
4
- console.log(BETWEEN([21, 37, 25, 36, 30.5, 21, 37, 25, 36, 30.5], 10, 3));
File without changes
@@ -1,11 +0,0 @@
1
- /**
2
- * 取收盘价
3
- * @param {Array} list 对象列表
4
- * @param {String} key 字段
5
- * @return {Array} 返回数值数组
6
- */
7
- module.exports = function CLOSE(list, key = "close") {
8
- return list.map(function(o) {
9
- return o[key];
10
- });
11
- }
@@ -1,8 +0,0 @@
1
- {
2
- "key": "CLOSE",
3
- "name": "close price",
4
- "title": "取收盘价",
5
- "group": "array",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,45 +0,0 @@
1
- var CLOSE = require('./index');
2
-
3
- var list = [{
4
- // 股票编码
5
- "gid": "sh601009",
6
- // 股票名称
7
- "name": "南京银行",
8
- // 昨日收盘价
9
- "close": 11,
10
- // 今日开盘价
11
- "open": 0,
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": 0,
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(CLOSE(list));
@@ -1,35 +0,0 @@
1
- /**
2
- * 比较大小
3
- * @param {Array} arr1 数组1
4
- * @param {String} symbol 比较符号 >大于 <小于 =等于 <=大于等于, >=小于等于
5
- * @param {Array} arr2 数组2
6
- * @param {Number} idx 倒数第N个进行比较
7
- * @return {Number} 返回整数 比较正确返回1, 否则返回0
8
- */
9
- module.exports = function CP(arr1, symbol, arr2, idx = 1) {
10
- var v1 = arr1[arr1.length - idx];
11
- var v2 = arr2[arr2.length - idx];
12
- var bl = false;
13
- switch (symbol) {
14
- case ">":
15
- bl = v1 > v2;
16
- break;
17
- case "<":
18
- bl = v1 < v2;
19
- break;
20
- case ">=":
21
- bl = v1 >= v2;
22
- break;
23
- case "<=":
24
- bl = v1 <= v2;
25
- break;
26
- case "=":
27
- case "==":
28
- bl = v1 == v2;
29
- break;
30
- case "~=":
31
- bl = (v1 == v2) || (Math.round(v1 * 10) == Math.round(v2 * 10));
32
- break;
33
- }
34
- return bl ? 1 : 0;
35
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "CP",
3
- "name": "compare sizes",
4
- "title": "比较大小",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,5 +0,0 @@
1
- const CP = require('./index');
2
- console.log(CP([3, 4], "<", [3,5]));
3
- console.log(CP([3, 4], ">", [3,5]));
4
- console.log(CP([1, 5], "=", [2,5]));
5
- console.log(CP([1, 5.21], "~=", [2,5.3]));
@@ -1,29 +0,0 @@
1
- /**
2
- * 交叉
3
- * @param {Array} arr1
4
- * @param {Array} arr2
5
- * @return {Number} 上穿返回1, 否则返回0
6
- */
7
- module.exports = function CROSS(arr1, arr2) {
8
- if (arr1.length < 3 || arr2.length < 3) {
9
- return 0;
10
- }
11
-
12
- var ret = 0;
13
-
14
- for (var i = arr1.length - 1; i > 2; i--) {
15
- var x3 = arr1[i];
16
- var x2 = arr1[i - 1];
17
- var x1 = arr1[i - 2];
18
-
19
- var y3 = arr2[i];
20
- var y1 = arr2[i - 2];
21
- if(x3 > x2 && x2 > x1 && x3 > y3 && x1 < y1){
22
- return 1;
23
- }
24
- else if(x3 < x2 && x2 < x1 && x3 < y3 && x1 > y1){
25
- return -1;
26
- }
27
- }
28
- return ret;
29
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "CROSS",
3
- "name": "cross",
4
- "title": "(黄金/死亡)交叉",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,6 +0,0 @@
1
- const CROSS = require('./index');
2
- // './stock_test'.fullname(__dirname);
3
- var arr1 = [1,2,3,4];
4
- var arr2 = [4,3,2,1];
5
-
6
- console.log(CROSS(arr1, arr2));
@@ -1,14 +0,0 @@
1
- require('mm_expand')
2
-
3
- /**
4
- * 取日期
5
- * @param {Array} list 对象列表
6
- * @param {String} key 字段
7
- * @return {Array} 返回数值数组
8
- */
9
- module.exports = function DATE(list, key = "datetime") {
10
- return list.map(function(o) {
11
- return o[key].toTime().toStr('yyyy-MM-dd');
12
- });
13
- };
14
-
@@ -1,8 +0,0 @@
1
- {
2
- "key": "DATE",
3
- "name": "date",
4
- "title": "取日期",
5
- "group": "array",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,45 +0,0 @@
1
- var DATE = 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": "2019-11-15 11:34:35",
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": "2019-10-15 21:34:05",
40
- // 成交量
41
- "vol": 0
42
- }
43
- ]
44
-
45
- console.log(DATE(list));
@@ -1,19 +0,0 @@
1
- /**
2
- * 下降趋势
3
- * @param {Object} arr 数值组
4
- * @param {Numbeer} extent 幅度
5
- * @return {Number} 下降返回1, 否则返回0
6
- */
7
- module.exports = function DOWN(arr, extent = 0) {
8
- var num = 1 - extent;
9
- var len = arr.length;
10
- if (len > 2) {
11
- var v1 = arr[len - 3];
12
- var v2 = arr[len - 2];
13
- var v3 = arr[len - 1];
14
- if (v3 <= v2 * num && v2 <= v1 * num) {
15
- return 1
16
- }
17
- }
18
- return 0;
19
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "DOWN",
3
- "name": "DOWN",
4
- "title": "下降趋势",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,8 +0,0 @@
1
- var DOWN = require('./index');
2
-
3
- var A1 = [1, 2, 3, 4, 5];
4
- var A2 = [5, 4, 3, 2, 1];
5
- var A21 = [1, 0.98, 0.96, 0.94, 0.92];
6
- console.log(DOWN(A1));
7
- console.log(DOWN(A2));
8
- console.log(DOWN(A21, 0.02));
@@ -1,27 +0,0 @@
1
- /**
2
- * 连跌N日
3
- * @param {Array} arr 跌幅数组
4
- * @param {Number} period 周期(单位:天)
5
- * @return {Number} 连涨返回1, 否则返回0
6
- */
7
- module.exports = function DOWNNDAY(arr, period = 3, n = 0.02) {
8
- if (arr.length > period) {
9
- var day = 0;
10
- var num = 1 - n;
11
- for (var i = arr.length - 1; i > 0; i--) {
12
- var bl = arr[i] < arr[i - 1] * num;
13
- if (bl) {
14
- day++;
15
- if (day == period) {
16
- break;
17
- }
18
- } else {
19
- break;
20
- }
21
- }
22
- if (day >= period) {
23
- return 1
24
- }
25
- }
26
- return 0;
27
- };
@@ -1,8 +0,0 @@
1
- {
2
- "key": "DOWNNDAY",
3
- "name": "DOWNNDAY",
4
- "title": "连跌N日",
5
- "group": "if",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,10 +0,0 @@
1
- var UPNDAY = require('./index');
2
-
3
- var A1 = [1,2,3,4,5];
4
- var A2 = [5,4,3,2,1];
5
- var A3 = [4,2,3,4,5];
6
-
7
- console.log(UPNDAY(A1, 3));
8
- console.log(UPNDAY(A2, 3));
9
- console.log(UPNDAY(A3, 4));
10
- console.log(UPNDAY(A1, 4));
@@ -1,30 +0,0 @@
1
- /**
2
- * 指数移动平均值
3
- * @param {ar} arr 数组
4
- * @param {Number} period 周期
5
- * @return {ar} 返回平均值数组
6
- */
7
- module.exports = function EMA(arr, period = 5) {
8
- var ar = arr.slice().reverse(),
9
- iPos = 0,
10
- i, k, ema;
11
- for (iPos = 0; iPos < ar.length && isNaN(ar[iPos]); iPos++) {}
12
- ar = ar.slice(iPos);
13
- ema = [];
14
- k = 2 / (period + 1);
15
- for (i = 0; i < period - 1; i++) {
16
- ema[i] = NaN;
17
- }
18
- ema[period - 1] = ar.slice(0, period).reduce(function(a, b) {
19
- return a + b;
20
- }) / period;
21
- for (i = period; i < ar.length; i++) {
22
- ema[i] = ar[i] * k + ema[i - 1] * (1 - k);
23
- }
24
- for (i = 0; i < iPos; i++) {
25
- ema.push(NaN);
26
- }
27
- return ema;
28
- }
29
-
30
- // EMA(X,2)=[2*X2+(2-1)*Y’]/(2+1)=(2/3)*X2+(1/3)X1
@@ -1,8 +0,0 @@
1
- {
2
- "key": "EMA",
3
- "name": "Exponential Moving Average",
4
- "title": "指数移动平均值",
5
- "group": "array",
6
- "type": "stock",
7
- "func_file": "./index.js"
8
- }
@@ -1,4 +0,0 @@
1
- const EMA = require('./index');
2
- console.log(EMA([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], 2));
3
- console.log(EMA([2, 4, 6, 8, 16, 2, 4, 6, 8, 16], 3));
4
- console.log(EMA([21, 37, 25, 36, 30.5, 21, 37, 25, 36, 30.5], 5));