Skip to content

AKSIL05/metaapi-cloud-php-starterkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation

πŸš€ MetaTrader Cloud Engine – PHP SDK 2026

The Unofficial Yet Powerful Bridge Between MetaTrader 5 & Modern PHP Ecosystems

License: MIT PHP Version MetaApi Compatible Stability

Download


🌌 A New Horizon for Automated Trading Infrastructure

Imagine your PHP application not just running a scriptβ€”but orchestrating a global fleet of trading terminals, all without a traditional desktop environment. MetaTrader Cloud Engine transforms your Laravel, Symfony, or Yii project into a command-center for MetaTrader 5 terminals, hosted entirely in the cloud.

This is not a simple wrapper. It is an architectural decision: build trading systems that are event-driven, horizontally scalable, and language-agnostic on the frontend, while PHP handles the heavy logic behind the scenes. Think of it as a neural bridge between the rigid world of forex terminals and the flexible universe of modern web development.


🧭 Table of Contents


Core Architecture (Mermaid Diagram)

The system is designed as a three-layer onion architecture with a cloud-burst capability. The following diagram illustrates how a PHP application connects to MetaApi, which in turn provisions cloud MetaTrader instances.

graph TD
    A[Your PHP Application] --> B{MetaTrader Cloud Engine SDK}
    B -->|REST/WebSocket| C[MetaApi Cloud API]
    C --> D[(Provisioned MT5 Terminal)]
    D --> E[Market Execution Engine]
    D --> F[Historical Data Cache]
    C --> G[Account Manager Service]
    B --> H[Local Strategy Controller]
    H --> I[Signal Generator / ML Model]
    
    subgraph "SDK Internal Modules"
        B1[Connection Pooling]
        B2[Rate Limiter]
        B3[Event Aggregator]
    end
    
    B --> B1
    B --> B2
    B --> B3
Loading

The SDK maintains persistent connections to the cloud terminal via WebSocket, ensuring sub-second latency for trade commands while PHP handles the asynchronous orchestration.


⚑ Quick Integration – Profile Configuration

Every trading account setup begins with a Profile Configuration Array. This is your digital signature to the cloud MetaTrader environment. Below is a complete configuration example that includes risk parameters, server location preference, and terminal behavior.

// config/trading-profile.php (Laravel style)
return [
    'environment' => 'production',           // sandbox | production
    'metaapi'     => [
        'token'             => env('METAAPI_TOKEN'),
        'region'            => 'europe-west', // data residency preference
        'terminal_type'     => 'mt5-cloud',
        'connection_timeout'=> 30,            // seconds
        'enable_heartbeat'  => true,
    ],
    
    'risk_controls' => [
        'max_daily_drawdown'    => 0.05,      // 5% of equity
        'max_positions_per_symbol' => 3,
        'consecutive_loss_limit'=> 4,
        'cooldown_after_loss'   => 300,       // 5 minutes
    ],
    
    'execution' => [
        'fill_policy'           => 'ioc',     // fill or kill / immediate or cancel
        'slippage_pips'         => 2,
        'hedging_enabled'       => false,
        'strategy_mode'         => 'continuous',
    ],
    
    'logging'        => [
        'channel'   => 'cloud-terminal',
        'level'     => 'debug',
        'retention' => 14,                   // days
    ],
];

This configuration acts as a contract between your application and the cloud terminal. Any deviation in risk parameters triggers a soft-block by the SDK’s internal safety governor.


πŸ–₯️ Console Invocation Example

Once configured, launching a trading session is a single artisan command (or Symfony console command) away. Below demonstrates how you would deploy a strategy to the cloud using the built-in CLI tool.

# Deploy "TrendFollower2026" strategy to a provisioned cloud MetaTrader terminal
php artisan mtcloud:deploy TrendFollower2026 \
  --symbol=XAUUSD \
  --timeframe=H1 \
  --risk=0.02 \
  --dry-run=false \
  --verbose

Expected output during a successful deployment:

[2026-04-15 10:32:14] MTCLOUD.INFO: Connecting to MetaApi cloud node...  
[2026-04-15 10:32:16] MTCLOUD.INFO: Terminal provisioned in eu-west-2 region.  
[2026-04-15 10:32:17] MTCLOUD.INFO: Strategy "TrendFollower2026" attached to XAUUSD H1.  
[2026-04-15 10:32:18] MTCLOUD.INFO: Execution engine ready. Latency: 47ms.  

The console reporter includes real-time trade logs if streamed to STDOUT with the --verbose flag. This is particularly useful for debugging or live-monitoring from a CI/CD pipeline.


πŸ“¦ Feature List & Capabilities

