From a67a2c732ec4093ed6a7140cf5577d4c410a5449 Mon Sep 17 00:00:00 2001 From: dceoy Date: Sun, 26 Apr 2026 12:50:38 +0000 Subject: [PATCH] deploy: b8ce76c9d682144e5b48354665aeb302ff119b53 --- api/cli/index.html | 2190 +++++++++++++++++++++++++------------- index.html | 25 + objects.inv | Bin 503 -> 558 bytes search/search_index.json | 2 +- sitemap.xml | 6 +- sitemap.xml.gz | Bin 204 -> 204 bytes 6 files changed, 1470 insertions(+), 753 deletions(-) diff --git a/api/cli/index.html b/api/cli/index.html index c14c365..ccbab8e 100644 --- a/api/cli/index.html +++ b/api/cli/index.html @@ -410,6 +410,17 @@ + + +
  • + + + + REQUEST_TYPE + + + +
  • @@ -653,6 +664,17 @@ +
  • + +
  • + + + + last_error + + + +
  • @@ -664,6 +686,39 @@ +
  • + +
  • + + + + market_book + + + + +
  • + +
  • + + + + order_check + + + + +
  • + +
  • + + + + order_send + + + +
  • @@ -686,6 +741,17 @@ +
  • + +
  • + + + + parse_request + + + +
  • @@ -763,6 +829,17 @@ +
  • + +
  • + + + + symbol_info_tick + + + +
  • @@ -807,6 +884,17 @@ +
  • + +
  • + + + + version + + + +
  • @@ -877,6 +965,17 @@ + + +
  • + + + + REQUEST_TYPE + + + +
  • @@ -1120,6 +1219,17 @@ +
  • + +
  • + + + + last_error + + + +
  • @@ -1131,6 +1241,39 @@ +
  • + +
  • + + + + market_book + + + + +
  • + +
  • + + + + order_check + + + + +
  • + +
  • + + + + order_send + + + +
  • @@ -1153,6 +1296,17 @@ +
  • + +
  • + + + + parse_request + + + +
  • @@ -1230,6 +1384,17 @@ +
  • + +
  • + + + + symbol_info_tick + + + +
  • @@ -1274,6 +1439,17 @@ +
  • + +
  • + + + + version + + + +
  • @@ -1361,6 +1537,28 @@ +

    + REQUEST_TYPE + + + + module-attribute + + +

    +
    REQUEST_TYPE = _RequestType()
    +
    + +
    + +
    + + + +
    + + +

    TICK_FLAGS_TYPE @@ -1819,13 +2017,13 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def account_info(ctx: typer.Context) -> None:
    -    """Export account information."""
    -    _execute_export(ctx, lambda c: c.account_info_as_df())
    +              
    @app.command()
    +def account_info(ctx: typer.Context) -> None:
    +    """Export account information."""
    +    _execute_export(ctx, lambda c: c.account_info_as_df())
     
    @@ -1945,57 +2143,57 @@
    Source code in mt5cli/cli.py -
    def detect_format(
    -    output_path: Path,
    -    explicit_format: str | None = None,
    -) -> str:
    -    """Detect the output format from a file extension or explicit format string.
    -
    -    Args:
    -        output_path: Path to the output file.
    -        explicit_format: Explicitly specified format, if any.
    -
    -    Returns:
    -        The detected format string.
    -
    -    Raises:
    -        ValueError: If the format cannot be determined.
    -    """
    -    if explicit_format is not None:
    -        return explicit_format
    -    suffix = output_path.suffix.lower()
    -    if suffix in _FORMAT_EXTENSIONS:
    -        return _FORMAT_EXTENSIONS[suffix]
    -    msg = (
    -        f"Cannot detect format from extension '{suffix}'."
    -        " Use --format to specify the output format."
    -    )
    -    raise ValueError(msg)
    +              
    def detect_format(
    +    output_path: Path,
    +    explicit_format: str | None = None,
    +) -> str:
    +    """Detect the output format from a file extension or explicit format string.
    +
    +    Args:
    +        output_path: Path to the output file.
    +        explicit_format: Explicitly specified format, if any.
    +
    +    Returns:
    +        The detected format string.
    +
    +    Raises:
    +        ValueError: If the format cannot be determined.
    +    """
    +    if explicit_format is not None:
    +        return explicit_format
    +    suffix = output_path.suffix.lower()
    +    if suffix in _FORMAT_EXTENSIONS:
    +        return _FORMAT_EXTENSIONS[suffix]
    +    msg = (
    +        f"Cannot detect format from extension '{suffix}'."
    +        " Use --format to specify the output format."
    +    )
    +    raise ValueError(msg)
     
    @@ -2127,36 +2325,7 @@
    Source code in mt5cli/cli.py -
    235
    -236
    -237
    -238
    -239
    -240
    -241
    -242
    -243
    -244
    -245
    -246
    -247
    -248
    -249
    -250
    -251
    -252
    -253
    -254
    -255
    -256
    -257
    -258
    -259
    -260
    -261
    -262
    -263
    -264
    +              
    264
     265
     266
     267
    @@ -2165,45 +2334,74 @@
     270
     271
     272
    -273
    def export_dataframe(
    -    df: pd.DataFrame,
    -    output_path: Path,
    -    output_format: str,
    -    table_name: str = "data",
    -) -> None:
    -    """Export a pandas DataFrame to the specified file format.
    -
    -    Args:
    -        df: DataFrame to export.
    -        output_path: Path to the output file.
    -        output_format: Output format (csv, json, parquet, or sqlite3).
    -        table_name: Table name for SQLite3 output.
    -
    -    Raises:
    -        ValueError: If the output format is not supported.
    -    """
    -    if output_format == "csv":
    -        df.to_csv(output_path, index=False)
    -    elif output_format == "json":
    -        df.to_json(
    -            output_path,
    -            orient="records",
    -            date_format="iso",
    -            indent=2,
    -        )
    -    elif output_format == "parquet":
    -        df.to_parquet(output_path, index=False)
    -    elif output_format == "sqlite3":
    -        with sqlite3.connect(output_path) as conn:
    -            df.to_sql(  # type: ignore[reportUnknownMemberType]
    -                table_name,
    -                conn,
    -                if_exists="replace",
    -                index=False,
    -            )
    -    else:
    -        msg = f"Unsupported output format: {output_format}"
    -        raise ValueError(msg)
    +273
    +274
    +275
    +276
    +277
    +278
    +279
    +280
    +281
    +282
    +283
    +284
    +285
    +286
    +287
    +288
    +289
    +290
    +291
    +292
    +293
    +294
    +295
    +296
    +297
    +298
    +299
    +300
    +301
    +302
    def export_dataframe(
    +    df: pd.DataFrame,
    +    output_path: Path,
    +    output_format: str,
    +    table_name: str = "data",
    +) -> None:
    +    """Export a pandas DataFrame to the specified file format.
    +
    +    Args:
    +        df: DataFrame to export.
    +        output_path: Path to the output file.
    +        output_format: Output format (csv, json, parquet, or sqlite3).
    +        table_name: Table name for SQLite3 output.
    +
    +    Raises:
    +        ValueError: If the output format is not supported.
    +    """
    +    if output_format == "csv":
    +        df.to_csv(output_path, index=False)
    +    elif output_format == "json":
    +        df.to_json(
    +            output_path,
    +            orient="records",
    +            date_format="iso",
    +            indent=2,
    +        )
    +    elif output_format == "parquet":
    +        df.to_parquet(output_path, index=False)
    +    elif output_format == "sqlite3":
    +        with sqlite3.connect(output_path) as conn:
    +            df.to_sql(  # type: ignore[reportUnknownMemberType]
    +                table_name,
    +                conn,
    +                if_exists="replace",
    +                index=False,
    +            )
    +    else:
    +        msg = f"Unsupported output format: {output_format}"
    +        raise ValueError(msg)
     
    @@ -2262,61 +2460,61 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def history_deals(
    -    ctx: typer.Context,
    -    date_from: Annotated[
    -        datetime | None,
    -        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    -    ] = None,
    -    date_to: Annotated[
    -        datetime | None,
    -        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    -    ] = None,
    -    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    -    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    -    ticket: Annotated[int | None, typer.Option(help="Order ticket.")] = None,
    -    position: Annotated[int | None, typer.Option(help="Position ticket.")] = None,
    -) -> None:
    -    """Export historical deals."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.history_deals_get_as_df(
    -            date_from=date_from,
    -            date_to=date_to,
    -            group=group,
    -            symbol=symbol,
    -            ticket=ticket,
    -            position=position,
    -        ),
    -    )
    +              
    @app.command()
    +def history_deals(
    +    ctx: typer.Context,
    +    date_from: Annotated[
    +        datetime | None,
    +        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    +    ] = None,
    +    date_to: Annotated[
    +        datetime | None,
    +        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    +    ] = None,
    +    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    +    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    +    ticket: Annotated[int | None, typer.Option(help="Order ticket.")] = None,
    +    position: Annotated[int | None, typer.Option(help="Position ticket.")] = None,
    +) -> None:
    +    """Export historical deals."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.history_deals_get_as_df(
    +            date_from=date_from,
    +            date_to=date_to,
    +            group=group,
    +            symbol=symbol,
    +            ticket=ticket,
    +            position=position,
    +        ),
    +    )
     
    @@ -2375,61 +2573,92 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def history_orders(
    -    ctx: typer.Context,
    -    date_from: Annotated[
    -        datetime | None,
    -        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    -    ] = None,
    -    date_to: Annotated[
    -        datetime | None,
    -        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    -    ] = None,
    -    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    -    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    -    ticket: Annotated[int | None, typer.Option(help="Order ticket.")] = None,
    -    position: Annotated[int | None, typer.Option(help="Position ticket.")] = None,
    -) -> None:
    -    """Export historical orders."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.history_orders_get_as_df(
    -            date_from=date_from,
    -            date_to=date_to,
    -            group=group,
    -            symbol=symbol,
    -            ticket=ticket,
    -            position=position,
    -        ),
    -    )
    +              
    @app.command()
    +def history_orders(
    +    ctx: typer.Context,
    +    date_from: Annotated[
    +        datetime | None,
    +        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    +    ] = None,
    +    date_to: Annotated[
    +        datetime | None,
    +        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    +    ] = None,
    +    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    +    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    +    ticket: Annotated[int | None, typer.Option(help="Order ticket.")] = None,
    +    position: Annotated[int | None, typer.Option(help="Position ticket.")] = None,
    +) -> None:
    +    """Export historical orders."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.history_orders_get_as_df(
    +            date_from=date_from,
    +            date_to=date_to,
    +            group=group,
    +            symbol=symbol,
    +            ticket=ticket,
    +            position=position,
    +        ),
    +    )
    +
    + +
    + + + +
    + + +

    + last_error + + +

    +
    last_error(ctx: Context) -> None
    +
    + +
    + +

    Export the last error information.

    + + +
    + Source code in mt5cli/cli.py +
    @app.command()
    +def last_error(ctx: typer.Context) -> None:
    +    """Export the last error information."""
    +    _execute_export(ctx, lambda c: c.last_error_as_df())
     
    @@ -2454,11 +2683,234 @@
    Source code in mt5cli/cli.py -
    def main() -> None:
    -    """Run the mt5cli CLI."""
    -    app()
    +              
    def main() -> None:
    +    """Run the mt5cli CLI."""
    +    app()
    +
    + +
    + + + +
    + + +

    + market_book + + +

    +
    market_book(
    +    ctx: Context,
    +    symbol: Annotated[str, Option(help="Symbol name.")],
    +) -> None
    +
    + +
    + +

    Export market depth (order book) for a symbol.

    + + +
    + Source code in mt5cli/cli.py +
    @app.command()
    +def market_book(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +) -> None:
    +    """Export market depth (order book) for a symbol."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.market_book_get_as_df(symbol=symbol),
    +    )
    +
    +
    +
    + +
    + +
    + + +

    + order_check + + +

    +
    order_check(
    +    ctx: Context,
    +    request: Annotated[
    +        dict[str, Any],
    +        Option(
    +            click_type=REQUEST_TYPE,
    +            help=_REQUEST_OPTION_HELP,
    +        ),
    +    ],
    +) -> None
    +
    + +
    + +

    Check funds sufficiency for a trading operation.

    + + +
    + Source code in mt5cli/cli.py +
    @app.command()
    +def order_check(
    +    ctx: typer.Context,
    +    request: Annotated[
    +        dict[str, Any],
    +        typer.Option(click_type=REQUEST_TYPE, help=_REQUEST_OPTION_HELP),
    +    ],
    +) -> None:
    +    """Check funds sufficiency for a trading operation."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.order_check_as_df(request=request),
    +    )
    +
    +
    +
    + +
    + +
    + + +

    + order_send + + +

    +
    order_send(
    +    ctx: Context,
    +    request: Annotated[
    +        dict[str, Any],
    +        Option(
    +            click_type=REQUEST_TYPE,
    +            help=_REQUEST_OPTION_HELP,
    +        ),
    +    ],
    +    yes: Annotated[
    +        bool,
    +        Option(
    +            "--yes", help="Confirm the live trade request."
    +        ),
    +    ] = False,
    +) -> None
    +
    + +
    + +

    Send a trading operation request to the trade server.

    + + +

    Raises:

    + + + + + + + + + + + + + +
    TypeDescription
    + BadParameter + +
    +

    If --yes is not provided.

    +
    +
    + + +
    + Source code in mt5cli/cli.py +
    @app.command()
    +def order_send(
    +    ctx: typer.Context,
    +    request: Annotated[
    +        dict[str, Any],
    +        typer.Option(click_type=REQUEST_TYPE, help=_REQUEST_OPTION_HELP),
    +    ],
    +    yes: Annotated[
    +        bool,
    +        typer.Option("--yes", help="Confirm the live trade request."),
    +    ] = False,
    +) -> None:
    +    """Send a trading operation request to the trade server.
    +
    +    Raises:
    +        typer.BadParameter: If --yes is not provided.
    +    """
    +    if not yes:
    +        msg = "Pass --yes to send a live trade request."
    +        raise typer.BadParameter(msg, param_hint="--yes")
    +    _execute_export(
    +        ctx,
    +        lambda c: c.order_send_as_df(request=request),
    +    )
     
    @@ -2494,37 +2946,37 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def orders(
    -    ctx: typer.Context,
    -    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    -    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    -    ticket: Annotated[int | None, typer.Option(help="Ticket filter.")] = None,
    -) -> None:
    -    """Export active orders."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.orders_get_as_df(
    -            symbol=symbol,
    -            group=group,
    -            ticket=ticket,
    -        ),
    -    )
    +              
    @app.command()
    +def orders(
    +    ctx: typer.Context,
    +    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    +    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    +    ticket: Annotated[int | None, typer.Option(help="Ticket filter.")] = None,
    +) -> None:
    +    """Export active orders."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.orders_get_as_df(
    +            symbol=symbol,
    +            group=group,
    +            ticket=ticket,
    +        ),
    +    )
     
    @@ -2627,47 +3079,210 @@
    Source code in mt5cli/cli.py -
    def parse_datetime(value: str) -> datetime:
    -    """Parse an ISO 8601 datetime string to a timezone-aware datetime.
    -
    -    Args:
    -        value: ISO 8601 datetime string (e.g., '2024-01-01' or
    -            '2024-01-01T12:00:00+00:00').
    -
    -    Returns:
    -        Parsed datetime with UTC timezone if no timezone is specified.
    -
    -    Raises:
    -        ValueError: If the string cannot be parsed.
    -    """
    -    try:
    -        dt = datetime.fromisoformat(value)
    -    except ValueError:
    -        msg = f"Invalid datetime format: '{value}'. Use ISO 8601 format."
    -        raise ValueError(msg) from None
    -    if dt.tzinfo is None:
    -        dt = dt.replace(tzinfo=UTC)
    -    return dt
    +              
    def parse_datetime(value: str) -> datetime:
    +    """Parse an ISO 8601 datetime string to a timezone-aware datetime.
    +
    +    Args:
    +        value: ISO 8601 datetime string (e.g., '2024-01-01' or
    +            '2024-01-01T12:00:00+00:00').
    +
    +    Returns:
    +        Parsed datetime with UTC timezone if no timezone is specified.
    +
    +    Raises:
    +        ValueError: If the string cannot be parsed.
    +    """
    +    try:
    +        dt = datetime.fromisoformat(value)
    +    except ValueError:
    +        msg = f"Invalid datetime format: '{value}'. Use ISO 8601 format."
    +        raise ValueError(msg) from None
    +    if dt.tzinfo is None:
    +        dt = dt.replace(tzinfo=UTC)
    +    return dt
    +
    + +
    + + + +
    + + +

    + parse_request + + +

    +
    parse_request(value: str) -> dict[str, Any]
    +
    + +
    + +

    Parse a JSON-formatted order request string or file reference.

    + + +

    Parameters:

    + + + + + + + + + + + + + + + + + +
    NameTypeDescriptionDefault
    + value + + str + +
    +

    JSON object string, or '@path' to read JSON from a file.

    +
    +
    + required +
    + + +

    Returns:

    + + + + + + + + + + + + + +
    TypeDescription
    + dict[str, Any] + +
    +

    Parsed request dictionary.

    +
    +
    + + +

    Raises:

    + + + + + + + + + + + + + +
    TypeDescription
    + ValueError + +
    +

    If the request file cannot be read or the value is not a +JSON object.

    +
    +
    + + +
    + Source code in mt5cli/cli.py +
    def parse_request(value: str) -> dict[str, Any]:
    +    """Parse a JSON-formatted order request string or file reference.
    +
    +    Args:
    +        value: JSON object string, or '@path' to read JSON from a file.
    +
    +    Returns:
    +        Parsed request dictionary.
    +
    +    Raises:
    +        ValueError: If the request file cannot be read or the value is not a
    +            JSON object.
    +    """
    +    if value.startswith("@"):
    +        path = Path(value[1:])
    +        try:
    +            text = path.read_text(encoding="utf-8")
    +        except (OSError, UnicodeDecodeError) as exc:
    +            msg = f"Failed to read JSON request file '{path}': {exc}"
    +            raise ValueError(msg) from exc
    +    else:
    +        text = value
    +    try:
    +        parsed: object = json.loads(text)
    +    except json.JSONDecodeError as exc:
    +        msg = f"Invalid JSON request: {exc}"
    +        raise ValueError(msg) from exc
    +    if not _is_request_dict(parsed):
    +        msg = "Order request must be a JSON object."
    +        raise ValueError(msg)
    +    return parsed
     
    @@ -2769,47 +3384,47 @@
    Source code in mt5cli/cli.py -
    def parse_tick_flags(value: str) -> int:
    -    """Parse tick flags string or integer value.
    -
    -    Args:
    -        value: Tick flag name (ALL, INFO, TRADE) or integer value.
    -
    -    Returns:
    -        Integer tick flag value.
    -
    -    Raises:
    -        ValueError: If the flag is invalid.
    -    """
    -    upper = value.upper()
    -    if upper in TICK_FLAG_MAP:
    -        return TICK_FLAG_MAP[upper]
    -    try:
    -        return int(value)
    -    except ValueError:
    -        valid = ", ".join(TICK_FLAG_MAP)
    -        msg = f"Invalid tick flags: '{value}'. Use one of: {valid}, or an integer."
    -        raise ValueError(msg) from None
    +              
    def parse_tick_flags(value: str) -> int:
    +    """Parse tick flags string or integer value.
    +
    +    Args:
    +        value: Tick flag name (ALL, INFO, TRADE) or integer value.
    +
    +    Returns:
    +        Integer tick flag value.
    +
    +    Raises:
    +        ValueError: If the flag is invalid.
    +    """
    +    upper = value.upper()
    +    if upper in TICK_FLAG_MAP:
    +        return TICK_FLAG_MAP[upper]
    +    try:
    +        return int(value)
    +    except ValueError:
    +        valid = ", ".join(TICK_FLAG_MAP)
    +        msg = f"Invalid tick flags: '{value}'. Use one of: {valid}, or an integer."
    +        raise ValueError(msg) from None
     
    @@ -2911,47 +3526,47 @@
    Source code in mt5cli/cli.py -
    def parse_timeframe(value: str) -> int:
    -    """Parse a timeframe string or integer value.
    -
    -    Args:
    -        value: Timeframe name (e.g., 'M1', 'H1', 'D1') or integer value.
    -
    -    Returns:
    -        Integer timeframe value.
    -
    -    Raises:
    -        ValueError: If the timeframe is invalid.
    -    """
    -    upper = value.upper()
    -    if upper in TIMEFRAME_MAP:
    -        return TIMEFRAME_MAP[upper]
    -    try:
    -        return int(value)
    -    except ValueError:
    -        valid = ", ".join(TIMEFRAME_MAP)
    -        msg = f"Invalid timeframe: '{value}'. Use one of: {valid}, or an integer."
    -        raise ValueError(msg) from None
    +              
    def parse_timeframe(value: str) -> int:
    +    """Parse a timeframe string or integer value.
    +
    +    Args:
    +        value: Timeframe name (e.g., 'M1', 'H1', 'D1') or integer value.
    +
    +    Returns:
    +        Integer timeframe value.
    +
    +    Raises:
    +        ValueError: If the timeframe is invalid.
    +    """
    +    upper = value.upper()
    +    if upper in TIMEFRAME_MAP:
    +        return TIMEFRAME_MAP[upper]
    +    try:
    +        return int(value)
    +    except ValueError:
    +        valid = ", ".join(TIMEFRAME_MAP)
    +        msg = f"Invalid timeframe: '{value}'. Use one of: {valid}, or an integer."
    +        raise ValueError(msg) from None
     
    @@ -2987,37 +3602,37 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def positions(
    -    ctx: typer.Context,
    -    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    -    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    -    ticket: Annotated[int | None, typer.Option(help="Ticket filter.")] = None,
    -) -> None:
    -    """Export open positions."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.positions_get_as_df(
    -            symbol=symbol,
    -            group=group,
    -            ticket=ticket,
    -        ),
    -    )
    +              
    @app.command()
    +def positions(
    +    ctx: typer.Context,
    +    symbol: Annotated[str | None, typer.Option(help="Symbol filter.")] = None,
    +    group: Annotated[str | None, typer.Option(help="Group filter.")] = None,
    +    ticket: Annotated[int | None, typer.Option(help="Ticket filter.")] = None,
    +) -> None:
    +    """Export open positions."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.positions_get_as_df(
    +            symbol=symbol,
    +            group=group,
    +            ticket=ticket,
    +        ),
    +    )
     
    @@ -3072,65 +3687,65 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def rates_from(
    -    ctx: typer.Context,
    -    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    -    timeframe: Annotated[
    -        int,
    -        typer.Option(
    -            click_type=TIMEFRAME_TYPE,
    -            help="Timeframe (e.g., M1, H1, D1, or integer).",
    -        ),
    -    ],
    -    date_from: Annotated[
    -        datetime,
    -        typer.Option(
    -            click_type=DATETIME_TYPE,
    -            help="Start date in ISO 8601 format.",
    -        ),
    -    ],
    -    count: Annotated[int, typer.Option(help="Number of records.")],
    -) -> None:
    -    """Export rates from a start date."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.copy_rates_from_as_df(
    -            symbol=symbol,
    -            timeframe=timeframe,
    -            date_from=date_from,
    -            count=count,
    -        ),
    -    )
    +              
    @app.command()
    +def rates_from(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +    timeframe: Annotated[
    +        int,
    +        typer.Option(
    +            click_type=TIMEFRAME_TYPE,
    +            help="Timeframe (e.g., M1, H1, D1, or integer).",
    +        ),
    +    ],
    +    date_from: Annotated[
    +        datetime,
    +        typer.Option(
    +            click_type=DATETIME_TYPE,
    +            help="Start date in ISO 8601 format.",
    +        ),
    +    ],
    +    count: Annotated[int, typer.Option(help="Number of records.")],
    +) -> None:
    +    """Export rates from a start date."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.copy_rates_from_as_df(
    +            symbol=symbol,
    +            timeframe=timeframe,
    +            date_from=date_from,
    +            count=count,
    +        ),
    +    )
     
    @@ -3176,53 +3791,53 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def rates_from_pos(
    -    ctx: typer.Context,
    -    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    -    timeframe: Annotated[
    -        int,
    -        typer.Option(
    -            click_type=TIMEFRAME_TYPE,
    -            help="Timeframe.",
    -        ),
    -    ],
    -    start_pos: Annotated[int, typer.Option(help="Start position (0 = current bar).")],
    -    count: Annotated[int, typer.Option(help="Number of records.")],
    -) -> None:
    -    """Export rates from a start position."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.copy_rates_from_pos_as_df(
    -            symbol=symbol,
    -            timeframe=timeframe,
    -            start_pos=start_pos,
    -            count=count,
    -        ),
    -    )
    +              
    @app.command()
    +def rates_from_pos(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +    timeframe: Annotated[
    +        int,
    +        typer.Option(
    +            click_type=TIMEFRAME_TYPE,
    +            help="Timeframe.",
    +        ),
    +    ],
    +    start_pos: Annotated[int, typer.Option(help="Start position (0 = current bar).")],
    +    count: Annotated[int, typer.Option(help="Number of records.")],
    +) -> None:
    +    """Export rates from a start position."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.copy_rates_from_pos_as_df(
    +            symbol=symbol,
    +            timeframe=timeframe,
    +            start_pos=start_pos,
    +            count=count,
    +        ),
    +    )
     
    @@ -3281,65 +3896,65 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def rates_range(
    -    ctx: typer.Context,
    -    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    -    timeframe: Annotated[
    -        int,
    -        typer.Option(
    -            click_type=TIMEFRAME_TYPE,
    -            help="Timeframe.",
    -        ),
    -    ],
    -    date_from: Annotated[
    -        datetime,
    -        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    -    ],
    -    date_to: Annotated[
    -        datetime,
    -        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    -    ],
    -) -> None:
    -    """Export rates for a date range."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.copy_rates_range_as_df(
    -            symbol=symbol,
    -            timeframe=timeframe,
    -            date_from=date_from,
    -            date_to=date_to,
    -        ),
    -    )
    +              
    @app.command()
    +def rates_range(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +    timeframe: Annotated[
    +        int,
    +        typer.Option(
    +            click_type=TIMEFRAME_TYPE,
    +            help="Timeframe.",
    +        ),
    +    ],
    +    date_from: Annotated[
    +        datetime,
    +        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    +    ],
    +    date_to: Annotated[
    +        datetime,
    +        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    +    ],
    +) -> None:
    +    """Export rates for a date range."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.copy_rates_range_as_df(
    +            symbol=symbol,
    +            timeframe=timeframe,
    +            date_from=date_from,
    +            date_to=date_to,
    +        ),
    +    )
     
    @@ -3367,25 +3982,71 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def symbol_info(
    -    ctx: typer.Context,
    -    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    -) -> None:
    -    """Export symbol details."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.symbol_info_as_df(symbol=symbol),
    -    )
    +              
    @app.command()
    +def symbol_info(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +) -> None:
    +    """Export symbol details."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.symbol_info_as_df(symbol=symbol),
    +    )
    +
    + +
    + + + +
    + + +

    + symbol_info_tick + + +

    +
    symbol_info_tick(
    +    ctx: Context,
    +    symbol: Annotated[str, Option(help="Symbol name.")],
    +) -> None
    +
    + +
    + +

    Export the last tick for a symbol.

    + + +
    + Source code in mt5cli/cli.py +
    @app.command()
    +def symbol_info_tick(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +) -> None:
    +    """Export the last tick for a symbol."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.symbol_info_tick_as_df(symbol=symbol),
    +    )
     
    @@ -3416,31 +4077,31 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def symbols(
    -    ctx: typer.Context,
    -    group: Annotated[
    -        str | None,
    -        typer.Option(help="Symbol group filter (e.g., *USD*)."),
    -    ] = None,
    -) -> None:
    -    """Export symbol list."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.symbols_get_as_df(group=group),
    -    )
    +              
    @app.command()
    +def symbols(
    +    ctx: typer.Context,
    +    group: Annotated[
    +        str | None,
    +        typer.Option(help="Symbol group filter (e.g., *USD*)."),
    +    ] = None,
    +) -> None:
    +    """Export symbol list."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.symbols_get_as_df(group=group),
    +    )
     
    @@ -3465,13 +4126,13 @@
    Source code in mt5cli/cli.py -
    @app.command()
    -def terminal_info(ctx: typer.Context) -> None:
    -    """Export terminal information."""
    -    _execute_export(ctx, lambda c: c.terminal_info_as_df())
    +              
    @app.command()
    +def terminal_info(ctx: typer.Context) -> None:
    +    """Export terminal information."""
    +    _execute_export(ctx, lambda c: c.terminal_info_as_df())
     
    @@ -3523,59 +4184,59 @@
    Source code in mt5cli/cli.py -
    + + + + + + + +
    @app.command()
    -def ticks_from(
    -    ctx: typer.Context,
    -    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    -    date_from: Annotated[
    -        datetime,
    -        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    -    ],
    -    count: Annotated[int, typer.Option(help="Number of ticks.")],
    -    flags: Annotated[
    -        int,
    -        typer.Option(
    -            click_type=TICK_FLAGS_TYPE,
    -            help="Tick flags (ALL, INFO, TRADE, or integer).",
    -        ),
    -    ],
    -) -> None:
    -    """Export ticks from a start date."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.copy_ticks_from_as_df(
    -            symbol=symbol,
    -            date_from=date_from,
    -            count=count,
    -            flags=flags,
    -        ),
    -    )
    +              
    @app.command()
    +def ticks_from(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +    date_from: Annotated[
    +        datetime,
    +        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    +    ],
    +    count: Annotated[int, typer.Option(help="Number of ticks.")],
    +    flags: Annotated[
    +        int,
    +        typer.Option(
    +            click_type=TICK_FLAGS_TYPE,
    +            help="Tick flags (ALL, INFO, TRADE, or integer).",
    +        ),
    +    ],
    +) -> None:
    +    """Export ticks from a start date."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.copy_ticks_from_as_df(
    +            symbol=symbol,
    +            date_from=date_from,
    +            count=count,
    +            flags=flags,
    +        ),
    +    )
     
    @@ -3634,59 +4295,90 @@
    Source code in mt5cli/cli.py -
    + + + + + + + + @@ -871,6 +879,14 @@ + + + + + + + +
    @app.command()
    -def ticks_range(
    -    ctx: typer.Context,
    -    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    -    date_from: Annotated[
    -        datetime,
    -        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    -    ],
    -    date_to: Annotated[
    -        datetime,
    -        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    -    ],
    -    flags: Annotated[
    -        int,
    -        typer.Option(click_type=TICK_FLAGS_TYPE, help="Tick flags."),
    -    ],
    -) -> None:
    -    """Export ticks for a date range."""
    -    _execute_export(
    -        ctx,
    -        lambda c: c.copy_ticks_range_as_df(
    -            symbol=symbol,
    -            date_from=date_from,
    -            date_to=date_to,
    -            flags=flags,
    -        ),
    -    )
    +              
    @app.command()
    +def ticks_range(
    +    ctx: typer.Context,
    +    symbol: Annotated[str, typer.Option(help="Symbol name.")],
    +    date_from: Annotated[
    +        datetime,
    +        typer.Option(click_type=DATETIME_TYPE, help="Start date."),
    +    ],
    +    date_to: Annotated[
    +        datetime,
    +        typer.Option(click_type=DATETIME_TYPE, help="End date."),
    +    ],
    +    flags: Annotated[
    +        int,
    +        typer.Option(click_type=TICK_FLAGS_TYPE, help="Tick flags."),
    +    ],
    +) -> None:
    +    """Export ticks for a date range."""
    +    _execute_export(
    +        ctx,
    +        lambda c: c.copy_ticks_range_as_df(
    +            symbol=symbol,
    +            date_from=date_from,
    +            date_to=date_to,
    +            flags=flags,
    +        ),
    +    )
    +
    + +
    + + + +
    + + +

    + version + + +

    +
    version(ctx: Context) -> None
    +
    + +
    + +

    Export MetaTrader5 version information.

    + + +
    + Source code in mt5cli/cli.py +
    @app.command()
    +def version(ctx: typer.Context) -> None:
    +    """Export MetaTrader5 version information."""
    +    _execute_export(ctx, lambda c: c.version_as_df())
     
    diff --git a/index.html b/index.html index 096b3f4..cef917c 100644 --- a/index.html +++ b/index.html @@ -864,6 +864,14 @@
    Export terminal information
    versionExport MetaTrader 5 version information
    last-errorExport the last error information
    symbols Export symbol list
    symbol-info Export symbol details
    symbol-info-tickExport the last tick for a symbol
    market-bookExport market depth (order book)

    Trading

    @@ -898,8 +914,17 @@
    history-deals Export historical deals
    order-checkCheck funds sufficiency for a trade request
    order-sendSend a trade request to the trade server (--yes required)
    +

    Use order-check to validate a request payload before running order-send --yes.

    Global Options

    diff --git a/objects.inv b/objects.inv index e66f7a1f395b7c3045ce4fd1881bd2b58a8142f0..03e1c4750294cda389e67871f993dfb8a86e74e9 100644 GIT binary patch delta 428 zcmV;d0aO0>1Fi&+jDM6(PuoBchVT4}NbMCPsCwzm6bD7k2Q@~hr`56^n{B)vGdqr& zf6p4EfJBLA4!&6L^X_~H{_Z-TrEfOue*~<@4rb>wJNUEo@9fLh+386*XtJxkDyqe* zFx8)%Vj^nG_K1Fo?Gkp-O;Xp{7zNtws<^zno(RiK5}+u{O@FBY7VG&&qrcC~^PT8VL;Y79D6ptZ*Y<~WAE6f)*L~GL10`1gJaVi21?)z{{|#B zlXF8hfDn81k$;i)rUu(ZC4*E0Nujh7Y=8(!3Sip;391#W?}eVh(iYe}AZ~@kOOD1p zg3}QZ`dR}>%b3vg;M^}G=xD7 znDmwkBHOppJmNk)V5d018CRe?>xs3l7L3TUdeOJna*vb&!j#EUom Wrw8<4bM!|3-{}K#dh!eq8x{aJWYR|f delta 372 zcmV-)0gL{w1os1wjDM3)Ps1<_#qawRmEgKgfVglgteqLb8LmTl@#&tMdom)blppct|D&4Z1^|3xQwO~HEQB{Ql@3TN?G~3 zO+8U_wjz$qJK$>b-t$bwCU0G zm}#pxQbPaM$CcX$mWV%`?m`*E?XCw5#oSH`gc|}@<`0i7TPBMq>Yj`QTP0hPewAiL zGAv@Kp4bqtD&2R;MAv99Z~Cr6G0gf5Vhq8!280S(Gj0gM8NQ6R$h>o7xdI~gE*xrm zU^Q^*0vT;b3<-2(P&4h@L?W3>)ph&j(PD$8&^GRG+Moymf(?f{?c`+6gbA zRa9>P^d#vp5peju5O89S^GDpD<`vM}Qjp^u=EP=uckw SXmj?6|9AR>Oef#O?2rbGrnO`M diff --git a/search/search_index.json b/search/search_index.json index d9d5eb7..b37532c 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"],"fields":{"title":{"boost":1000.0},"text":{"boost":1.0},"tags":{"boost":1000000.0}}},"docs":[{"location":"","title":"mt5cli","text":"

    Command-line tool for MetaTrader 5 data export.

    "},{"location":"#overview","title":"Overview","text":"

    mt5cli is a CLI application that exports MetaTrader 5 trading data to multiple file formats. It is built on top of pdmt5, a pandas-based data handler for MetaTrader 5.

    "},{"location":"#features","title":"Features","text":"
    • Multi-format export: CSV, JSON, Parquet, and SQLite3 output formats
    • Auto-detection: Format detection from file extensions
    • Comprehensive data access: Rates, ticks, account info, symbols, orders, positions, and trading history
    • Flexible timeframes: Named timeframes (M1, H1, D1, etc.) and numeric values
    • Connection management: Optional credentials, server, and timeout configuration
    "},{"location":"#installation","title":"Installation","text":"
    pip install mt5cli\n
    "},{"location":"#quick-start","title":"Quick Start","text":"
    # Export account information to CSV\nmt5cli -o account.csv account-info\n\n# Export EURUSD M1 rates to Parquet\nmt5cli -o rates.parquet rates-from --symbol EURUSD --timeframe M1 \\\n  --date-from 2024-01-01 --count 1000\n\n# Export ticks to JSON\nmt5cli -o ticks.json ticks-from --symbol EURUSD \\\n  --date-from 2024-01-01 --count 500 --flags ALL\n\n# Export symbols to SQLite3 with custom table name\nmt5cli -o data.db --table symbols symbols --group \"*USD*\"\n\n# Export with connection credentials\nmt5cli --login 12345 --password mypass --server MyBroker-Demo \\\n  -o positions.csv positions\n
    "},{"location":"#commands","title":"Commands","text":""},{"location":"#rates","title":"Rates","text":"Command Description rates-from Export rates from a start date rates-from-pos Export rates from a start position rates-range Export rates for a date range"},{"location":"#ticks","title":"Ticks","text":"Command Description ticks-from Export ticks from a start date ticks-range Export ticks for a date range"},{"location":"#information","title":"Information","text":"Command Description account-info Export account information terminal-info Export terminal information symbols Export symbol list symbol-info Export symbol details"},{"location":"#trading","title":"Trading","text":"Command Description orders Export active orders positions Export open positions history-orders Export historical orders history-deals Export historical deals"},{"location":"#global-options","title":"Global Options","text":"Option Description -o, --output Output file path (required) -f, --format Output format (auto-detected from extension if omitted) --table Table name for SQLite3 output (default: \"data\") --login Trading account login --password Trading account password --server Trading server name --path Path to MetaTrader5 terminal EXE file --timeout Connection timeout in milliseconds --log-level Logging level (DEBUG, INFO, WARNING, ERROR)"},{"location":"#requirements","title":"Requirements","text":"
    • Python 3.11+
    • Windows OS (MetaTrader 5 requirement)
    • MetaTrader 5 platform
    "},{"location":"#api-reference","title":"API Reference","text":"

    Browse the API documentation for detailed module information:

    • CLI Module - CLI application with export commands and utility functions
    "},{"location":"#development","title":"Development","text":"

    This project follows strict code quality standards:

    • Type hints required (strict mode)
    • Comprehensive linting with Ruff
    • Test coverage tracking
    • Google-style docstrings
    "},{"location":"#license","title":"License","text":"

    MIT License - see LICENSE file for details.

    "},{"location":"api/","title":"API Reference","text":"

    This section contains the complete API documentation for mt5cli.

    "},{"location":"api/#modules","title":"Modules","text":"

    The mt5cli package consists of the following modules:

    "},{"location":"api/#cli","title":"CLI","text":"

    Command-line interface module providing typer-based commands for exporting MetaTrader 5 data to CSV, JSON, Parquet, and SQLite3 formats.

    "},{"location":"api/#architecture-overview","title":"Architecture Overview","text":"

    The package follows a simple architecture built on top of pdmt5:

    1. CLI Layer (cli.py): Typer application with subcommands for each data type, custom Click parameter types for datetime/timeframe/tick flags parsing, and format detection/export utilities.
    2. Data Layer (via pdmt5): Uses Mt5DataClient and Mt5Config from the pdmt5 package for all MetaTrader 5 data access.
    "},{"location":"api/#usage-guidelines","title":"Usage Guidelines","text":"

    All modules follow these conventions:

    • Type Safety: All functions include comprehensive type hints
    • Error Handling: User-friendly error messages via typer
    • Documentation: Google-style docstrings with examples
    • Validation: Custom Click parameter types for input validation
    "},{"location":"api/#quick-start","title":"Quick Start","text":"
    # Export account information to CSV\nmt5cli -o account.csv account-info\n\n# Export EURUSD H1 rates to Parquet\nmt5cli -o rates.parquet rates-from --symbol EURUSD --timeframe H1 \\\n  --date-from 2024-01-01 --count 1000\n\n# Export ticks to JSON\nmt5cli -o ticks.json ticks-from --symbol EURUSD \\\n  --date-from 2024-01-01 --count 500 --flags ALL\n\n# Export to SQLite3 with custom table name\nmt5cli -o data.db --table symbols symbols --group \"*USD*\"\n
    "},{"location":"api/#python-api","title":"Python API","text":"
    from mt5cli import detect_format, export_dataframe\nimport pandas as pd\n\n# Detect output format from file extension\nfmt = detect_format(Path(\"output.parquet\"))  # Returns \"parquet\"\n\n# Export a DataFrame\ndf = pd.DataFrame({\"symbol\": [\"EURUSD\"], \"bid\": [1.1234]})\nexport_dataframe(df, Path(\"output.csv\"), \"csv\")\n
    "},{"location":"api/#examples","title":"Examples","text":"

    See individual module pages for detailed usage examples and code samples.

    "},{"location":"api/cli/","title":"CLI Module","text":""},{"location":"api/cli/#mt5cli.cli","title":"mt5cli.cli","text":"

    Command-line interface for MetaTrader 5 data export.

    "},{"location":"api/cli/#mt5cli.cli.DATETIME_TYPE","title":"DATETIME_TYPE module-attribute","text":"
    DATETIME_TYPE = _DateTimeType()\n
    "},{"location":"api/cli/#mt5cli.cli.TICK_FLAGS_TYPE","title":"TICK_FLAGS_TYPE module-attribute","text":"
    TICK_FLAGS_TYPE = _TickFlagsType()\n
    "},{"location":"api/cli/#mt5cli.cli.TICK_FLAG_MAP","title":"TICK_FLAG_MAP module-attribute","text":"
    TICK_FLAG_MAP: dict[str, int] = {\n    \"ALL\": 1,\n    \"INFO\": 2,\n    \"TRADE\": 4,\n}\n
    "},{"location":"api/cli/#mt5cli.cli.TIMEFRAME_MAP","title":"TIMEFRAME_MAP module-attribute","text":"
    TIMEFRAME_MAP: dict[str, int] = {\n    \"M1\": 1,\n    \"M2\": 2,\n    \"M3\": 3,\n    \"M4\": 4,\n    \"M5\": 5,\n    \"M6\": 6,\n    \"M10\": 10,\n    \"M12\": 12,\n    \"M15\": 15,\n    \"M20\": 20,\n    \"M30\": 30,\n    \"H1\": 16385,\n    \"H2\": 16386,\n    \"H3\": 16387,\n    \"H4\": 16388,\n    \"H6\": 16390,\n    \"H8\": 16392,\n    \"H12\": 16396,\n    \"D1\": 16408,\n    \"W1\": 32769,\n    \"MN1\": 49153,\n}\n
    "},{"location":"api/cli/#mt5cli.cli.TIMEFRAME_TYPE","title":"TIMEFRAME_TYPE module-attribute","text":"
    TIMEFRAME_TYPE = _TimeframeType()\n
    "},{"location":"api/cli/#mt5cli.cli.app","title":"app module-attribute","text":"
    app = Typer(\n    name=\"mt5cli\",\n    help=\"Export MetaTrader5 data to CSV, JSON, Parquet, or SQLite3.\",\n)\n
    "},{"location":"api/cli/#mt5cli.cli.logger","title":"logger module-attribute","text":"
    logger = getLogger(__name__)\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel","title":"LogLevel","text":"

    Bases: StrEnum

    Logging verbosity levels.

    "},{"location":"api/cli/#mt5cli.cli.LogLevel.DEBUG","title":"DEBUG class-attribute instance-attribute","text":"
    DEBUG = 'DEBUG'\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel.ERROR","title":"ERROR class-attribute instance-attribute","text":"
    ERROR = 'ERROR'\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel.INFO","title":"INFO class-attribute instance-attribute","text":"
    INFO = 'INFO'\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel.WARNING","title":"WARNING class-attribute instance-attribute","text":"
    WARNING = 'WARNING'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat","title":"OutputFormat","text":"

    Bases: StrEnum

    Supported output file formats.

    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.csv","title":"csv class-attribute instance-attribute","text":"
    csv = 'csv'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.json","title":"json class-attribute instance-attribute","text":"
    json = 'json'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.parquet","title":"parquet class-attribute instance-attribute","text":"
    parquet = 'parquet'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.sqlite3","title":"sqlite3 class-attribute instance-attribute","text":"
    sqlite3 = 'sqlite3'\n
    "},{"location":"api/cli/#mt5cli.cli.account_info","title":"account_info","text":"
    account_info(ctx: Context) -> None\n

    Export account information.

    Source code in mt5cli/cli.py
    @app.command()\ndef account_info(ctx: typer.Context) -> None:\n    \"\"\"Export account information.\"\"\"\n    _execute_export(ctx, lambda c: c.account_info_as_df())\n
    "},{"location":"api/cli/#mt5cli.cli.detect_format","title":"detect_format","text":"
    detect_format(\n    output_path: Path, explicit_format: str | None = None\n) -> str\n

    Detect the output format from a file extension or explicit format string.

    Parameters:

    Name Type Description Default output_path Path

    Path to the output file.

    required explicit_format str | None

    Explicitly specified format, if any.

    None

    Returns:

    Type Description str

    The detected format string.

    Raises:

    Type Description ValueError

    If the format cannot be determined.

    Source code in mt5cli/cli.py
    def detect_format(\n    output_path: Path,\n    explicit_format: str | None = None,\n) -> str:\n    \"\"\"Detect the output format from a file extension or explicit format string.\n\n    Args:\n        output_path: Path to the output file.\n        explicit_format: Explicitly specified format, if any.\n\n    Returns:\n        The detected format string.\n\n    Raises:\n        ValueError: If the format cannot be determined.\n    \"\"\"\n    if explicit_format is not None:\n        return explicit_format\n    suffix = output_path.suffix.lower()\n    if suffix in _FORMAT_EXTENSIONS:\n        return _FORMAT_EXTENSIONS[suffix]\n    msg = (\n        f\"Cannot detect format from extension '{suffix}'.\"\n        \" Use --format to specify the output format.\"\n    )\n    raise ValueError(msg)\n
    "},{"location":"api/cli/#mt5cli.cli.export_dataframe","title":"export_dataframe","text":"
    export_dataframe(\n    df: DataFrame,\n    output_path: Path,\n    output_format: str,\n    table_name: str = \"data\",\n) -> None\n

    Export a pandas DataFrame to the specified file format.

    Parameters:

    Name Type Description Default df DataFrame

    DataFrame to export.

    required output_path Path

    Path to the output file.

    required output_format str

    Output format (csv, json, parquet, or sqlite3).

    required table_name str

    Table name for SQLite3 output.

    'data'

    Raises:

    Type Description ValueError

    If the output format is not supported.

    Source code in mt5cli/cli.py
    def export_dataframe(\n    df: pd.DataFrame,\n    output_path: Path,\n    output_format: str,\n    table_name: str = \"data\",\n) -> None:\n    \"\"\"Export a pandas DataFrame to the specified file format.\n\n    Args:\n        df: DataFrame to export.\n        output_path: Path to the output file.\n        output_format: Output format (csv, json, parquet, or sqlite3).\n        table_name: Table name for SQLite3 output.\n\n    Raises:\n        ValueError: If the output format is not supported.\n    \"\"\"\n    if output_format == \"csv\":\n        df.to_csv(output_path, index=False)\n    elif output_format == \"json\":\n        df.to_json(\n            output_path,\n            orient=\"records\",\n            date_format=\"iso\",\n            indent=2,\n        )\n    elif output_format == \"parquet\":\n        df.to_parquet(output_path, index=False)\n    elif output_format == \"sqlite3\":\n        with sqlite3.connect(output_path) as conn:\n            df.to_sql(  # type: ignore[reportUnknownMemberType]\n                table_name,\n                conn,\n                if_exists=\"replace\",\n                index=False,\n            )\n    else:\n        msg = f\"Unsupported output format: {output_format}\"\n        raise ValueError(msg)\n
    "},{"location":"api/cli/#mt5cli.cli.history_deals","title":"history_deals","text":"
    history_deals(\n    ctx: Context,\n    date_from: Annotated[\n        datetime | None,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Order ticket.\")\n    ] = None,\n    position: Annotated[\n        int | None, Option(help=\"Position ticket.\")\n    ] = None,\n) -> None\n

    Export historical deals.

    Source code in mt5cli/cli.py
    @app.command()\ndef history_deals(\n    ctx: typer.Context,\n    date_from: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Order ticket.\")] = None,\n    position: Annotated[int | None, typer.Option(help=\"Position ticket.\")] = None,\n) -> None:\n    \"\"\"Export historical deals.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.history_deals_get_as_df(\n            date_from=date_from,\n            date_to=date_to,\n            group=group,\n            symbol=symbol,\n            ticket=ticket,\n            position=position,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.history_orders","title":"history_orders","text":"
    history_orders(\n    ctx: Context,\n    date_from: Annotated[\n        datetime | None,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Order ticket.\")\n    ] = None,\n    position: Annotated[\n        int | None, Option(help=\"Position ticket.\")\n    ] = None,\n) -> None\n

    Export historical orders.

    Source code in mt5cli/cli.py
    @app.command()\ndef history_orders(\n    ctx: typer.Context,\n    date_from: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Order ticket.\")] = None,\n    position: Annotated[int | None, typer.Option(help=\"Position ticket.\")] = None,\n) -> None:\n    \"\"\"Export historical orders.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.history_orders_get_as_df(\n            date_from=date_from,\n            date_to=date_to,\n            group=group,\n            symbol=symbol,\n            ticket=ticket,\n            position=position,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.main","title":"main","text":"
    main() -> None\n

    Run the mt5cli CLI.

    Source code in mt5cli/cli.py
    def main() -> None:\n    \"\"\"Run the mt5cli CLI.\"\"\"\n    app()\n
    "},{"location":"api/cli/#mt5cli.cli.orders","title":"orders","text":"
    orders(\n    ctx: Context,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Ticket filter.\")\n    ] = None,\n) -> None\n

    Export active orders.

    Source code in mt5cli/cli.py
    @app.command()\ndef orders(\n    ctx: typer.Context,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Ticket filter.\")] = None,\n) -> None:\n    \"\"\"Export active orders.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.orders_get_as_df(\n            symbol=symbol,\n            group=group,\n            ticket=ticket,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.parse_datetime","title":"parse_datetime","text":"
    parse_datetime(value: str) -> datetime\n

    Parse an ISO 8601 datetime string to a timezone-aware datetime.

    Parameters:

    Name Type Description Default value str

    ISO 8601 datetime string (e.g., '2024-01-01' or '2024-01-01T12:00:00+00:00').

    required

    Returns:

    Type Description datetime

    Parsed datetime with UTC timezone if no timezone is specified.

    Raises:

    Type Description ValueError

    If the string cannot be parsed.

    Source code in mt5cli/cli.py
    def parse_datetime(value: str) -> datetime:\n    \"\"\"Parse an ISO 8601 datetime string to a timezone-aware datetime.\n\n    Args:\n        value: ISO 8601 datetime string (e.g., '2024-01-01' or\n            '2024-01-01T12:00:00+00:00').\n\n    Returns:\n        Parsed datetime with UTC timezone if no timezone is specified.\n\n    Raises:\n        ValueError: If the string cannot be parsed.\n    \"\"\"\n    try:\n        dt = datetime.fromisoformat(value)\n    except ValueError:\n        msg = f\"Invalid datetime format: '{value}'. Use ISO 8601 format.\"\n        raise ValueError(msg) from None\n    if dt.tzinfo is None:\n        dt = dt.replace(tzinfo=UTC)\n    return dt\n
    "},{"location":"api/cli/#mt5cli.cli.parse_tick_flags","title":"parse_tick_flags","text":"
    parse_tick_flags(value: str) -> int\n

    Parse tick flags string or integer value.

    Parameters:

    Name Type Description Default value str

    Tick flag name (ALL, INFO, TRADE) or integer value.

    required

    Returns:

    Type Description int

    Integer tick flag value.

    Raises:

    Type Description ValueError

    If the flag is invalid.

    Source code in mt5cli/cli.py
    def parse_tick_flags(value: str) -> int:\n    \"\"\"Parse tick flags string or integer value.\n\n    Args:\n        value: Tick flag name (ALL, INFO, TRADE) or integer value.\n\n    Returns:\n        Integer tick flag value.\n\n    Raises:\n        ValueError: If the flag is invalid.\n    \"\"\"\n    upper = value.upper()\n    if upper in TICK_FLAG_MAP:\n        return TICK_FLAG_MAP[upper]\n    try:\n        return int(value)\n    except ValueError:\n        valid = \", \".join(TICK_FLAG_MAP)\n        msg = f\"Invalid tick flags: '{value}'. Use one of: {valid}, or an integer.\"\n        raise ValueError(msg) from None\n
    "},{"location":"api/cli/#mt5cli.cli.parse_timeframe","title":"parse_timeframe","text":"
    parse_timeframe(value: str) -> int\n

    Parse a timeframe string or integer value.

    Parameters:

    Name Type Description Default value str

    Timeframe name (e.g., 'M1', 'H1', 'D1') or integer value.

    required

    Returns:

    Type Description int

    Integer timeframe value.

    Raises:

    Type Description ValueError

    If the timeframe is invalid.

    Source code in mt5cli/cli.py
    def parse_timeframe(value: str) -> int:\n    \"\"\"Parse a timeframe string or integer value.\n\n    Args:\n        value: Timeframe name (e.g., 'M1', 'H1', 'D1') or integer value.\n\n    Returns:\n        Integer timeframe value.\n\n    Raises:\n        ValueError: If the timeframe is invalid.\n    \"\"\"\n    upper = value.upper()\n    if upper in TIMEFRAME_MAP:\n        return TIMEFRAME_MAP[upper]\n    try:\n        return int(value)\n    except ValueError:\n        valid = \", \".join(TIMEFRAME_MAP)\n        msg = f\"Invalid timeframe: '{value}'. Use one of: {valid}, or an integer.\"\n        raise ValueError(msg) from None\n
    "},{"location":"api/cli/#mt5cli.cli.positions","title":"positions","text":"
    positions(\n    ctx: Context,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Ticket filter.\")\n    ] = None,\n) -> None\n

    Export open positions.

    Source code in mt5cli/cli.py
    @app.command()\ndef positions(\n    ctx: typer.Context,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Ticket filter.\")] = None,\n) -> None:\n    \"\"\"Export open positions.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.positions_get_as_df(\n            symbol=symbol,\n            group=group,\n            ticket=ticket,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.rates_from","title":"rates_from","text":"
    rates_from(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe (e.g., M1, H1, D1, or integer).\",\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE,\n            help=\"Start date in ISO 8601 format.\",\n        ),\n    ],\n    count: Annotated[\n        int, Option(help=\"Number of records.\")\n    ],\n) -> None\n

    Export rates from a start date.

    Source code in mt5cli/cli.py
    @app.command()\ndef rates_from(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        typer.Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe (e.g., M1, H1, D1, or integer).\",\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        typer.Option(\n            click_type=DATETIME_TYPE,\n            help=\"Start date in ISO 8601 format.\",\n        ),\n    ],\n    count: Annotated[int, typer.Option(help=\"Number of records.\")],\n) -> None:\n    \"\"\"Export rates from a start date.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_rates_from_as_df(\n            symbol=symbol,\n            timeframe=timeframe,\n            date_from=date_from,\n            count=count,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.rates_from_pos","title":"rates_from_pos","text":"
    rates_from_pos(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        Option(\n            click_type=TIMEFRAME_TYPE, help=\"Timeframe.\"\n        ),\n    ],\n    start_pos: Annotated[\n        int,\n        Option(help=\"Start position (0 = current bar).\"),\n    ],\n    count: Annotated[\n        int, Option(help=\"Number of records.\")\n    ],\n) -> None\n

    Export rates from a start position.

    Source code in mt5cli/cli.py
    @app.command()\ndef rates_from_pos(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        typer.Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe.\",\n        ),\n    ],\n    start_pos: Annotated[int, typer.Option(help=\"Start position (0 = current bar).\")],\n    count: Annotated[int, typer.Option(help=\"Number of records.\")],\n) -> None:\n    \"\"\"Export rates from a start position.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_rates_from_pos_as_df(\n            symbol=symbol,\n            timeframe=timeframe,\n            start_pos=start_pos,\n            count=count,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.rates_range","title":"rates_range","text":"
    rates_range(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        Option(\n            click_type=TIMEFRAME_TYPE, help=\"Timeframe.\"\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ],\n    date_to: Annotated[\n        datetime,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n) -> None\n

    Export rates for a date range.

    Source code in mt5cli/cli.py
    @app.command()\ndef rates_range(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        typer.Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe.\",\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ],\n    date_to: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n) -> None:\n    \"\"\"Export rates for a date range.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_rates_range_as_df(\n            symbol=symbol,\n            timeframe=timeframe,\n            date_from=date_from,\n            date_to=date_to,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.symbol_info","title":"symbol_info","text":"
    symbol_info(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n) -> None\n

    Export symbol details.

    Source code in mt5cli/cli.py
    @app.command()\ndef symbol_info(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n) -> None:\n    \"\"\"Export symbol details.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.symbol_info_as_df(symbol=symbol),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.symbols","title":"symbols","text":"
    symbols(\n    ctx: Context,\n    group: Annotated[\n        str | None,\n        Option(help=\"Symbol group filter (e.g., *USD*).\"),\n    ] = None,\n) -> None\n

    Export symbol list.

    Source code in mt5cli/cli.py
    @app.command()\ndef symbols(\n    ctx: typer.Context,\n    group: Annotated[\n        str | None,\n        typer.Option(help=\"Symbol group filter (e.g., *USD*).\"),\n    ] = None,\n) -> None:\n    \"\"\"Export symbol list.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.symbols_get_as_df(group=group),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.terminal_info","title":"terminal_info","text":"
    terminal_info(ctx: Context) -> None\n

    Export terminal information.

    Source code in mt5cli/cli.py
    @app.command()\ndef terminal_info(ctx: typer.Context) -> None:\n    \"\"\"Export terminal information.\"\"\"\n    _execute_export(ctx, lambda c: c.terminal_info_as_df())\n
    "},{"location":"api/cli/#mt5cli.cli.ticks_from","title":"ticks_from","text":"
    ticks_from(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ],\n    count: Annotated[int, Option(help=\"Number of ticks.\")],\n    flags: Annotated[\n        int,\n        Option(\n            click_type=TICK_FLAGS_TYPE,\n            help=\"Tick flags (ALL, INFO, TRADE, or integer).\",\n        ),\n    ],\n) -> None\n

    Export ticks from a start date.

    Source code in mt5cli/cli.py
    @app.command()\ndef ticks_from(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ],\n    count: Annotated[int, typer.Option(help=\"Number of ticks.\")],\n    flags: Annotated[\n        int,\n        typer.Option(\n            click_type=TICK_FLAGS_TYPE,\n            help=\"Tick flags (ALL, INFO, TRADE, or integer).\",\n        ),\n    ],\n) -> None:\n    \"\"\"Export ticks from a start date.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_ticks_from_as_df(\n            symbol=symbol,\n            date_from=date_from,\n            count=count,\n            flags=flags,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.ticks_range","title":"ticks_range","text":"
    ticks_range(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ],\n    date_to: Annotated[\n        datetime,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n    flags: Annotated[\n        int,\n        Option(\n            click_type=TICK_FLAGS_TYPE, help=\"Tick flags.\"\n        ),\n    ],\n) -> None\n

    Export ticks for a date range.

    Source code in mt5cli/cli.py
    @app.command()\ndef ticks_range(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ],\n    date_to: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n    flags: Annotated[\n        int,\n        typer.Option(click_type=TICK_FLAGS_TYPE, help=\"Tick flags.\"),\n    ],\n) -> None:\n    \"\"\"Export ticks for a date range.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_ticks_range_as_df(\n            symbol=symbol,\n            date_from=date_from,\n            date_to=date_to,\n            flags=flags,\n        ),\n    )\n
    "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"],"fields":{"title":{"boost":1000.0},"text":{"boost":1.0},"tags":{"boost":1000000.0}}},"docs":[{"location":"","title":"mt5cli","text":"

    Command-line tool for MetaTrader 5 data export.

    "},{"location":"#overview","title":"Overview","text":"

    mt5cli is a CLI application that exports MetaTrader 5 trading data to multiple file formats. It is built on top of pdmt5, a pandas-based data handler for MetaTrader 5.

    "},{"location":"#features","title":"Features","text":"
    • Multi-format export: CSV, JSON, Parquet, and SQLite3 output formats
    • Auto-detection: Format detection from file extensions
    • Comprehensive data access: Rates, ticks, account info, symbols, orders, positions, and trading history
    • Flexible timeframes: Named timeframes (M1, H1, D1, etc.) and numeric values
    • Connection management: Optional credentials, server, and timeout configuration
    "},{"location":"#installation","title":"Installation","text":"
    pip install mt5cli\n
    "},{"location":"#quick-start","title":"Quick Start","text":"
    # Export account information to CSV\nmt5cli -o account.csv account-info\n\n# Export EURUSD M1 rates to Parquet\nmt5cli -o rates.parquet rates-from --symbol EURUSD --timeframe M1 \\\n  --date-from 2024-01-01 --count 1000\n\n# Export ticks to JSON\nmt5cli -o ticks.json ticks-from --symbol EURUSD \\\n  --date-from 2024-01-01 --count 500 --flags ALL\n\n# Export symbols to SQLite3 with custom table name\nmt5cli -o data.db --table symbols symbols --group \"*USD*\"\n\n# Export with connection credentials\nmt5cli --login 12345 --password mypass --server MyBroker-Demo \\\n  -o positions.csv positions\n
    "},{"location":"#commands","title":"Commands","text":""},{"location":"#rates","title":"Rates","text":"Command Description rates-from Export rates from a start date rates-from-pos Export rates from a start position rates-range Export rates for a date range"},{"location":"#ticks","title":"Ticks","text":"Command Description ticks-from Export ticks from a start date ticks-range Export ticks for a date range"},{"location":"#information","title":"Information","text":"Command Description account-info Export account information terminal-info Export terminal information version Export MetaTrader 5 version information last-error Export the last error information symbols Export symbol list symbol-info Export symbol details symbol-info-tick Export the last tick for a symbol market-book Export market depth (order book)"},{"location":"#trading","title":"Trading","text":"Command Description orders Export active orders positions Export open positions history-orders Export historical orders history-deals Export historical deals order-check Check funds sufficiency for a trade request order-send Send a trade request to the trade server (--yes required)

    Use order-check to validate a request payload before running order-send --yes.

    "},{"location":"#global-options","title":"Global Options","text":"Option Description -o, --output Output file path (required) -f, --format Output format (auto-detected from extension if omitted) --table Table name for SQLite3 output (default: \"data\") --login Trading account login --password Trading account password --server Trading server name --path Path to MetaTrader5 terminal EXE file --timeout Connection timeout in milliseconds --log-level Logging level (DEBUG, INFO, WARNING, ERROR)"},{"location":"#requirements","title":"Requirements","text":"
    • Python 3.11+
    • Windows OS (MetaTrader 5 requirement)
    • MetaTrader 5 platform
    "},{"location":"#api-reference","title":"API Reference","text":"

    Browse the API documentation for detailed module information:

    • CLI Module - CLI application with export commands and utility functions
    "},{"location":"#development","title":"Development","text":"

    This project follows strict code quality standards:

    • Type hints required (strict mode)
    • Comprehensive linting with Ruff
    • Test coverage tracking
    • Google-style docstrings
    "},{"location":"#license","title":"License","text":"

    MIT License - see LICENSE file for details.

    "},{"location":"api/","title":"API Reference","text":"

    This section contains the complete API documentation for mt5cli.

    "},{"location":"api/#modules","title":"Modules","text":"

    The mt5cli package consists of the following modules:

    "},{"location":"api/#cli","title":"CLI","text":"

    Command-line interface module providing typer-based commands for exporting MetaTrader 5 data to CSV, JSON, Parquet, and SQLite3 formats.

    "},{"location":"api/#architecture-overview","title":"Architecture Overview","text":"

    The package follows a simple architecture built on top of pdmt5:

    1. CLI Layer (cli.py): Typer application with subcommands for each data type, custom Click parameter types for datetime/timeframe/tick flags parsing, and format detection/export utilities.
    2. Data Layer (via pdmt5): Uses Mt5DataClient and Mt5Config from the pdmt5 package for all MetaTrader 5 data access.
    "},{"location":"api/#usage-guidelines","title":"Usage Guidelines","text":"

    All modules follow these conventions:

    • Type Safety: All functions include comprehensive type hints
    • Error Handling: User-friendly error messages via typer
    • Documentation: Google-style docstrings with examples
    • Validation: Custom Click parameter types for input validation
    "},{"location":"api/#quick-start","title":"Quick Start","text":"
    # Export account information to CSV\nmt5cli -o account.csv account-info\n\n# Export EURUSD H1 rates to Parquet\nmt5cli -o rates.parquet rates-from --symbol EURUSD --timeframe H1 \\\n  --date-from 2024-01-01 --count 1000\n\n# Export ticks to JSON\nmt5cli -o ticks.json ticks-from --symbol EURUSD \\\n  --date-from 2024-01-01 --count 500 --flags ALL\n\n# Export to SQLite3 with custom table name\nmt5cli -o data.db --table symbols symbols --group \"*USD*\"\n
    "},{"location":"api/#python-api","title":"Python API","text":"
    from mt5cli import detect_format, export_dataframe\nimport pandas as pd\n\n# Detect output format from file extension\nfmt = detect_format(Path(\"output.parquet\"))  # Returns \"parquet\"\n\n# Export a DataFrame\ndf = pd.DataFrame({\"symbol\": [\"EURUSD\"], \"bid\": [1.1234]})\nexport_dataframe(df, Path(\"output.csv\"), \"csv\")\n
    "},{"location":"api/#examples","title":"Examples","text":"

    See individual module pages for detailed usage examples and code samples.

    "},{"location":"api/cli/","title":"CLI Module","text":""},{"location":"api/cli/#mt5cli.cli","title":"mt5cli.cli","text":"

    Command-line interface for MetaTrader 5 data export.

    "},{"location":"api/cli/#mt5cli.cli.DATETIME_TYPE","title":"DATETIME_TYPE module-attribute","text":"
    DATETIME_TYPE = _DateTimeType()\n
    "},{"location":"api/cli/#mt5cli.cli.REQUEST_TYPE","title":"REQUEST_TYPE module-attribute","text":"
    REQUEST_TYPE = _RequestType()\n
    "},{"location":"api/cli/#mt5cli.cli.TICK_FLAGS_TYPE","title":"TICK_FLAGS_TYPE module-attribute","text":"
    TICK_FLAGS_TYPE = _TickFlagsType()\n
    "},{"location":"api/cli/#mt5cli.cli.TICK_FLAG_MAP","title":"TICK_FLAG_MAP module-attribute","text":"
    TICK_FLAG_MAP: dict[str, int] = {\n    \"ALL\": 1,\n    \"INFO\": 2,\n    \"TRADE\": 4,\n}\n
    "},{"location":"api/cli/#mt5cli.cli.TIMEFRAME_MAP","title":"TIMEFRAME_MAP module-attribute","text":"
    TIMEFRAME_MAP: dict[str, int] = {\n    \"M1\": 1,\n    \"M2\": 2,\n    \"M3\": 3,\n    \"M4\": 4,\n    \"M5\": 5,\n    \"M6\": 6,\n    \"M10\": 10,\n    \"M12\": 12,\n    \"M15\": 15,\n    \"M20\": 20,\n    \"M30\": 30,\n    \"H1\": 16385,\n    \"H2\": 16386,\n    \"H3\": 16387,\n    \"H4\": 16388,\n    \"H6\": 16390,\n    \"H8\": 16392,\n    \"H12\": 16396,\n    \"D1\": 16408,\n    \"W1\": 32769,\n    \"MN1\": 49153,\n}\n
    "},{"location":"api/cli/#mt5cli.cli.TIMEFRAME_TYPE","title":"TIMEFRAME_TYPE module-attribute","text":"
    TIMEFRAME_TYPE = _TimeframeType()\n
    "},{"location":"api/cli/#mt5cli.cli.app","title":"app module-attribute","text":"
    app = Typer(\n    name=\"mt5cli\",\n    help=\"Export MetaTrader5 data to CSV, JSON, Parquet, or SQLite3.\",\n)\n
    "},{"location":"api/cli/#mt5cli.cli.logger","title":"logger module-attribute","text":"
    logger = getLogger(__name__)\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel","title":"LogLevel","text":"

    Bases: StrEnum

    Logging verbosity levels.

    "},{"location":"api/cli/#mt5cli.cli.LogLevel.DEBUG","title":"DEBUG class-attribute instance-attribute","text":"
    DEBUG = 'DEBUG'\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel.ERROR","title":"ERROR class-attribute instance-attribute","text":"
    ERROR = 'ERROR'\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel.INFO","title":"INFO class-attribute instance-attribute","text":"
    INFO = 'INFO'\n
    "},{"location":"api/cli/#mt5cli.cli.LogLevel.WARNING","title":"WARNING class-attribute instance-attribute","text":"
    WARNING = 'WARNING'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat","title":"OutputFormat","text":"

    Bases: StrEnum

    Supported output file formats.

    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.csv","title":"csv class-attribute instance-attribute","text":"
    csv = 'csv'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.json","title":"json class-attribute instance-attribute","text":"
    json = 'json'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.parquet","title":"parquet class-attribute instance-attribute","text":"
    parquet = 'parquet'\n
    "},{"location":"api/cli/#mt5cli.cli.OutputFormat.sqlite3","title":"sqlite3 class-attribute instance-attribute","text":"
    sqlite3 = 'sqlite3'\n
    "},{"location":"api/cli/#mt5cli.cli.account_info","title":"account_info","text":"
    account_info(ctx: Context) -> None\n

    Export account information.

    Source code in mt5cli/cli.py
    @app.command()\ndef account_info(ctx: typer.Context) -> None:\n    \"\"\"Export account information.\"\"\"\n    _execute_export(ctx, lambda c: c.account_info_as_df())\n
    "},{"location":"api/cli/#mt5cli.cli.detect_format","title":"detect_format","text":"
    detect_format(\n    output_path: Path, explicit_format: str | None = None\n) -> str\n

    Detect the output format from a file extension or explicit format string.

    Parameters:

    Name Type Description Default output_path Path

    Path to the output file.

    required explicit_format str | None

    Explicitly specified format, if any.

    None

    Returns:

    Type Description str

    The detected format string.

    Raises:

    Type Description ValueError

    If the format cannot be determined.

    Source code in mt5cli/cli.py
    def detect_format(\n    output_path: Path,\n    explicit_format: str | None = None,\n) -> str:\n    \"\"\"Detect the output format from a file extension or explicit format string.\n\n    Args:\n        output_path: Path to the output file.\n        explicit_format: Explicitly specified format, if any.\n\n    Returns:\n        The detected format string.\n\n    Raises:\n        ValueError: If the format cannot be determined.\n    \"\"\"\n    if explicit_format is not None:\n        return explicit_format\n    suffix = output_path.suffix.lower()\n    if suffix in _FORMAT_EXTENSIONS:\n        return _FORMAT_EXTENSIONS[suffix]\n    msg = (\n        f\"Cannot detect format from extension '{suffix}'.\"\n        \" Use --format to specify the output format.\"\n    )\n    raise ValueError(msg)\n
    "},{"location":"api/cli/#mt5cli.cli.export_dataframe","title":"export_dataframe","text":"
    export_dataframe(\n    df: DataFrame,\n    output_path: Path,\n    output_format: str,\n    table_name: str = \"data\",\n) -> None\n

    Export a pandas DataFrame to the specified file format.

    Parameters:

    Name Type Description Default df DataFrame

    DataFrame to export.

    required output_path Path

    Path to the output file.

    required output_format str

    Output format (csv, json, parquet, or sqlite3).

    required table_name str

    Table name for SQLite3 output.

    'data'

    Raises:

    Type Description ValueError

    If the output format is not supported.

    Source code in mt5cli/cli.py
    def export_dataframe(\n    df: pd.DataFrame,\n    output_path: Path,\n    output_format: str,\n    table_name: str = \"data\",\n) -> None:\n    \"\"\"Export a pandas DataFrame to the specified file format.\n\n    Args:\n        df: DataFrame to export.\n        output_path: Path to the output file.\n        output_format: Output format (csv, json, parquet, or sqlite3).\n        table_name: Table name for SQLite3 output.\n\n    Raises:\n        ValueError: If the output format is not supported.\n    \"\"\"\n    if output_format == \"csv\":\n        df.to_csv(output_path, index=False)\n    elif output_format == \"json\":\n        df.to_json(\n            output_path,\n            orient=\"records\",\n            date_format=\"iso\",\n            indent=2,\n        )\n    elif output_format == \"parquet\":\n        df.to_parquet(output_path, index=False)\n    elif output_format == \"sqlite3\":\n        with sqlite3.connect(output_path) as conn:\n            df.to_sql(  # type: ignore[reportUnknownMemberType]\n                table_name,\n                conn,\n                if_exists=\"replace\",\n                index=False,\n            )\n    else:\n        msg = f\"Unsupported output format: {output_format}\"\n        raise ValueError(msg)\n
    "},{"location":"api/cli/#mt5cli.cli.history_deals","title":"history_deals","text":"
    history_deals(\n    ctx: Context,\n    date_from: Annotated[\n        datetime | None,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Order ticket.\")\n    ] = None,\n    position: Annotated[\n        int | None, Option(help=\"Position ticket.\")\n    ] = None,\n) -> None\n

    Export historical deals.

    Source code in mt5cli/cli.py
    @app.command()\ndef history_deals(\n    ctx: typer.Context,\n    date_from: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Order ticket.\")] = None,\n    position: Annotated[int | None, typer.Option(help=\"Position ticket.\")] = None,\n) -> None:\n    \"\"\"Export historical deals.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.history_deals_get_as_df(\n            date_from=date_from,\n            date_to=date_to,\n            group=group,\n            symbol=symbol,\n            ticket=ticket,\n            position=position,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.history_orders","title":"history_orders","text":"
    history_orders(\n    ctx: Context,\n    date_from: Annotated[\n        datetime | None,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Order ticket.\")\n    ] = None,\n    position: Annotated[\n        int | None, Option(help=\"Position ticket.\")\n    ] = None,\n) -> None\n

    Export historical orders.

    Source code in mt5cli/cli.py
    @app.command()\ndef history_orders(\n    ctx: typer.Context,\n    date_from: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ] = None,\n    date_to: Annotated[\n        datetime | None,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Order ticket.\")] = None,\n    position: Annotated[int | None, typer.Option(help=\"Position ticket.\")] = None,\n) -> None:\n    \"\"\"Export historical orders.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.history_orders_get_as_df(\n            date_from=date_from,\n            date_to=date_to,\n            group=group,\n            symbol=symbol,\n            ticket=ticket,\n            position=position,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.last_error","title":"last_error","text":"
    last_error(ctx: Context) -> None\n

    Export the last error information.

    Source code in mt5cli/cli.py
    @app.command()\ndef last_error(ctx: typer.Context) -> None:\n    \"\"\"Export the last error information.\"\"\"\n    _execute_export(ctx, lambda c: c.last_error_as_df())\n
    "},{"location":"api/cli/#mt5cli.cli.main","title":"main","text":"
    main() -> None\n

    Run the mt5cli CLI.

    Source code in mt5cli/cli.py
    def main() -> None:\n    \"\"\"Run the mt5cli CLI.\"\"\"\n    app()\n
    "},{"location":"api/cli/#mt5cli.cli.market_book","title":"market_book","text":"
    market_book(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n) -> None\n

    Export market depth (order book) for a symbol.

    Source code in mt5cli/cli.py
    @app.command()\ndef market_book(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n) -> None:\n    \"\"\"Export market depth (order book) for a symbol.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.market_book_get_as_df(symbol=symbol),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.order_check","title":"order_check","text":"
    order_check(\n    ctx: Context,\n    request: Annotated[\n        dict[str, Any],\n        Option(\n            click_type=REQUEST_TYPE,\n            help=_REQUEST_OPTION_HELP,\n        ),\n    ],\n) -> None\n

    Check funds sufficiency for a trading operation.

    Source code in mt5cli/cli.py
    @app.command()\ndef order_check(\n    ctx: typer.Context,\n    request: Annotated[\n        dict[str, Any],\n        typer.Option(click_type=REQUEST_TYPE, help=_REQUEST_OPTION_HELP),\n    ],\n) -> None:\n    \"\"\"Check funds sufficiency for a trading operation.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.order_check_as_df(request=request),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.order_send","title":"order_send","text":"
    order_send(\n    ctx: Context,\n    request: Annotated[\n        dict[str, Any],\n        Option(\n            click_type=REQUEST_TYPE,\n            help=_REQUEST_OPTION_HELP,\n        ),\n    ],\n    yes: Annotated[\n        bool,\n        Option(\n            \"--yes\", help=\"Confirm the live trade request.\"\n        ),\n    ] = False,\n) -> None\n

    Send a trading operation request to the trade server.

    Raises:

    Type Description BadParameter

    If --yes is not provided.

    Source code in mt5cli/cli.py
    @app.command()\ndef order_send(\n    ctx: typer.Context,\n    request: Annotated[\n        dict[str, Any],\n        typer.Option(click_type=REQUEST_TYPE, help=_REQUEST_OPTION_HELP),\n    ],\n    yes: Annotated[\n        bool,\n        typer.Option(\"--yes\", help=\"Confirm the live trade request.\"),\n    ] = False,\n) -> None:\n    \"\"\"Send a trading operation request to the trade server.\n\n    Raises:\n        typer.BadParameter: If --yes is not provided.\n    \"\"\"\n    if not yes:\n        msg = \"Pass --yes to send a live trade request.\"\n        raise typer.BadParameter(msg, param_hint=\"--yes\")\n    _execute_export(\n        ctx,\n        lambda c: c.order_send_as_df(request=request),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.orders","title":"orders","text":"
    orders(\n    ctx: Context,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Ticket filter.\")\n    ] = None,\n) -> None\n

    Export active orders.

    Source code in mt5cli/cli.py
    @app.command()\ndef orders(\n    ctx: typer.Context,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Ticket filter.\")] = None,\n) -> None:\n    \"\"\"Export active orders.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.orders_get_as_df(\n            symbol=symbol,\n            group=group,\n            ticket=ticket,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.parse_datetime","title":"parse_datetime","text":"
    parse_datetime(value: str) -> datetime\n

    Parse an ISO 8601 datetime string to a timezone-aware datetime.

    Parameters:

    Name Type Description Default value str

    ISO 8601 datetime string (e.g., '2024-01-01' or '2024-01-01T12:00:00+00:00').

    required

    Returns:

    Type Description datetime

    Parsed datetime with UTC timezone if no timezone is specified.

    Raises:

    Type Description ValueError

    If the string cannot be parsed.

    Source code in mt5cli/cli.py
    def parse_datetime(value: str) -> datetime:\n    \"\"\"Parse an ISO 8601 datetime string to a timezone-aware datetime.\n\n    Args:\n        value: ISO 8601 datetime string (e.g., '2024-01-01' or\n            '2024-01-01T12:00:00+00:00').\n\n    Returns:\n        Parsed datetime with UTC timezone if no timezone is specified.\n\n    Raises:\n        ValueError: If the string cannot be parsed.\n    \"\"\"\n    try:\n        dt = datetime.fromisoformat(value)\n    except ValueError:\n        msg = f\"Invalid datetime format: '{value}'. Use ISO 8601 format.\"\n        raise ValueError(msg) from None\n    if dt.tzinfo is None:\n        dt = dt.replace(tzinfo=UTC)\n    return dt\n
    "},{"location":"api/cli/#mt5cli.cli.parse_request","title":"parse_request","text":"
    parse_request(value: str) -> dict[str, Any]\n

    Parse a JSON-formatted order request string or file reference.

    Parameters:

    Name Type Description Default value str

    JSON object string, or '@path' to read JSON from a file.

    required

    Returns:

    Type Description dict[str, Any]

    Parsed request dictionary.

    Raises:

    Type Description ValueError

    If the request file cannot be read or the value is not a JSON object.

    Source code in mt5cli/cli.py
    def parse_request(value: str) -> dict[str, Any]:\n    \"\"\"Parse a JSON-formatted order request string or file reference.\n\n    Args:\n        value: JSON object string, or '@path' to read JSON from a file.\n\n    Returns:\n        Parsed request dictionary.\n\n    Raises:\n        ValueError: If the request file cannot be read or the value is not a\n            JSON object.\n    \"\"\"\n    if value.startswith(\"@\"):\n        path = Path(value[1:])\n        try:\n            text = path.read_text(encoding=\"utf-8\")\n        except (OSError, UnicodeDecodeError) as exc:\n            msg = f\"Failed to read JSON request file '{path}': {exc}\"\n            raise ValueError(msg) from exc\n    else:\n        text = value\n    try:\n        parsed: object = json.loads(text)\n    except json.JSONDecodeError as exc:\n        msg = f\"Invalid JSON request: {exc}\"\n        raise ValueError(msg) from exc\n    if not _is_request_dict(parsed):\n        msg = \"Order request must be a JSON object.\"\n        raise ValueError(msg)\n    return parsed\n
    "},{"location":"api/cli/#mt5cli.cli.parse_tick_flags","title":"parse_tick_flags","text":"
    parse_tick_flags(value: str) -> int\n

    Parse tick flags string or integer value.

    Parameters:

    Name Type Description Default value str

    Tick flag name (ALL, INFO, TRADE) or integer value.

    required

    Returns:

    Type Description int

    Integer tick flag value.

    Raises:

    Type Description ValueError

    If the flag is invalid.

    Source code in mt5cli/cli.py
    def parse_tick_flags(value: str) -> int:\n    \"\"\"Parse tick flags string or integer value.\n\n    Args:\n        value: Tick flag name (ALL, INFO, TRADE) or integer value.\n\n    Returns:\n        Integer tick flag value.\n\n    Raises:\n        ValueError: If the flag is invalid.\n    \"\"\"\n    upper = value.upper()\n    if upper in TICK_FLAG_MAP:\n        return TICK_FLAG_MAP[upper]\n    try:\n        return int(value)\n    except ValueError:\n        valid = \", \".join(TICK_FLAG_MAP)\n        msg = f\"Invalid tick flags: '{value}'. Use one of: {valid}, or an integer.\"\n        raise ValueError(msg) from None\n
    "},{"location":"api/cli/#mt5cli.cli.parse_timeframe","title":"parse_timeframe","text":"
    parse_timeframe(value: str) -> int\n

    Parse a timeframe string or integer value.

    Parameters:

    Name Type Description Default value str

    Timeframe name (e.g., 'M1', 'H1', 'D1') or integer value.

    required

    Returns:

    Type Description int

    Integer timeframe value.

    Raises:

    Type Description ValueError

    If the timeframe is invalid.

    Source code in mt5cli/cli.py
    def parse_timeframe(value: str) -> int:\n    \"\"\"Parse a timeframe string or integer value.\n\n    Args:\n        value: Timeframe name (e.g., 'M1', 'H1', 'D1') or integer value.\n\n    Returns:\n        Integer timeframe value.\n\n    Raises:\n        ValueError: If the timeframe is invalid.\n    \"\"\"\n    upper = value.upper()\n    if upper in TIMEFRAME_MAP:\n        return TIMEFRAME_MAP[upper]\n    try:\n        return int(value)\n    except ValueError:\n        valid = \", \".join(TIMEFRAME_MAP)\n        msg = f\"Invalid timeframe: '{value}'. Use one of: {valid}, or an integer.\"\n        raise ValueError(msg) from None\n
    "},{"location":"api/cli/#mt5cli.cli.positions","title":"positions","text":"
    positions(\n    ctx: Context,\n    symbol: Annotated[\n        str | None, Option(help=\"Symbol filter.\")\n    ] = None,\n    group: Annotated[\n        str | None, Option(help=\"Group filter.\")\n    ] = None,\n    ticket: Annotated[\n        int | None, Option(help=\"Ticket filter.\")\n    ] = None,\n) -> None\n

    Export open positions.

    Source code in mt5cli/cli.py
    @app.command()\ndef positions(\n    ctx: typer.Context,\n    symbol: Annotated[str | None, typer.Option(help=\"Symbol filter.\")] = None,\n    group: Annotated[str | None, typer.Option(help=\"Group filter.\")] = None,\n    ticket: Annotated[int | None, typer.Option(help=\"Ticket filter.\")] = None,\n) -> None:\n    \"\"\"Export open positions.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.positions_get_as_df(\n            symbol=symbol,\n            group=group,\n            ticket=ticket,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.rates_from","title":"rates_from","text":"
    rates_from(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe (e.g., M1, H1, D1, or integer).\",\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE,\n            help=\"Start date in ISO 8601 format.\",\n        ),\n    ],\n    count: Annotated[\n        int, Option(help=\"Number of records.\")\n    ],\n) -> None\n

    Export rates from a start date.

    Source code in mt5cli/cli.py
    @app.command()\ndef rates_from(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        typer.Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe (e.g., M1, H1, D1, or integer).\",\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        typer.Option(\n            click_type=DATETIME_TYPE,\n            help=\"Start date in ISO 8601 format.\",\n        ),\n    ],\n    count: Annotated[int, typer.Option(help=\"Number of records.\")],\n) -> None:\n    \"\"\"Export rates from a start date.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_rates_from_as_df(\n            symbol=symbol,\n            timeframe=timeframe,\n            date_from=date_from,\n            count=count,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.rates_from_pos","title":"rates_from_pos","text":"
    rates_from_pos(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        Option(\n            click_type=TIMEFRAME_TYPE, help=\"Timeframe.\"\n        ),\n    ],\n    start_pos: Annotated[\n        int,\n        Option(help=\"Start position (0 = current bar).\"),\n    ],\n    count: Annotated[\n        int, Option(help=\"Number of records.\")\n    ],\n) -> None\n

    Export rates from a start position.

    Source code in mt5cli/cli.py
    @app.command()\ndef rates_from_pos(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        typer.Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe.\",\n        ),\n    ],\n    start_pos: Annotated[int, typer.Option(help=\"Start position (0 = current bar).\")],\n    count: Annotated[int, typer.Option(help=\"Number of records.\")],\n) -> None:\n    \"\"\"Export rates from a start position.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_rates_from_pos_as_df(\n            symbol=symbol,\n            timeframe=timeframe,\n            start_pos=start_pos,\n            count=count,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.rates_range","title":"rates_range","text":"
    rates_range(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        Option(\n            click_type=TIMEFRAME_TYPE, help=\"Timeframe.\"\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ],\n    date_to: Annotated[\n        datetime,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n) -> None\n

    Export rates for a date range.

    Source code in mt5cli/cli.py
    @app.command()\ndef rates_range(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    timeframe: Annotated[\n        int,\n        typer.Option(\n            click_type=TIMEFRAME_TYPE,\n            help=\"Timeframe.\",\n        ),\n    ],\n    date_from: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ],\n    date_to: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n) -> None:\n    \"\"\"Export rates for a date range.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_rates_range_as_df(\n            symbol=symbol,\n            timeframe=timeframe,\n            date_from=date_from,\n            date_to=date_to,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.symbol_info","title":"symbol_info","text":"
    symbol_info(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n) -> None\n

    Export symbol details.

    Source code in mt5cli/cli.py
    @app.command()\ndef symbol_info(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n) -> None:\n    \"\"\"Export symbol details.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.symbol_info_as_df(symbol=symbol),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.symbol_info_tick","title":"symbol_info_tick","text":"
    symbol_info_tick(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n) -> None\n

    Export the last tick for a symbol.

    Source code in mt5cli/cli.py
    @app.command()\ndef symbol_info_tick(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n) -> None:\n    \"\"\"Export the last tick for a symbol.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.symbol_info_tick_as_df(symbol=symbol),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.symbols","title":"symbols","text":"
    symbols(\n    ctx: Context,\n    group: Annotated[\n        str | None,\n        Option(help=\"Symbol group filter (e.g., *USD*).\"),\n    ] = None,\n) -> None\n

    Export symbol list.

    Source code in mt5cli/cli.py
    @app.command()\ndef symbols(\n    ctx: typer.Context,\n    group: Annotated[\n        str | None,\n        typer.Option(help=\"Symbol group filter (e.g., *USD*).\"),\n    ] = None,\n) -> None:\n    \"\"\"Export symbol list.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.symbols_get_as_df(group=group),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.terminal_info","title":"terminal_info","text":"
    terminal_info(ctx: Context) -> None\n

    Export terminal information.

    Source code in mt5cli/cli.py
    @app.command()\ndef terminal_info(ctx: typer.Context) -> None:\n    \"\"\"Export terminal information.\"\"\"\n    _execute_export(ctx, lambda c: c.terminal_info_as_df())\n
    "},{"location":"api/cli/#mt5cli.cli.ticks_from","title":"ticks_from","text":"
    ticks_from(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ],\n    count: Annotated[int, Option(help=\"Number of ticks.\")],\n    flags: Annotated[\n        int,\n        Option(\n            click_type=TICK_FLAGS_TYPE,\n            help=\"Tick flags (ALL, INFO, TRADE, or integer).\",\n        ),\n    ],\n) -> None\n

    Export ticks from a start date.

    Source code in mt5cli/cli.py
    @app.command()\ndef ticks_from(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ],\n    count: Annotated[int, typer.Option(help=\"Number of ticks.\")],\n    flags: Annotated[\n        int,\n        typer.Option(\n            click_type=TICK_FLAGS_TYPE,\n            help=\"Tick flags (ALL, INFO, TRADE, or integer).\",\n        ),\n    ],\n) -> None:\n    \"\"\"Export ticks from a start date.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_ticks_from_as_df(\n            symbol=symbol,\n            date_from=date_from,\n            count=count,\n            flags=flags,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.ticks_range","title":"ticks_range","text":"
    ticks_range(\n    ctx: Context,\n    symbol: Annotated[str, Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        Option(\n            click_type=DATETIME_TYPE, help=\"Start date.\"\n        ),\n    ],\n    date_to: Annotated[\n        datetime,\n        Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n    flags: Annotated[\n        int,\n        Option(\n            click_type=TICK_FLAGS_TYPE, help=\"Tick flags.\"\n        ),\n    ],\n) -> None\n

    Export ticks for a date range.

    Source code in mt5cli/cli.py
    @app.command()\ndef ticks_range(\n    ctx: typer.Context,\n    symbol: Annotated[str, typer.Option(help=\"Symbol name.\")],\n    date_from: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"Start date.\"),\n    ],\n    date_to: Annotated[\n        datetime,\n        typer.Option(click_type=DATETIME_TYPE, help=\"End date.\"),\n    ],\n    flags: Annotated[\n        int,\n        typer.Option(click_type=TICK_FLAGS_TYPE, help=\"Tick flags.\"),\n    ],\n) -> None:\n    \"\"\"Export ticks for a date range.\"\"\"\n    _execute_export(\n        ctx,\n        lambda c: c.copy_ticks_range_as_df(\n            symbol=symbol,\n            date_from=date_from,\n            date_to=date_to,\n            flags=flags,\n        ),\n    )\n
    "},{"location":"api/cli/#mt5cli.cli.version","title":"version","text":"
    version(ctx: Context) -> None\n

    Export MetaTrader5 version information.

    Source code in mt5cli/cli.py
    @app.command()\ndef version(ctx: typer.Context) -> None:\n    \"\"\"Export MetaTrader5 version information.\"\"\"\n    _execute_export(ctx, lambda c: c.version_as_df())\n
    "}]} \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml index 5429635..47444b0 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,14 +2,14 @@ https://github.com/dceoy/mt5cli/ - 2026-04-25 + 2026-04-26 https://github.com/dceoy/mt5cli/api/ - 2026-04-25 + 2026-04-26 https://github.com/dceoy/mt5cli/api/cli/ - 2026-04-25 + 2026-04-26 \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index e7d31dcdd7ad05a051fa817b0c67bdc8d4ec4283..6979e36347faf15c478847abaffbfd23dc5216ea 100644 GIT binary patch delta 49 zcmV-10M7r+0n7mhABzYGfK~002OR+@ktKEz_R?tJFsVM5Dh$@wB1^M8k*gU9SR!D> H%mDxZzfTeV delta 49 zcmV-10M7r+0n7mhABzYG00iuj2OR;3ktKEza%nVhm{gxj6$a~Tk)_!_k*gU9aBUr( H%mDxZjJ*(=