ohlcv-indicators 1.9.8 → 2.0.0

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.
@@ -0,0 +1,20 @@
1
+ export const validateDate = dateString => typeof dateString === 'string' && /^\d{4}-\d{2}-\d{2}/.test(dateString)
2
+
3
+
4
+ export const validateInputParams = main => {
5
+
6
+ const {inputParams, len} = main
7
+
8
+ for (const { params } of inputParams) {
9
+ for (const v of params) {
10
+ if (typeof v === 'number' && v > len) {
11
+ console.log(v, len);
12
+ throw new Error('At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.');
13
+ }
14
+ }
15
+ }
16
+ }
17
+
18
+ export const isAlreadyComputed = main => {
19
+ if(main.lastComputedIndex !== 0) throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" or "getData" methods are called.')
20
+ }