ohlcv-indicators 1.6.1 → 1.6.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,9 @@ export const parseOhlcvToVertical = (input, len) => {
|
|
|
32
32
|
{
|
|
33
33
|
verticalOhlcv['session_index'] = new Array(len)
|
|
34
34
|
verticalOhlcv['session_intraday_index'] = new Array(len)
|
|
35
|
+
verticalOhlcv['day_of_the_week'] = new Array(len)
|
|
36
|
+
verticalOhlcv['day_of_the_month'] = new Array(len)
|
|
37
|
+
verticalOhlcv['week_of_the_month'] = new Array(len)
|
|
35
38
|
prevDateStr = input[0].date.slice(0, 10)
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -59,11 +62,43 @@ export const parseOhlcvToVertical = (input, len) => {
|
|
|
59
62
|
sessionIntradayIndex = 0
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
const {
|
|
66
|
+
day_of_the_week,
|
|
67
|
+
day_of_the_month,
|
|
68
|
+
week_of_the_month
|
|
69
|
+
} = getDateInfo(thisDateStr)
|
|
70
|
+
|
|
71
|
+
verticalOhlcv.day_of_the_week[x] = day_of_the_week
|
|
72
|
+
verticalOhlcv.day_of_the_month[x] = day_of_the_month
|
|
73
|
+
verticalOhlcv.week_of_the_month[x] = week_of_the_month
|
|
62
74
|
verticalOhlcv.session_index[x] = sessionIndex
|
|
63
75
|
verticalOhlcv.session_intraday_index[x] = sessionIntradayIndex
|
|
76
|
+
|
|
64
77
|
sessionIntradayIndex++
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
return verticalOhlcv
|
|
69
|
-
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const getDateInfo = dateString => {
|
|
86
|
+
const date = new Date(dateString);
|
|
87
|
+
|
|
88
|
+
// Get day of the week (0 for Sunday, 1 for Monday, etc.)
|
|
89
|
+
const day_of_the_week = date.getDay()
|
|
90
|
+
|
|
91
|
+
// Get day of the month
|
|
92
|
+
const day_of_the_month = date.getDate();
|
|
93
|
+
|
|
94
|
+
// Calculate the week of the month
|
|
95
|
+
const firstDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1);
|
|
96
|
+
const dayOffset = firstDayOfMonth.getDay(); // Day of the week for the 1st day of the month
|
|
97
|
+
const week_of_the_month = Math.ceil((day_of_the_month + dayOffset) / 7);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
day_of_the_week,
|
|
101
|
+
day_of_the_month,
|
|
102
|
+
week_of_the_month
|
|
103
|
+
};
|
|
104
|
+
}
|