import { MT5_INTERVAL, MT5Interval } from '../../common/constants/mt5.constant'; /** Single source-interval value (always M1; doc §5.5.2). */ type M1Only = typeof MT5_INTERVAL.M1; /** * Chart-bars query — mirrors BE `GET /api/v1/chart/bars` (doc §5.5.1). * All fields use camelCase; the service forwards them verbatim to the backend. */ export interface BarsQuery { symbol: string; /** * Accepts FE-style ('1m','5m','15m','30m','1h','4h','1d','1w','1M') * OR MT5-style ('M1'…'MN1'). Passed through verbatim; the backend maps * both to the same bucket width. */ interval: MT5Interval | ChartIntervalFe | (string & {}); /** ISO-8601, inclusive lower bound. */ fromTime: string; /** ISO-8601, exclusive upper bound, strictly > fromTime. */ toTime: string; /** MT5 server filter. Defaults to `MT5_SERVER_NAME` (`'live'`) when omitted. */ serverName?: string; /** 1..5000, applied AFTER aggregation. Default 1000. */ limit?: number; /** 'asc' (oldest first, default) | 'desc' (newest first). */ sortDirection?: BarsSortDirection; } export type BarsSortDirection = 'asc' | 'desc'; /** Aggregation-source label for a derived bar (doc §5.5.2). Distinct from * MT5ChartBarSource (raw Mt5ChartBar.data.source, doc §4.6). * `broker_snapshot` — seen on `POST /api/v1/chart/bars/latest` (live demo). */ export type BarsItemSource = 'aggregated' | 'live' | 'backfill' | 'broker_snapshot'; export interface BarItem { symbol: string; /** Canonical MT5-style bucket width. */ interval: MT5Interval; /** ISO-8601 UTC; bucket-start for aggregated bars. */ mt5Ts: string; open: number; high: number; low: number; close: number; tickVolume: number | null; volume: number | null; spread: number | null; source: BarsItemSource | null; } export interface BarsResponse { items: BarItem[]; symbol: string; /** Canonical label returned by the backend. */ interval: MT5Interval; /** ISO-8601 UTC (= parsed fromTime). */ fromTime: string; /** ISO-8601 UTC (= parsed toTime). */ toTime: string; /** Always 'M1' — the only persisted interval. */ sourceInterval: M1Only; /** items.length. */ count: number; /** true iff interval !== 'M1' and bucketing occurred. */ aggregated: boolean; } /** FE-style timeframe labels accepted by GET /api/v1/chart/bars (doc §5.5.1). */ export declare const CHART_INTERVAL: { readonly M1: "1m"; readonly M5: "5m"; readonly M15: "15m"; readonly M30: "30m"; readonly H1: "1h"; readonly H4: "4h"; readonly D1: "1d"; readonly W1: "1w"; readonly MN1: "1M"; }; export type ChartIntervalFe = (typeof CHART_INTERVAL)[keyof typeof CHART_INTERVAL]; /** Map either dialect to the canonical MT5 label. */ export declare function normalizeChartInterval(input: MT5Interval | ChartIntervalFe | string): MT5Interval; /** * Latest-bar query — mirrors BE `POST /api/v1/chart/bars/latest`. * All fields camelCase; the service forwards them verbatim to the backend. */ export interface BarsLatestQuery { /** Non-empty symbol list; duplicates are deduped before the call. */ symbols: string[]; /** MT5 server filter. Defaults to `MT5_SERVER_NAME` (`'live'`) when omitted. */ serverName?: string; } /** One latest-bar row: a plain `BarItem` plus the resolved server. */ export type BarsLatestItem = BarItem & { serverName: string; }; /** * Latest-bar response — a map keyed by SYMBOL (verified against the live * demo endpoint). Symbols with no bar are simply absent from the map. */ export type BarsLatestResponse = Record; export {}; //# sourceMappingURL=bars.type.d.ts.map