Skip to content

Times without a time zone are UTC; Lighter account summaries; positions freshness - #16

Merged
0xFantomMenace merged 1 commit into
masterfrom
fix/utc-times-account-summaries
Sep 28, 2026
Merged

0xFantomMenace merged 1 commit into
masterfrom
fix/utc-times-account-summaries

Conversation

@0xFantomMenace

Copy link
Copy Markdown
Member

Two fixes for 1.12.0: times without a time zone are UTC, and the account summary and positions freshness routes get wrappers.

Times without a time zone are UTC

  • One helper, oxarchive/_time.py, replaces the per-resource conversion copies. An int passes through; an aware datetime is its instant; a naive datetime is UTC; a string of digits is Unix milliseconds; any other string is ISO 8601 (a trailing Z is accepted), UTC when it has no offset, and a date alone is midnight UTC.
  • Before, a naive datetime and an offset-less ISO string were read as the machine's local time. Under TZ=America/New_York, "2026-09-01", "2026-09-01T00:00:00" and datetime(2026, 9, 1) all became 1788235200000 (04:00 UTC); they are now 1788220800000.
  • A value that is not a timestamp raises ValueError instead of being dropped from the request.
  • A naive datetime.now() is local wall-clock time, so the README and docstring examples now use datetime.now(timezone.utc).

New wrappers

  • client.lighter.positions and client.rh_lighter.positions: account(account_index), account_history(account_index, start=, end=, cursor=, limit=), iterate_account_history() and async versions, for /accounts/{account_index}/account and /account/history. Rows are AccountSummary with the account's position aggregates.
  • client.data_quality.positions_freshness() (and apositions_freshness()) for /v1/data-quality/positions, typed as PositionsFreshness.

Checks

  • pytest: 173 passed, also under TZ=Asia/Kolkata and TZ=Pacific/Auckland; the new time zone tests set America/New_York themselves.
  • ruff and mypy --strict: no new findings compared with master.
  • The new methods were called against the production API and every response parsed.

…ns freshness

- One shared timestamp helper replaces the per-resource copies. A naive
  datetime, an ISO string without an offset and a date alone are UTC;
  before, they were read as the machine's local time. A value that is not
  a timestamp raises ValueError instead of being dropped.
- client.lighter.positions and client.rh_lighter.positions: account(),
  account_history(), iterate_account_history() and async versions (the
  account's position aggregates, now and hourly).
- client.data_quality.positions_freshness(): one PositionsFreshness row per
  venue.
- Tests run under a non-UTC time zone; README examples use aware datetimes.
@0xFantomMenace
0xFantomMenace merged commit e3f1669 into master Sep 28, 2026
1 check passed
@0xFantomMenace
0xFantomMenace deleted the fix/utc-times-account-summaries branch September 28, 2026 23:15
0xFantomMenace added a commit that referenced this pull request Sep 29, 2026
…ns freshness (#16)

- One shared helper converts every timestamp. A naive datetime, an ISO
  string without an offset and a date alone are UTC; before, they were
  read as the machine's local time. A value that is not a timestamp raises
  ValueError.
- client.lighter.positions and client.rh_lighter.positions: account(),
  account_history(), iterate_account_history() and async versions.
- client.data_quality.positions_freshness() and PositionsFreshness.
0xFantomMenace added a commit that referenced this pull request Sep 29, 2026
…ns freshness (#16)

- One shared helper converts every timestamp. A naive datetime, an ISO
  string without an offset and a date alone are UTC; before, they were
  read as the machine's local time. A value that is not a timestamp raises
  ValueError.
- client.lighter.positions and client.rh_lighter.positions: account(),
  account_history(), iterate_account_history() and async versions.
- client.data_quality.positions_freshness() and PositionsFreshness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant