Files
mt5cli/api/index.html
T
2026-06-18 10:12:55 +00:00

320 lines
16 KiB
HTML

<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="dceoy">
<link rel="canonical" href="https://github.com/dceoy/mt5cli/api/">
<link rel="shortcut icon" href="../img/favicon.ico">
<title>Overview - mt5cli API Documentation</title>
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/fontawesome.min.css" rel="stylesheet">
<link href="../css/brands.min.css" rel="stylesheet">
<link href="../css/solid.min.css" rel="stylesheet">
<link href="../css/v4-font-face.min.css" rel="stylesheet">
<link href="../css/base.css" rel="stylesheet">
<link id="hljs-light" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css" >
<link id="hljs-dark" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github-dark.min.css" disabled>
<link href="../assets/_mkdocstrings.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body>
<div class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="..">mt5cli API Documentation</a>
<!-- Expander button -->
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbar-collapse" aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Expanded navigation -->
<div id="navbar-collapse" class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li class="nav-item">
<a href=".." class="nav-link">Home</a>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle active" aria-current="page" role="button" data-bs-toggle="dropdown" aria-expanded="false">API Reference</a>
<ul class="dropdown-menu">
<li>
<a href="./" class="dropdown-item active" aria-current="page">Overview</a>
</li>
<li>
<a href="public-contract/" class="dropdown-item">Public API Contract</a>
</li>
<li>
<a href="client/" class="dropdown-item">Client</a>
</li>
<li>
<a href="schemas/" class="dropdown-item">Schemas</a>
</li>
<li>
<a href="storage/" class="dropdown-item">Storage</a>
</li>
<li>
<a href="converters/" class="dropdown-item">Converters</a>
</li>
<li>
<a href="exceptions/" class="dropdown-item">Exceptions</a>
</li>
<li>
<a href="cli/" class="dropdown-item">CLI</a>
</li>
<li>
<a href="sdk/" class="dropdown-item">SDK</a>
</li>
<li>
<a href="trading/" class="dropdown-item">Trading</a>
</li>
<li>
<a href="history/" class="dropdown-item">History Collection (SQLite)</a>
</li>
<li>
<a href="utils/" class="dropdown-item">Utils</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav ms-md-auto">
<li class="nav-item">
<a href="#" class="nav-link" data-bs-toggle="modal" data-bs-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
<li class="nav-item">
<a rel="prev" href=".." class="nav-link">
<i class="fa fa-arrow-left"></i> Previous
</a>
</li>
<li class="nav-item">
<a rel="next" href="public-contract/" class="nav-link">
Next <i class="fa fa-arrow-right"></i>
</a>
</li>
<li class="nav-item">
<a href="https://github.com/dceoy/mt5cli/edit/master/docs/api/index.md" class="nav-link">Edit on dceoy/mt5cli
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3"><div class="navbar-expand-md bs-sidebar hidden-print affix" role="complementary">
<div class="navbar-header">
<button type="button" class="navbar-toggler collapsed" data-bs-toggle="collapse" data-bs-target="#toc-collapse" title="Table of Contents">
<span class="fa fa-angle-down"></span>
</button>
</div>
<div id="toc-collapse" class="navbar-collapse collapse card bg-body-tertiary">
<ul class="nav flex-column">
<li class="nav-item" data-bs-level="1"><a href="#api-reference" class="nav-link">API Reference</a>
<ul class="nav flex-column">
<li class="nav-item" data-bs-level="2"><a href="#public-api-layers" class="nav-link">Public API layers</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-bs-level="2"><a href="#architecture-overview" class="nav-link">Architecture overview</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-bs-level="2"><a href="#quick-start" class="nav-link">Quick start</a>
<ul class="nav flex-column">
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div></div>
<div class="col-md-9" role="main">
<h1 id="api-reference">API Reference<a class="headerlink" href="#api-reference" title="Permanent link">&para;</a></h1>
<p>This section documents the mt5cli public Python API and CLI modules.</p>
<p>Start with the <a href="public-contract/">Public API Contract</a> for the stable
downstream SDK surface, CLI boundary, internal modules, and out-of-scope strategy
responsibilities.</p>
<h2 id="public-api-layers">Public API layers<a class="headerlink" href="#public-api-layers" title="Permanent link">&para;</a></h2>
<table>
<thead>
<tr>
<th>Module</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="public-contract/">Public API Contract</a></td>
<td>Stable downstream SDK exports, CLI boundary, and out-of-scope items</td>
</tr>
<tr>
<td><a href="client/">Client</a></td>
<td><code>MT5Client</code> session abstraction for data access and order primitives</td>
</tr>
<tr>
<td><a href="schemas/">Schemas</a></td>
<td>Canonical DataFrame contracts and normalization helpers</td>
</tr>
<tr>
<td><a href="storage/">Storage</a></td>
<td>CSV/JSON/Parquet/SQLite export and history collection helpers</td>
</tr>
<tr>
<td><a href="converters/">Converters</a></td>
<td>Symbol, timeframe, timezone, and date-range utilities</td>
</tr>
<tr>
<td><a href="exceptions/">Exceptions</a></td>
<td>Stable mt5cli exception types and MT5 error normalization</td>
</tr>
<tr>
<td><a href="sdk/">SDK</a></td>
<td>Module-level fetch helpers, multi-account collectors, incremental history</td>
</tr>
<tr>
<td><a href="trading/">Trading</a></td>
<td>Trading-capable sessions and operational helpers</td>
</tr>
<tr>
<td><a href="history/">History Collection (SQLite)</a></td>
<td>SQLite schema, incremental writes, dedup, and rate views</td>
</tr>
<tr>
<td><a href="cli/">CLI</a></td>
<td>Typer commands that delegate to the Python API</td>
</tr>
<tr>
<td><a href="utils/">Utils</a></td>
<td>Parsing helpers and Click parameter types</td>
</tr>
</tbody>
</table>
<h2 id="architecture-overview">Architecture overview<a class="headerlink" href="#architecture-overview" title="Permanent link">&para;</a></h2>
<div class="highlight"><pre><span></span><code><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a>flowchart TD
<a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> App[&quot;Downstream application&quot;] --&gt; Client[&quot;MT5Client&quot;]
<a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a> CLI[&quot;mt5cli CLI&quot;] --&gt; Client
<a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a> Client --&gt; SDK[&quot;sdk / pdmt5&quot;]
<a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a> Client --&gt; Schemas[&quot;schemas&quot;]
<a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a> Storage[&quot;storage&quot;] --&gt; History[&quot;history SQLite&quot;]
<a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a> Storage --&gt; Utils[&quot;utils export&quot;]
<a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a> SDK --&gt; PDMT5[&quot;pdmt5.Mt5DataClient&quot;]
</code></pre></div>
<p>Downstream packages should depend on the package root exports documented in the
<a href="public-contract/">Public API Contract</a> (<code>MT5Client</code>,
<code>DataKind</code>, <code>normalize_dataframe</code>, <code>collect_history</code>, <code>load_rate_data</code>,
<code>resolve_rate_view_name</code>, etc.) rather than private modules.</p>
<p><code>MT5Client.order_send()</code> is a live execution primitive that can place real trades. mt5cli exposes minimal execution helpers only; strategy logic, signals, backtests, and optimization remain out of scope and must be implemented downstream with explicit execution gating.</p>
<h2 id="quick-start">Quick start<a class="headerlink" href="#quick-start" title="Permanent link">&para;</a></h2>
<div class="highlight"><pre><span></span><code><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="kn">from</span><span class="w"> </span><span class="nn">mt5cli</span><span class="w"> </span><span class="kn">import</span> <span class="n">MT5Client</span><span class="p">,</span> <span class="n">build_config</span><span class="p">,</span> <span class="n">mt5_session</span>
<a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a>
<a id="__codelineno-1-3" name="__codelineno-1-3" href="#__codelineno-1-3"></a><span class="k">with</span> <span class="n">mt5_session</span><span class="p">(</span><span class="n">build_config</span><span class="p">(</span><span class="n">login</span><span class="o">=</span><span class="mi">12345</span><span class="p">))</span> <span class="k">as</span> <span class="n">client</span><span class="p">:</span>
<a id="__codelineno-1-4" name="__codelineno-1-4" href="#__codelineno-1-4"></a> <span class="n">rates</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">copy_rates_range</span><span class="p">(</span><span class="s2">&quot;EURUSD&quot;</span><span class="p">,</span> <span class="s2">&quot;H1&quot;</span><span class="p">,</span> <span class="s2">&quot;2024-01-01&quot;</span><span class="p">,</span> <span class="s2">&quot;2024-02-01&quot;</span><span class="p">)</span>
<a id="__codelineno-1-5" name="__codelineno-1-5" href="#__codelineno-1-5"></a> <span class="n">positions</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">positions</span><span class="p">()</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a>mt5cli<span class="w"> </span>-o<span class="w"> </span>account.csv<span class="w"> </span>account-info
<a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a>mt5cli<span class="w"> </span>-o<span class="w"> </span>rates.parquet<span class="w"> </span>rates-range<span class="w"> </span>--symbol<span class="w"> </span>EURUSD<span class="w"> </span>--timeframe<span class="w"> </span>H1<span class="w"> </span><span class="se">\</span>
<a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="w"> </span>--date-from<span class="w"> </span><span class="m">2024</span>-01-01<span class="w"> </span>--date-to<span class="w"> </span><span class="m">2024</span>-02-01
</code></pre></div>
<p>See individual module pages for detailed usage examples.</p></div>
</div>
</div>
<footer class="col-md-12">
<hr>
<p>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</p>
</footer>
<script src="../js/bootstrap.bundle.min.js"></script>
<script>
var base_url = "..",
shortcuts = {"help": 191, "next": 78, "previous": 80, "search": 83};
</script>
<script src="../js/base.js"></script>
<script src="../search/main.js"></script>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="searchModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="searchModalLabel">Search</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>From here you can search these documents. Enter your search terms below.</p>
<form>
<div class="form-group">
<input type="search" class="form-control" placeholder="Search..." id="mkdocs-search-query" title="Type search term here">
</div>
</form>
<div id="mkdocs-search-results" data-no-results-text="No results found"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div><div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="keyboardModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th style="width: 20%;">Keys</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td class="help shortcut"><kbd>?</kbd></td>
<td>Open this help</td>
</tr>
<tr>
<td class="next shortcut"><kbd>n</kbd></td>
<td>Next page</td>
</tr>
<tr>
<td class="prev shortcut"><kbd>p</kbd></td>
<td>Previous page</td>
</tr>
<tr>
<td class="search shortcut"><kbd>s</kbd></td>
<td>Search</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>