Skip to main content

top3-market-context-aware-impovements

· 2 min read

I'll scan the Mercury Kairos module to map the current position job lifecycle and queues, then propose top 3 approaches for market timing awareness.

[4 tools called]

I'll locate the Kairos queue names and job types, and read the position execution consumer to map the lifecycle. Then I'll propose the top 3 approaches for market timing awareness.

[4 tools called]

  • Checked Kairos queues and consumers to map the job lifecycle. Now proposing top 3 timing-aware approaches.

Top 3 market-timing approaches to add context awareness

  1. Session quality scoring and gating
  • What: Compute a rolling “session quality score” (Asian/Europe/US, hour-of-day), volume/volatility-weighted, with exchange uptime and spread/liquidity checks.
  • How to use:
    • Validation gate: block or defer VALIDATE_POSITION_CANDIDATE during poor sessions unless high-confidence signal.
    • Scheduling: slow SYNC cadence and TPSL recalcs in weak sessions; speed up in strong sessions.
  • Integration points:
    • DynamicTpslConsumer.handleValidatePositionCandidate(...): inject sessionScore into decision; require minimum score to proceed.
    • PositionSchedulerService.schedulePositionSyncJobs() and any candle-delay util: vary cadence by session score.
    • tpsl-helpers.validateTPSLDataSanity(...): enforce larger SL buffers when session score is low.
  1. Volatility regime controls (ATR/ADX bands) with risk throttling
  • What: Classify low/normal/high regimes (ATR percent-of-price, ADX, realized vol) per symbol-timeframe and throttle entries/risk.
  • How to use:
    • Validation: disallow entries in extreme regimes unless strategy explicitly supports them.
    • TPSL shaping: widen SL/bring TPs closer in high-vol; cap reward/risk dynamically.
  • Integration points:
    • TaService to compute ATR/ADX; pass regime into DynamicTPSLService and validation output.
    • tpsl-helpers.fixExcessiveRewardRiskRatio(...): make regime-aware caps/floors.
    • PositionExecutionConsumer.handleFinalizePosition(...): guard finalize/open if regime out-of-policy.
  1. Event risk windows and micro-liquidity guardrails
  • What: Maintain a near-term “risk calendar” (economic events, exchange maintenance) plus live micro-liquidity checks (spread, order book depth).
  • How to use:
    • Validation: block/defer near high-impact events; allow only shadow positions; or reduce size.
    • Scheduler: introduce “freeze windows” where only SYNC runs, no new creates/finalizes.
  • Integration points:
    • Extend validation output with eventRiskLevel and liquidityOk.
    • PositionFactory/finalize gate: enforce freeze windows for LIVE opens.
    • PositionSchedulerService: schedule deferrals until window passes.

Current position lifecycle (jobs perspective)

  • Queues

    • KAIROS.dynamic-tpsl
      • VALIDATE_POSITION_CANDIDATE: AI validation (pre-entry)
      • CALCULATE_DYNAMIC_TPSL_INIT: initial TP/SL calc for creation
      • CALCULATE_DYNAMIC_TPSL_PERIODIC: recalcs for open positions
    • KAIROS.position-execution
      • CREATE_POSITION: creates DB entity and opens LIVE position on exchange (stores exchangeOrderLinkId), emits event
      • FINALIZE_POSITION: finalizes with TPSL and opens LIVE if needed, emits event
      • SYNC_POSITION: core sync for TP/SL checks, verification, pricing updates
      • SCHEDULE_POSITIONS: orchestrates scheduling of SYNC_POSITION jobs
  • Primary flow

    1. Candidate → VALIDATE_POSITION_CANDIDATE (gate: market session/regime/event recommended)
    2. If valid → CALCULATE_DYNAMIC_TPSL_INIT
    3. CREATE_POSITION (or FINALIZE_POSITION depending on flow) opens LIVE on exchange and emits event
    4. SCHEDULE_POSITIONS periodically enqueues SYNC_POSITION per open position
    5. Optional: CALCULATE_DYNAMIC_TPSL_PERIODIC to adapt levels
  • Key guard points for timing/context

    • Validation step: accept/deny/defer with reason and next-candle delay
    • Finalize/open: last-mile gating before touching exchange
    • Scheduler: cadence control and freeze windows

Minimal, high-impact implementation plan

  • Add MarketContextService (session score, regime, event risk, liquidity) consumed by:

    • DynamicTpslConsumer.handleValidatePositionCandidate(...)
    • PositionSchedulerService.schedulePositionSyncJobs(...)
    • PositionExecutionConsumer.handleFinalizePosition(...)
  • Extend validation result/AI decision context with sessionScore, volRegime, eventRiskLevel.

  • Make tpsl-helpers regime-aware: dynamic R/R caps, SL buffers, TP spacing.

  • Adjust scheduler cadence and allow deferrals based on session score and event windows.

  • In short: gate earlier (validation), shape risk (TPSL), and schedule smarter (scheduler).

  • Summary: Proposed 3 timing-aware layers (session scoring, volatility regimes, event/liquidity guardrails) and mapped where to inject them across validation, finalize/open, and scheduling for a robust market context pipeline.