# Feature Benefit
1 Cloud MetaTrader Provisioning No desktop app required; terminals spawn in data centers.
2 Persistent WebSocket Stream Real-time price ticks, order updates, and account events.
3 Multi-Terminal Management Manage 100+ cloud terminals from a single PHP instance.
4 Graceful Rate Limiting Avoid MetaApi throttling with adaptive backoff algorithms.
5 Audit Trail Logger Every trade decision is timestamped, signed, and stored.
6 Plugin-Based Strategy Loader Hot-swap trading strategies without rebooting the terminal.
7 Historical Backtester Bridge Feed cloud-harvested data into local PHPMD backtests.
8 Emergency Circuit Breaker Automatic shutdown if the system detects anomalies.
9 Symbol Group Management Batch operations on correlated instruments (e.g., all DXY pairs).
10 Webhook Integration Receive alerts and trigger actions from external systems.

πŸ—ΊοΈ OS Compatibility Matrix

The PHP SDK runs wherever PHP 8.x runs, but the cloud terminal control layer has specific dependency requirements. The following table details compatibility by operating system.

Operating System πŸ–₯️ Connection Stability Port Management Recommended Use
Linux (Ubuntu 22.04+) βœ… Excellent βœ… Native Production servers
macOS Ventura+ βœ… Good βœ… Via Homebrew Development & testing
Windows Server 2022 βœ… Good ⚠️ Requires admin Corporate back-office
Windows 10/11 (WSL2) βœ… Good βœ… Virtualized Hybrid dev environment
Alpine Linux ⚠️ Limited ⚠️ Beta support Lightweight containers
FreeBSD ❌ Not tested ❌ N/A Future milestone

πŸ’‘ Tip for high-frequency strategies: Deploy on Linux with libuv enabled for maximum event-loop performance.


πŸ€– AI Integration Modules

The SDK ships with two pre-integrated AI connectors that allow your trading logic to leverage large language models directly from PHP.

🧠 OpenAI Connector

use MetaTraderCloud\AI\OpenAIStrategy;

$brain = new OpenAIStrategy([
    'model' => 'gpt-4-turbo',     // 2026 stable version
    'api_key' => env('OPENAI_KEY'),
    'context_window' => 8192,
    'temperature' => 0.1,         // low variation for trading
]);

$signal = $brain->evaluate([
    'symbol' => 'EURUSD',
    'price'  => 1.09234,
    'rsi'    => 45.2,
    'volume' => 12000,
]);

πŸ€– Claude API Connector

use MetaTraderCloud\AI\ClaudeAdvisor;

$advisor = new ClaudeAdvisor([
    'model'     => 'claude-3-opus-2026',
    'api_key'   => env('CLAUDE_KEY'),
    'max_tokens'=> 200,
]);

$marketSentiment = $advisor->summarize([
    'news_headlines' => $latestCentralBankNews,
    'economic_calendar' => $nextEightHours,
]);

Both connectors cache prompts to reduce API costs and include a fallback to rule-based logic if the AI endpoint is unreachable.


🌍 Multilingual & Responsive UI Support

Although this repository focuses on backend logic, the SDK outputs ready-to-integrate JSON responses for multilingual frontends. A companion UI component (React/Vue) can be built using the exposed endpoints.

{
  "locale": "de_DE",
  "message": "Handelssignal ausgefΓΌhrt. Position erΓΆffnet zu 1.09234.",
  "execution_id": "txn_f3a2c8e1-9b01-4d7d-bf12-58a0e34f21cd",
  "ui_badge": {
    "color": "success",
    "icon": "check_circle_outline"
  }
}

The SDK also supports bidirectional communication for frontend dashboards via Server-Sent Events (SSE). This enables real-time trade status badges on responsive dashboards without WebSocket polyfills.

Supported UI languages: English, German, French, Japanese, Simplified Chinese, Portuguese, and Arabic (RTL ready).


πŸ›‘οΈ Disclaimer & Risk Clarification

Important: This software is provided as an unofficial MetaApi integration tool and is not affiliated with MetaQuotes Ltd., MetaApi, or any brokerage. Trading financial instruments involves substantial risk of loss. Past performance of any strategy does not guarantee future results.

While the SDK includes circuit breakers and safety limits, no automated system can eliminate the risk of total capital loss. The AI integration modules should not be considered financial advice; they are experimental analysis tools.

By using this SDK, you acknowledge that:

  • You are solely responsible for your trading decisions.
  • The SDK developers assume zero liability for any financial or data losses.
  • You have tested the system in a sandbox environment before live deployment.
  • You comply with your jurisdiction’s financial regulations regarding algorithmic trading.

Trade wise, stay curious, and never risk what you cannot afford to lose.


πŸ“œ License

This project is released under the MIT License. You are free to modify, distribute, and integrate the SDK into commercial projects. However, the original MetaApi terms of service still apply to your use of their cloud infrastructure.

License: MIT

Full legal text: https://opensource.org/licenses/MIT


πŸ”— Final Download Link

Download


Built with 🧩 for the PHP trading ecosystem. Version 2026.4.15 – Cloud Engine Build 0x1F4A.

About

πŸš€ PHP MetaApi Cloud Kit 2026 – Free SDK Setup Guide & Code Examples for Traders πŸ“ˆ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors