@ch20026103/anysis 0.0.18 → 0.0.19-alpha
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/demo/main.js +5 -5
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/stockSkills/ad.d.ts +17 -0
- package/dist/cjs/stockSkills/ad.js +57 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/stockSkills/ad.d.ts +17 -0
- package/dist/esm/stockSkills/ad.js +55 -0
- package/dist/umd/index.js +58 -2
- package/package.json +1 -1
package/demo/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint @typescript-eslint/no-var-requires: "off" */
|
|
2
2
|
const axios = require("axios");
|
|
3
|
-
const {
|
|
3
|
+
const { Ad } = require("../dist/cjs/index.js");
|
|
4
4
|
|
|
5
5
|
// 使用示例
|
|
6
|
-
const
|
|
6
|
+
const ad = new Ad();
|
|
7
7
|
function DemoDay(stockId) {
|
|
8
8
|
axios
|
|
9
9
|
.get(
|
|
@@ -45,11 +45,11 @@ function DemoDay(stockId) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
let
|
|
48
|
+
let adData = ad.init(response[0], 14);
|
|
49
49
|
for (let i = 1; i < response.length; i++) {
|
|
50
|
-
|
|
50
|
+
adData = ad.next(response[i], adData, 14);
|
|
51
51
|
}
|
|
52
|
-
console.log(
|
|
52
|
+
console.log(adData);
|
|
53
53
|
})
|
|
54
54
|
.catch((error) => {
|
|
55
55
|
console.error(error);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { default as Vma } from "./stockSkills/vma.js";
|
|
|
20
20
|
export { default as Williams } from "./stockSkills/williams.js";
|
|
21
21
|
export { default as ObvEma } from "./stockSkills/obv_ema.js";
|
|
22
22
|
export { default as Mfi } from "./stockSkills/mfi.js";
|
|
23
|
+
export { default as Ad } from "./stockSkills/ad.js";
|
|
23
24
|
export { add } from "./test/add.js";
|
|
24
25
|
export { minus } from "./test/minus.js";
|
|
25
26
|
export { default as calculateDivisionFactor } from "./utils/calculateDivisionFactor.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseLsusbOutput = exports.isJSON = exports.calculateDivisionFactor = exports.minus = exports.add = exports.Mfi = exports.ObvEma = exports.Williams = exports.Vma = exports.Week = exports.dateFormat = exports.Rsi = exports.Obv = exports.Macd = exports.Ma = exports.Kd = exports.Gold = exports.Ema = exports.Boll = exports.calcSeasonalIndicesNoTrend = exports.weightMovingAverages = exports.movingAverages = exports.exponentialSmoothing = exports.findTroughByGradient = exports.findPeaksByGradient = exports.SwingExtremesType = exports.SwingExtremes = exports.slope = exports.simpleRegressionModel = exports.Angle = void 0;
|
|
3
|
+
exports.parseLsusbOutput = exports.isJSON = exports.calculateDivisionFactor = exports.minus = exports.add = exports.Ad = exports.Mfi = exports.ObvEma = exports.Williams = exports.Vma = exports.Week = exports.dateFormat = exports.Rsi = exports.Obv = exports.Macd = exports.Ma = exports.Kd = exports.Gold = exports.Ema = exports.Boll = exports.calcSeasonalIndicesNoTrend = exports.weightMovingAverages = exports.movingAverages = exports.exponentialSmoothing = exports.findTroughByGradient = exports.findPeaksByGradient = exports.SwingExtremesType = exports.SwingExtremes = exports.slope = exports.simpleRegressionModel = exports.Angle = void 0;
|
|
4
4
|
/*
|
|
5
5
|
請注意,在 src/index.ts 中,我的導入包含文件擴展名(.js)。
|
|
6
6
|
如果需要支持 Node.js 和構建工具(ex: webpack),則不需要這樣做。 **因為commonJs默認js副檔名**
|
|
@@ -51,6 +51,8 @@ var obv_ema_js_1 = require("./stockSkills/obv_ema.js");
|
|
|
51
51
|
Object.defineProperty(exports, "ObvEma", { enumerable: true, get: function () { return obv_ema_js_1.default; } });
|
|
52
52
|
var mfi_js_1 = require("./stockSkills/mfi.js");
|
|
53
53
|
Object.defineProperty(exports, "Mfi", { enumerable: true, get: function () { return mfi_js_1.default; } });
|
|
54
|
+
var ad_js_1 = require("./stockSkills/ad.js");
|
|
55
|
+
Object.defineProperty(exports, "Ad", { enumerable: true, get: function () { return ad_js_1.default; } });
|
|
54
56
|
var add_js_1 = require("./test/add.js");
|
|
55
57
|
Object.defineProperty(exports, "add", { enumerable: true, get: function () { return add_js_1.add; } });
|
|
56
58
|
var minus_js_1 = require("./test/minus.js");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StockListType, StockType } from "./types";
|
|
2
|
+
type NewStockType = Required<Pick<StockType, "v">> & StockType;
|
|
3
|
+
export type AdResType = {
|
|
4
|
+
dataset: StockListType;
|
|
5
|
+
ad: number;
|
|
6
|
+
preClose: number;
|
|
7
|
+
};
|
|
8
|
+
interface AdType {
|
|
9
|
+
init: (data: NewStockType) => AdResType;
|
|
10
|
+
next: (data: NewStockType, preList: AdResType) => AdResType;
|
|
11
|
+
}
|
|
12
|
+
export default class Ad implements AdType {
|
|
13
|
+
init(data: NewStockType): AdResType;
|
|
14
|
+
next(data: NewStockType, preList: AdResType): AdResType;
|
|
15
|
+
private calcAD;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
var Ad = /** @class */ (function () {
|
|
13
|
+
function Ad() {
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(Ad.prototype, "init", {
|
|
16
|
+
enumerable: false,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: function (data) {
|
|
20
|
+
// AD 初始值
|
|
21
|
+
var ad = this.calcAD(data);
|
|
22
|
+
return {
|
|
23
|
+
dataset: [data],
|
|
24
|
+
ad: ad,
|
|
25
|
+
preClose: data.c,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(Ad.prototype, "next", {
|
|
30
|
+
enumerable: false,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: function (data, preList) {
|
|
34
|
+
// AD 累加
|
|
35
|
+
var ad = preList.ad + this.calcAD(data);
|
|
36
|
+
return {
|
|
37
|
+
dataset: __spreadArray(__spreadArray([], preList.dataset, true), [data], false),
|
|
38
|
+
ad: ad,
|
|
39
|
+
preClose: data.c,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
// AD 計算公式
|
|
44
|
+
Object.defineProperty(Ad.prototype, "calcAD", {
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: function (data) {
|
|
49
|
+
var h = data.h, l = data.l, c = data.c, v = data.v;
|
|
50
|
+
if (h === l)
|
|
51
|
+
return 0; // 避免除以零
|
|
52
|
+
return ((c - l - (h - c)) / (h - l)) * v;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return Ad;
|
|
56
|
+
}());
|
|
57
|
+
exports.default = Ad;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { default as Vma } from "./stockSkills/vma.js";
|
|
|
20
20
|
export { default as Williams } from "./stockSkills/williams.js";
|
|
21
21
|
export { default as ObvEma } from "./stockSkills/obv_ema.js";
|
|
22
22
|
export { default as Mfi } from "./stockSkills/mfi.js";
|
|
23
|
+
export { default as Ad } from "./stockSkills/ad.js";
|
|
23
24
|
export { add } from "./test/add.js";
|
|
24
25
|
export { minus } from "./test/minus.js";
|
|
25
26
|
export { default as calculateDivisionFactor } from "./utils/calculateDivisionFactor.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { default as Vma } from "./stockSkills/vma.js";
|
|
|
23
23
|
export { default as Williams } from "./stockSkills/williams.js";
|
|
24
24
|
export { default as ObvEma } from "./stockSkills/obv_ema.js";
|
|
25
25
|
export { default as Mfi } from "./stockSkills/mfi.js";
|
|
26
|
+
export { default as Ad } from "./stockSkills/ad.js";
|
|
26
27
|
export { add } from "./test/add.js";
|
|
27
28
|
export { minus } from "./test/minus.js";
|
|
28
29
|
export { default as calculateDivisionFactor } from "./utils/calculateDivisionFactor.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StockListType, StockType } from "./types";
|
|
2
|
+
type NewStockType = Required<Pick<StockType, "v">> & StockType;
|
|
3
|
+
export type AdResType = {
|
|
4
|
+
dataset: StockListType;
|
|
5
|
+
ad: number;
|
|
6
|
+
preClose: number;
|
|
7
|
+
};
|
|
8
|
+
interface AdType {
|
|
9
|
+
init: (data: NewStockType) => AdResType;
|
|
10
|
+
next: (data: NewStockType, preList: AdResType) => AdResType;
|
|
11
|
+
}
|
|
12
|
+
export default class Ad implements AdType {
|
|
13
|
+
init(data: NewStockType): AdResType;
|
|
14
|
+
next(data: NewStockType, preList: AdResType): AdResType;
|
|
15
|
+
private calcAD;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
var Ad = /** @class */ (function () {
|
|
11
|
+
function Ad() {
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(Ad.prototype, "init", {
|
|
14
|
+
enumerable: false,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: function (data) {
|
|
18
|
+
// AD 初始值
|
|
19
|
+
var ad = this.calcAD(data);
|
|
20
|
+
return {
|
|
21
|
+
dataset: [data],
|
|
22
|
+
ad: ad,
|
|
23
|
+
preClose: data.c,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(Ad.prototype, "next", {
|
|
28
|
+
enumerable: false,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: function (data, preList) {
|
|
32
|
+
// AD 累加
|
|
33
|
+
var ad = preList.ad + this.calcAD(data);
|
|
34
|
+
return {
|
|
35
|
+
dataset: __spreadArray(__spreadArray([], preList.dataset, true), [data], false),
|
|
36
|
+
ad: ad,
|
|
37
|
+
preClose: data.c,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
// AD 計算公式
|
|
42
|
+
Object.defineProperty(Ad.prototype, "calcAD", {
|
|
43
|
+
enumerable: false,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: function (data) {
|
|
47
|
+
var h = data.h, l = data.l, c = data.c, v = data.v;
|
|
48
|
+
if (h === l)
|
|
49
|
+
return 0; // 避免除以零
|
|
50
|
+
return ((c - l - (h - c)) / (h - l)) * v;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return Ad;
|
|
54
|
+
}());
|
|
55
|
+
export default Ad;
|
package/dist/umd/index.js
CHANGED
|
@@ -1214,7 +1214,7 @@
|
|
|
1214
1214
|
};
|
|
1215
1215
|
return __assign$3.apply(this, arguments);
|
|
1216
1216
|
};
|
|
1217
|
-
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
1217
|
+
var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
1218
1218
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1219
1219
|
if (ar || !(i in from)) {
|
|
1220
1220
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -1254,7 +1254,7 @@
|
|
|
1254
1254
|
obv -= currentVolume;
|
|
1255
1255
|
}
|
|
1256
1256
|
return {
|
|
1257
|
-
dataset: __spreadArray(__spreadArray([], preList.dataset, true), [data], false),
|
|
1257
|
+
dataset: __spreadArray$1(__spreadArray$1([], preList.dataset, true), [data], false),
|
|
1258
1258
|
obv: obv,
|
|
1259
1259
|
preClose: currentClose,
|
|
1260
1260
|
};
|
|
@@ -1869,6 +1869,61 @@
|
|
|
1869
1869
|
return Mfi;
|
|
1870
1870
|
}());
|
|
1871
1871
|
|
|
1872
|
+
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
1873
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1874
|
+
if (ar || !(i in from)) {
|
|
1875
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1876
|
+
ar[i] = from[i];
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1880
|
+
};
|
|
1881
|
+
var Ad = /** @class */ (function () {
|
|
1882
|
+
function Ad() {
|
|
1883
|
+
}
|
|
1884
|
+
Object.defineProperty(Ad.prototype, "init", {
|
|
1885
|
+
enumerable: false,
|
|
1886
|
+
configurable: true,
|
|
1887
|
+
writable: true,
|
|
1888
|
+
value: function (data) {
|
|
1889
|
+
// AD 初始值
|
|
1890
|
+
var ad = this.calcAD(data);
|
|
1891
|
+
return {
|
|
1892
|
+
dataset: [data],
|
|
1893
|
+
ad: ad,
|
|
1894
|
+
preClose: data.c,
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
});
|
|
1898
|
+
Object.defineProperty(Ad.prototype, "next", {
|
|
1899
|
+
enumerable: false,
|
|
1900
|
+
configurable: true,
|
|
1901
|
+
writable: true,
|
|
1902
|
+
value: function (data, preList) {
|
|
1903
|
+
// AD 累加
|
|
1904
|
+
var ad = preList.ad + this.calcAD(data);
|
|
1905
|
+
return {
|
|
1906
|
+
dataset: __spreadArray(__spreadArray([], preList.dataset, true), [data], false),
|
|
1907
|
+
ad: ad,
|
|
1908
|
+
preClose: data.c,
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
// AD 計算公式
|
|
1913
|
+
Object.defineProperty(Ad.prototype, "calcAD", {
|
|
1914
|
+
enumerable: false,
|
|
1915
|
+
configurable: true,
|
|
1916
|
+
writable: true,
|
|
1917
|
+
value: function (data) {
|
|
1918
|
+
var h = data.h, l = data.l, c = data.c, v = data.v;
|
|
1919
|
+
if (h === l)
|
|
1920
|
+
return 0; // 避免除以零
|
|
1921
|
+
return ((c - l - (h - c)) / (h - l)) * v;
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
return Ad;
|
|
1925
|
+
}());
|
|
1926
|
+
|
|
1872
1927
|
function add(a, b) {
|
|
1873
1928
|
return a + b;
|
|
1874
1929
|
}
|
|
@@ -1905,6 +1960,7 @@
|
|
|
1905
1960
|
return devices;
|
|
1906
1961
|
}
|
|
1907
1962
|
|
|
1963
|
+
exports.Ad = Ad;
|
|
1908
1964
|
exports.Angle = TwoPointAngle;
|
|
1909
1965
|
exports.Boll = Boll;
|
|
1910
1966
|
exports.Ema = Ema;
|