pmxt-core 1.1.1 → 1.1.3

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.
@@ -24,12 +24,16 @@ async function fetchOHLCV(id, params) {
24
24
  const now = Math.floor(Date.now() / 1000);
25
25
  let startTs = now - (24 * 60 * 60);
26
26
  let endTs = now;
27
- if (params.start) {
28
- startTs = Math.floor(params.start.getTime() / 1000);
27
+ // Helper to handle string dates (from JSON)
28
+ const ensureDate = (d) => (typeof d === 'string' ? new Date(d) : d);
29
+ const pStart = params.start ? ensureDate(params.start) : undefined;
30
+ const pEnd = params.end ? ensureDate(params.end) : undefined;
31
+ if (pStart) {
32
+ startTs = Math.floor(pStart.getTime() / 1000);
29
33
  }
30
- if (params.end) {
31
- endTs = Math.floor(params.end.getTime() / 1000);
32
- if (!params.start) {
34
+ if (pEnd) {
35
+ endTs = Math.floor(pEnd.getTime() / 1000);
36
+ if (!pStart) {
33
37
  startTs = endTs - (24 * 60 * 60);
34
38
  }
35
39
  }
@@ -20,9 +20,13 @@ async function fetchOHLCV(id, params) {
20
20
  const nowTs = Math.floor(Date.now() / 1000);
21
21
  // 1. Smart Lookback Calculation
22
22
  // If start/end not provided, calculate window based on limit * resolution
23
- let startTs = params.start ? Math.floor(params.start.getTime() / 1000) : 0;
24
- let endTs = params.end ? Math.floor(params.end.getTime() / 1000) : nowTs;
25
- if (!params.start) {
23
+ // Helper to handle string dates (from JSON)
24
+ const ensureDate = (d) => (typeof d === 'string' ? new Date(d) : d);
25
+ const pStart = params.start ? ensureDate(params.start) : undefined;
26
+ const pEnd = params.end ? ensureDate(params.end) : undefined;
27
+ let startTs = pStart ? Math.floor(pStart.getTime() / 1000) : 0;
28
+ let endTs = pEnd ? Math.floor(pEnd.getTime() / 1000) : nowTs;
29
+ if (!pStart) {
26
30
  // Default limit is usually 20 in the example, but safety margin is good.
27
31
  // If limit is not set, we default to 100 candles.
28
32
  const count = params.limit || 100;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxt-core",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "pmxt is a unified prediction market data API. The ccxt for prediction markets.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,8 +29,8 @@
29
29
  "test": "jest -c jest.config.js",
30
30
  "server": "tsx watch src/server/index.ts",
31
31
  "server:prod": "node dist/server/index.js",
32
- "generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=1.1.1,library=urllib3",
33
- "generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=1.1.1,supportsES6=true,typescriptThreePlus=true",
32
+ "generate:sdk:python": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g python -o ../sdks/python/generated --package-name pmxt_internal --additional-properties=projectName=pmxt-internal,packageVersion=1.1.3,library=urllib3",
33
+ "generate:sdk:typescript": "npx @openapitools/openapi-generator-cli generate -i src/server/openapi.yaml -g typescript-fetch -o ../sdks/typescript/generated --additional-properties=npmName=pmxtjs,npmVersion=1.1.3,supportsES6=true,typescriptThreePlus=true",
34
34
  "generate:docs": "node ../scripts/generate-api-docs.js",
35
35
  "generate:sdk:all": "npm run generate:sdk:python && npm run generate:sdk:typescript && npm run generate:docs"
36
36
  },