@polymarbot/shared 0.2.0 → 0.2.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/index.cjs +9 -0
- package/index.d.cts +7 -0
- package/index.d.ts +7 -0
- package/index.js +7 -0
- package/markets/tools.cjs +11 -0
- package/markets/tools.d.cts +3 -1
- package/markets/tools.d.ts +3 -1
- package/markets/tools.js +10 -0
- package/package.json +14 -4
package/index.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
...require('./basic.cjs'),
|
|
3
|
+
...require('./markets/tools.cjs'),
|
|
4
|
+
...require('./markets/types.cjs'),
|
|
5
|
+
...require('./relayer-client.cjs'),
|
|
6
|
+
...require('./trade-strategy/normalize.cjs'),
|
|
7
|
+
...require('./trade-strategy/types.cjs'),
|
|
8
|
+
...require('./wallet.cjs')
|
|
9
|
+
}
|
package/index.d.cts
ADDED
package/index.d.ts
ADDED
package/index.js
ADDED
package/markets/tools.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var tools_exports = {};
|
|
|
32
32
|
__export(tools_exports, {
|
|
33
33
|
SUPPORTED_SYMBOLS: () => SUPPORTED_SYMBOLS,
|
|
34
34
|
SYMBOL_FULL_NAME_MAP: () => SYMBOL_FULL_NAME_MAP,
|
|
35
|
+
calculatePeriodStartInET: () => calculatePeriodStartInET,
|
|
35
36
|
generate15mSlug: () => generate15mSlug,
|
|
36
37
|
generate1dSlug: () => generate1dSlug,
|
|
37
38
|
generate1hSlug: () => generate1hSlug,
|
|
@@ -107,10 +108,20 @@ function generate1dSlug(timestamp, symbol) {
|
|
|
107
108
|
const day = date.getUTCDate();
|
|
108
109
|
return `${prefix}-up-or-down-on-${month}-${day}`;
|
|
109
110
|
}
|
|
111
|
+
function calculatePeriodStartInET(intervalSeconds) {
|
|
112
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
113
|
+
const utcTime = dayjs_default.unix(now).utc();
|
|
114
|
+
const etTime = dayjs_default.unix(now).tz("America/New_York");
|
|
115
|
+
const offset = utcTime.utcOffset() * 60 - etTime.utcOffset() * 60;
|
|
116
|
+
const nowInET = now - offset;
|
|
117
|
+
const periodStartInET = Math.floor(nowInET / intervalSeconds) * intervalSeconds;
|
|
118
|
+
return periodStartInET + offset;
|
|
119
|
+
}
|
|
110
120
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
121
|
0 && (module.exports = {
|
|
112
122
|
SUPPORTED_SYMBOLS,
|
|
113
123
|
SYMBOL_FULL_NAME_MAP,
|
|
124
|
+
calculatePeriodStartInET,
|
|
114
125
|
generate15mSlug,
|
|
115
126
|
generate1dSlug,
|
|
116
127
|
generate1hSlug,
|
package/markets/tools.d.cts
CHANGED
|
@@ -13,4 +13,6 @@ declare function generate4hSlug(timestamp: number, symbol: SupportedSymbol): str
|
|
|
13
13
|
|
|
14
14
|
declare function generate1dSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
declare function calculatePeriodStartInET(intervalSeconds: number): number;
|
|
17
|
+
|
|
18
|
+
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
|
package/markets/tools.d.ts
CHANGED
|
@@ -13,4 +13,6 @@ declare function generate4hSlug(timestamp: number, symbol: SupportedSymbol): str
|
|
|
13
13
|
|
|
14
14
|
declare function generate1dSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
declare function calculatePeriodStartInET(intervalSeconds: number): number;
|
|
17
|
+
|
|
18
|
+
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
|
package/markets/tools.js
CHANGED
|
@@ -60,9 +60,19 @@ function generate1dSlug(timestamp, symbol) {
|
|
|
60
60
|
const day = date.getUTCDate();
|
|
61
61
|
return `${prefix}-up-or-down-on-${month}-${day}`;
|
|
62
62
|
}
|
|
63
|
+
function calculatePeriodStartInET(intervalSeconds) {
|
|
64
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
65
|
+
const utcTime = dayjs_default.unix(now).utc();
|
|
66
|
+
const etTime = dayjs_default.unix(now).tz("America/New_York");
|
|
67
|
+
const offset = utcTime.utcOffset() * 60 - etTime.utcOffset() * 60;
|
|
68
|
+
const nowInET = now - offset;
|
|
69
|
+
const periodStartInET = Math.floor(nowInET / intervalSeconds) * intervalSeconds;
|
|
70
|
+
return periodStartInET + offset;
|
|
71
|
+
}
|
|
63
72
|
export {
|
|
64
73
|
SUPPORTED_SYMBOLS,
|
|
65
74
|
SYMBOL_FULL_NAME_MAP,
|
|
75
|
+
calculatePeriodStartInET,
|
|
66
76
|
generate15mSlug,
|
|
67
77
|
generate1dSlug,
|
|
68
78
|
generate1hSlug,
|
package/package.json
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/shared",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "./
|
|
6
|
-
"module": "./
|
|
7
|
-
"types": "./
|
|
5
|
+
"main": "./index.cjs",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./index.d.cts",
|
|
16
|
+
"default": "./index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
9
19
|
"./basic": {
|
|
10
20
|
"import": {
|
|
11
21
|
"types": "./basic.d.ts",
|