Technical Journal — Egis (Admin, Positions, BI, Time Invariants)
What I have done
- Continued shaping Egis Admin BI and operations with a strict backend-first, evidence-first approach.
- Extended Admin Dashboard metrics:
- Updated Total Fee to correctly include funding fees.
- Added Total Volume as a pure execution-derived metric.
- Defined navigation from Total Fee → a new Admin > Fees page.
- Designed the Admin > Fees page with:
- A clear summary section (total, trading fees, funding fees).
- A paginated, backend-driven table listing all fee records.
- Refactored Admin > Positions for clarity and correctness:
- Merged
opened_at and closed_at into a single Duration column.
- Duration is human-readable, backend-generated, and excludes seconds.
- Open positions display
- instead of live timers.
- Added hover tooltips to reveal exact opened / closed datetimes when needed.
- Investigated and fixed multiple timestamp consistency issues:
- Detected impossible cases where
closed_at < opened_at.
- Fixed the root cause instead of masking it at the UI layer.
- Discovered a follow-up issue where some CLOSED positions lost
closed_at.
- Enforced the invariant: status = CLOSED requires a valid closed_at or an explicit reason.
- Identified a new anomaly:
- Positions with IDs 41–55 showing
opened_at == closed_at.
- Initiated a structured investigation to trace this back to execution data, repair logic, or timestamp normalization.
- Defined multiple hard invariants and investigative playbooks for Cursor:
- Positions lifecycle must be derived from executions, not assumptions.
- No silent timestamp “fixing”.
- All BI and display values must be explainable under stress.
What I have learned
- Time is one of the most fragile domains in trading systems:
- A single guard clause meant to “fix” bad data can quietly corrupt historical truth.
- Every timestamp must have a clear origin: execution time, not import time or UI time.
- UI simplification increases backend responsibility:
- Replacing raw timestamps with Duration made data inconsistencies more visible, not less.
- This is good: it forces correctness instead of hiding problems.
- Status-based assumptions are dangerous:
status = CLOSED does not automatically mean all lifecycle fields are valid.
- Status transitions must be atomic with their timestamps.
- Backend-first formatting is not just aesthetics:
- Centralizing datetime, currency, and duration formatting eliminates entire classes of bugs.
- It also makes cross-page consistency enforceable, not aspirational.
- BI features should reinforce invariants, not create overlap:
- Separating execution quality, fees, volume, and PnL keeps each metric auditable.
- Removing seconds from duration is a UX choice that also reduces false precision.
- Every fix must create a recovery path:
- Nulling bad data without recomputation logic only defers the bug.
- Repair commands and evidence logs are essential for long-lived systems.