pmxt icon indicating copy to clipboard operation
pmxt copied to clipboard

since param type inconsistency: TypeScript uses Date, Python uses int (Unix ms)

Open realfishsam opened this issue 6 months ago • 7 comments

Inconsistency

The since time-filter parameter is typed as Date in the TypeScript core but as int (Unix milliseconds) in the Python SDK. CCXT uses Int (Unix milliseconds) universally in both languages.

Current (PMXT)

TypeScript — core/src/BaseExchange.ts:

interface MyTradesParams {
  since?: Date;    // Date object
  until?: Date;    // Date object
  // ...
}
interface OrderHistoryParams {
  since?: Date;    // Date object
  until?: Date;    // Date object
  // ...
}

Python — sdks/python/pmxt/client.py:

def fetch_trades(self, outcome_id=_UNSET, limit=None, since=None, ...) -> List[Trade]
#                                                       ^^^^ int (Unix ms)
def fetch_my_trades(self, params: Optional[dict] = None, **kwargs) -> List[UserTrade]
# docs/usage shows since as an integer timestamp

Expected (CCXT convention)

CCXT uses Unix millisecond integers (Int = number | undefined in TypeScript, plain int in Python) for since in all languages:

// CCXT TypeScript
async fetchMyTrades(symbol: Str, since: Int = undefined, ...): Promise<Trade[]>
# CCXT Python
def fetch_my_trades(self, symbol=None, since=None, limit=None, params={}):
    # since: int (Unix ms)

Impact

TypeScript callers must use new Date(timestamp) to construct filter values. Python callers pass raw integers. This inconsistency means the two SDKs behave differently for the same conceptual operation. Cross-language code samples in documentation will be wrong for one of the two SDKs.

Found by automated PMXT ↔ CCXT API consistency audit

realfishsam avatar May 22 '26 12:05 realfishsam

Additional context from duplicates #1003 and #1005 — exact file and line references:

MyTradesParams (from #1005):

SDK File Lines Type
TypeScript sdks/typescript/pmxt/models.ts 636–638 since?: Date, until?: Date
Python sdks/python/pmxt/models.py 820–821 since: int, until: int
Affects: fetchMyTrades / fetch_my_trades

OrderHistoryParams (from #1003):

SDK File Lines Type
TypeScript sdks/typescript/pmxt/models.ts 652–654 since?: Date, until?: Date
Python sdks/python/pmxt/models.py 829–830 since: int, until: int
Affects: fetchClosedOrders / fetch_closed_orders and fetchAllOrders / fetch_all_orders

Generated by Claude Code

realfishsam avatar Jun 13 '26 21:06 realfishsam

Additional context from duplicates #1095 and #1096:

The Date vs int mismatch exists in both the core type definitions (core/src/BaseExchange.ts, already noted above) and in the SDK model files:

MyTradesParams (sdks/typescript/pmxt/models.ts ~line 630):

export interface MyTradesParams {
  outcomeId?: string;
  marketId?: string;
  since?: Date;
  until?: Date;
  limit?: number;
  cursor?: string;
}

Python counterpart (sdks/python/pmxt/models.py ~line 816):

class MyTradesParams(TypedDict, total=False):
    outcome_id: str
    market_id: str
    since: int   # unix timestamp
    until: int   # unix timestamp
    limit: int
    cursor: str

OrderHistoryParams (sdks/typescript/pmxt/models.ts ~line 648):

export interface OrderHistoryParams {
  marketId?: string;
  since?: Date;
  until?: Date;
  limit?: number;
  cursor?: string;
}

Python counterpart (sdks/python/pmxt/models.py ~line 826):

class OrderHistoryParams(TypedDict, total=False):
    market_id: str
    since: int   # unix timestamp
    until: int   # unix timestamp
    limit: int
    cursor: str

The fix must be applied in both the core BaseExchange types and the SDK models.ts/models.py files. The same Date vs int pattern also appears in TradesParams (#968), OHLCVParams (#1048), and HistoryFilterParams (#1006).


Generated by Claude Code

realfishsam avatar Jun 15 '26 21:06 realfishsam

Additional context from duplicates #1130 and #1131 — SDK-level file locations for each affected params type:

MyTradesParams (from #1130):

  • TypeScript: sdks/typescript/pmxt/models.ts lines 630–643 — since?: Date, until?: Date
  • Python: sdks/python/pmxt/models.py lines 816–823 — since: int, until: int (Unix ms)

OrderHistoryParams (from #1131):

  • TypeScript: sdks/typescript/pmxt/models.ts lines 648–659 — since?: Date, until?: Date
  • Python: sdks/python/pmxt/models.py lines 826–832 — since: int, until: int (Unix ms)

Note: TradesParams has the same pattern but with an additional field-name inconsistency (start/end in TS vs since/until in Python), tracked separately in #968.


Generated by Claude Code

realfishsam avatar Jun 16 '26 21:06 realfishsam

Additional context from duplicate #1153 (sdks/typescript/pmxt/models.ts:630):

// sdks/typescript/pmxt/models.ts:630
export interface MyTradesParams {
    outcomeId?: string;
    marketId?: string;
    /** Only return records after this date */
    since?: Date;   // Date object
    /** Only return records before this date */
    until?: Date;   // Date object
    limit?: number;
    cursor?: string;
}

Python equivalent (sdks/python/pmxt/models.py) uses int (Unix timestamp) for the same fields. #1153 is being closed as a duplicate of this issue.


Generated by Claude Code

realfishsam avatar Jun 18 '26 21:06 realfishsam

Additional context from duplicate #1154 (sdks/typescript/pmxt/models.ts:648):

// sdks/typescript/pmxt/models.ts:648
export interface OrderHistoryParams {
    /** Filter by market ID */
    marketId?: string;
    /** Only return records after this date */
    since?: Date;    // Date object
    /** Only return records before this date */
    until?: Date;    // Date object
    /** Maximum number of results */
    limit?: number;
    cursor?: string;
}

Python equivalent uses int (Unix timestamp) for the same fields. #1154 is being closed as a duplicate of this issue.


Generated by Claude Code

realfishsam avatar Jun 18 '26 21:06 realfishsam

Additional context from duplicate #1165: pins exact file/line citations (models.ts:630-643, models.py:816-823) for the same MyTradesParams since/until Date-vs-int fields already quoted verbatim in this issue.

Additional context from duplicate #1166: pins exact file/line citations (models.ts:648-659, models.py:826-833) for the same OrderHistoryParams since/until Date-vs-int fields, and notes this type is used by fetchClosedOrders/fetchAllOrders specifically.


Generated by Claude Code

realfishsam avatar Jul 03 '26 21:07 realfishsam

Additional context from duplicates #1526 and #1527 — current SDK-level file locations (file has shifted since earlier citations in this thread):

MyTradesParams (from #1526):

  • TypeScript: sdks/typescript/pmxt/models.ts:674-687 — since?: Date, until?: Date
  • Python: sdks/python/pmxt/models.py:832-839 — since: int, until: int Affects: fetchMyTrades / fetch_my_trades

OrderHistoryParams (from #1527):

  • TypeScript: sdks/typescript/pmxt/models.ts:692-702 — since?: Date, until?: Date
  • Python: sdks/python/pmxt/models.py:842-848 — since: int, until: int Affects: fetchClosedOrders/fetch_closed_orders and fetchAllOrders/fetch_all_orders

Same underlying Date-vs-int drift already tracked by this issue.


Generated by Claude Code

realfishsam avatar Jul 18 '26 21:07 realfishsam