@polymarbot/shared 0.2.0 → 0.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.
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,
@@ -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
- export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
16
+ declare function calculatePeriodStartInET(intervalSeconds: number): number;
17
+
18
+ export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
@@ -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
- export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymarbot/shared",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "main": "./basic.cjs",
6
6
  "module": "./basic.js",