Skip to content
项目

关于

MetaTrader 5 + Python on macOS (Apple Silicon), Linux and your own Linux/Windows VPS. Desktop app, setup wizard, official MetaTrader5 API.

商业与金融

这些数字如何统计

49 星标22 复刻 +1 24小时

可以做什么

  • Setup wizardChecks the machine, installs what is missing with your approval and tests that real data arrives. - Mac native modeMT5 in Wine 11 under Rosetta 2. No VM, no Docker: up to 30× faster than v1.2. - Your own serversLinux or Windows VPS over SSH. Keeps trading while your computer is off.
  • MT5 screen in the appLog in to your broker and use charts. ⌘C / ⌘V reach MT5 as Ctrl, the clipboard syncs. - Bot connection guideShows the exact host and port for wherever your bot runs, with a 3-line test. - Data and speed testsBars, ticks and the broker's clock checked through the same path your code uses.
  • Data managementHistory and tick storage per broker, symbol and year, with safe cleanup. - smt5 command lineEverything the app does, from a terminal or a script. Every command has --json. - Private by designPorts listen on 127.0.0.1 only. The app never reads or stores your passwords.

实测星标增长

24小时
+1
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文
SiliconMetaTrader5: MetaTrader 5 and Python on macOS, Linux and your own servers

Install  ·  Tour  ·  Python  ·  CLI  ·  Türkçe

Release PyPI Downloads Python 3.9+ macOS · Linux · Windows server License: PolyForm Noncommercial



The SiliconMetaTrader5 app: overview page

Overview. Balance, equity, trading result and runtime health in one place.

SiliconMetaTrader5 runs a real MetaTrader 5 terminal next to a small Python bridge, so code written for MetaQuotes' official MetaTrader5 package works on a Mac, on Linux, or on a Linux or Windows server you own. Your code changes only one line.

[!CAUTION] Test your strategy on a demo account before trading real money.

At a glance

SiliconMetaTrader5
What it is A desktop app, a runtime and a Python package that run MetaTrader 5 (MT5) for Python code outside Windows
Python API Same functions as MetaQuotes' official MetaTrader5 package: copy_rates_from_pos, symbol_info_tick, order_send, positions_get, …
Runs on macOS on Apple Silicon (M1, M2, M3, M4) and Intel · Linux x86_64 · your own Linux or Windows VPS over SSH
For Algorithmic trading, trading bots, backtests, research notebooks and data pipelines that use MT5 market data and orders
Install brew tap bahadirumutiscimen/siliconmt5 https://github.com/bahadirumutiscimen/silicon-metatrader5 && brew trust bahadirumutiscimen/siliconmt5 && brew install siliconmt5 · .deb / .AppImage · pip install siliconmetatrader5

Highlights


Setup wizard
Checks the machine, installs what is missing with your approval and tests that real data arrives.

Mac native mode
MT5 in Wine 11 under Rosetta 2. No VM, no Docker: up to 30× faster than v1.2.

Your own servers
Linux or Windows VPS over SSH. Keeps trading while your computer is off.

MT5 screen in the app
Log in to your broker and use charts. ⌘C / ⌘V reach MT5 as Ctrl, the clipboard syncs.

Bot connection guide
Shows the exact host and port for wherever your bot runs, with a 3-line test.

Data and speed tests
Bars, ticks and the broker's clock checked through the same path your code uses.

Data management
History and tick storage per broker, symbol and year, with safe cleanup.

smt5 command line
Everything the app does, from a terminal or a script. Every command has --json.

Private by design
Ports listen on 127.0.0.1 only. The app never reads or stores your passwords.

Faster in 1.3

The new Mac native mode runs MT5 directly on macOS, without a virtual machine. Same Mac, v1.2 vs v1.3:

Speed: startup 55.2 s → 20.3 s, bridge round trip 10.96 ms → 0.8 ms, 10,000 bars 1.10 s → 0.03 s, Windows Python CPU 1.89 s → 0.14 s

Run the same test on your machine from the Data Test page or with smt5 bench.

How it fits together

Your Python code talks to 127.0.0.1; the bridge, the MetaTrader5 package and the MT5 terminal run on this Mac (native or Safe mode) or on a Linux or Windows server reached through an SSH tunnel

Where MT5 can run

Mode How MT5 runs Good for
macOS Mac native (recommended) Directly on macOS, as a normal window Development, backtests, bots while the Mac is on
macOS Safe (fallback) In an isolated virtual machine Macs without Rosetta 2
Linux x86_64 Linux native or Docker Directly, with or without a display Linux desktops and PCs
Linux server Linux native or Docker Installed and managed by the app over SSH 24/7 bots
Windows server Windows Natively, managed by the app over SSH 24/7 bots

Other ways to use MT5 from Python outside Windows

Windows virtual machine Wine set up by hand SiliconMetaTrader5
Setup Install Windows, MT5 and Python inside the VM Install Wine, Windows Python, MT5 and a bridge yourself One wizard, every step checked
Your Python code Runs inside the VM, or needs its own network bridge Needs a bridge you maintain Runs on your machine; one line points it at 127.0.0.1
Apple Silicon Windows on ARM runs MT5 under its own emulation Depends on the Wine build Wine 11 + Rosetta 2, measured above
Servers Separate setup per VPS Separate setup per VPS Linux and Windows VPS from the same app, over SSH
Monitoring None built in None built in Health, logs, data and speed tests, menu bar panel

Install

macOS

brew tap bahadirumutiscimen/siliconmt5 https://github.com/bahadirumutiscimen/silicon-metatrader5
brew trust bahadirumutiscimen/siliconmt5
brew install siliconmt5
smt5 app-install          # adds the app to Applications

Linux x86_64: the .deb or .AppImage from Releases.

Python

pip install siliconmetatrader5
Build from source
git clone https://github.com/bahadirumutiscimen/silicon-metatrader5.git
cd silicon-metatrader5/app
cargo build --release -p smt5-cli -p smt5-desktop   # app: target/release/siliconmt5 · CLI: target/release/smt5
export PATH="$PWD/target/release:$PATH"

See app/README.md for Linux build dependencies.

A tour of the app

Setup wizard

Setup wizard: language, system, Mac native mode, components installed, MT5 started

From an empty Mac to a running MT5. Choose the language, system and mode. The wizard installs what is missing with your approval, starts MT5 and checks the data.

MT5 screen

MT5 screen inside the app for a Windows server MT5 as a normal macOS window in the Mac native mode
Inside the app for servers and Linux. ⌘C / ⌘V work as in any Mac app and the clipboard syncs both ways. A normal macOS window in the Mac native mode.

Servers

Adding a Windows server: choose Windows, enter the SSH address, accept the fingerprint, run mode, precheck

Add a server in one form. Choose Linux or Windows and enter the SSH address. The precheck shows what is missing and how to fix it.

Servers page with this computer and several VPS cards

Every server is a card with its connection, account, balance and today's result. Servers keep running while the app is closed.

Linux server requirements
  • Ubuntu or Debian, x86_64, 2 GB RAM, 3 GB free disk.
  • Missing packages are listed by the precheck with the command to install them.
Windows server requirements
  • Windows 10 1809+ or Windows Server 2019+, x64, an administrator account.
  • OpenSSH Server turned on once; the wizard shows the command.
  • MT5 needs a signed-in desktop, so setup turns on automatic sign-in and restarts once. You type the password on the server; the app never sees it.
  • Uninstall removes only what the app installed.

Bot connection

Bot connection page: choosing the MT5 and where the bot runs shows host and port

Which address does my bot use? Pick the MT5 and where the bot runs; the page shows the host and port for your setup.

Your bot runs Host Port Works
On this computer, MT5 on this computer 127.0.0.1 the local bridge port (8001) while MT5 runs
On this computer, MT5 on a server 127.0.0.1 the server's tunnel port (e.g. 18001) while the app is open
On the server itself 127.0.0.1 the server's own bridge port (8001) always, even with your computer off
On another computer 127.0.0.1 after ssh -N -L 18001:127.0.0.1:8001 user@server while that command runs

The bridge listens only on 127.0.0.1, so use these values instead of the server's IP.

Data test and speed test

Data test runs eight checks and draws the last bars; the speed test measures startup, CPU, transfer and latency

Is data really coming in? Eight checks through the same bridge your code uses, with the last bars drawn. The speed test compares the modes.

Data, accounts and logs

Data management
Data management. History and ticks per broker, symbol and year, with safe cleanup.
Accounts
Accounts. The active account and the accounts used on this computer.
Logs
Logs. Live logs with search and a noise filter.
Runtime settings
Runtime settings. Mode, MaxBars, Algo Trading, screen and ports.
App settings
App settings. Window behaviour and setup.
Reset and remove
Reset and remove. Reset MT5 data or remove everything, with a clear list of what is deleted.

Menu bar, Python guide and an example strategy

Menu bar panel
Menu bar panel. Status and balance at a glance.
Python API guide
Python API guide. Every function with a copyable example.
Supertrend example
Supertrend example. Same code for backtest and live signals.

Python quick start

After logging in to your broker in MT5:

import pandas as pd
from datetime import timedelta
from siliconmetatrader5 import MetaTrader5, server_now

mt5 = MetaTrader5(host="127.0.0.1", port=8001, keepalive=True)   # see "Bot connection" for the port
if not mt5.initialize():
    raise SystemExit(f"initialize() failed: {mt5.last_error()}")

print(mt5.account_info().server, mt5.terminal_info().build)

# last 200 closed M15 bars (position 1 skips the bar that is still forming)
rates = mt5.copy_rates_from_pos("EURUSD", mt5.TIMEFRAME_M15, 1, 200)
print(pd.DataFrame(rates).tail())

# a range that ends "now" on the broker's clock
now = server_now(mt5)
bars = mt5.copy_rates_range("EURUSD", mt5.TIMEFRAME_M5, now - timedelta(hours=6), now)

mt5.close()   # disconnects this script only; shutdown() would disconnect every client of the bridge

Moving a bot from the official package changes only the connection lines:

# before                               # after
import MetaTrader5 as mt5              from siliconmetatrader5 import MetaTrader5
mt5.initialize()                       mt5 = MetaTrader5(host="127.0.0.1", port=8001)
                                       mt5.initialize()

Bar times are on the broker's clock; use server_now(mt5) instead of datetime.now(). More in the client README.

smt5 command line

Command reference
Command What it does
smt5 doctor Checks prerequisites and health, with the exact fix for each problem
smt5 init Creates the settings with a random API token
smt5 mode [safe|native] Shows or switches the mode (the running one is stopped first)
smt5 build / pull Installs the native runtime, or builds / pulls the Docker image
smt5 up / down / restart [mt5|bridge] Start, stop, restart
smt5 status / watch / logs <source> Phase, live phase, logs
smt5 test EURUSD --tf M5 Data test through the bridge
smt5 bench Speed test: startup, CPU, copy_rates, transfer, latency
smt5 symbols Market Watch symbols
smt5 data / purge … History inventory and safe deletion
smt5 mt5-import Copies MT5 (login and history) from the Safe mode into the native mode
smt5 vm start|stop|status The Safe mode's Colima VM
smt5 app-install macOS Homebrew: copies the app into Applications

All commands accept --json.

Security and privacy

  • Every port listens on 127.0.0.1; servers are reached through an encrypted SSH tunnel.
  • The app never reads or stores your passwords.
  • A server whose identity changes is blocked until you approve it.

FAQ

How do I use the MetaTrader5 Python package on a Mac with Apple Silicon (M1, M2, M3, M4)?

Install SiliconMetaTrader5 and pip install siliconmetatrader5, then replace import MetaTrader5 as mt5 with mt5 = MetaTrader5(host="127.0.0.1", port=8001). The rest of your code stays the same.

Does the MetaTrader 5 Python API work on Linux?

Yes, on Linux x86_64, with or without a display.

How do I run an MT5 trading bot 24/7 on a VPS?

Add the server in the app, copy your bot to it and connect to 127.0.0.1:8001 there. It keeps running while your computer is off.

Can I place orders, or is it read-only?

Everything the official package can do works, including order_send and positions_get.

I restarted my Mac. What now?

Open the app and press Start. Servers keep running on their own.

Can I keep using MT5 data from v1.2 (Safe mode)?

Yes. The Mac native mode copies your login and history from it.

The data test says "No data".

History downloads after the first login; wait a few minutes. Check that the symbol is in Market Watch and spelled as your broker spells it (e.g. EURUSD.m).

Repository

Folder What it is
app/ The desktop app (Tauri v2) and the smt5 command line, in Rust
runtime/ The MT5 runtime: macOS and Linux native scripts, the Docker image, the Windows server scripts, the status API
client/ The Python package siliconmetatrader5
examples/ Small scripts: fetch data, plot bars
packaging/ Homebrew formula and Linux test scripts

License

PolyForm Noncommercial 1.0.0: free for personal and other noncommercial use. Commercial use requires a license from the author; open an issue to ask. See NOTICE for third-party components.

Support

If this project saves you time, you can support it with USDT on the TRC20 network:

TMh8eS5EPRL77Z7L4KhsKmccSNLgf6Rfta

MetaTrader 5 · MT5 · MetaTrader5 Python API · MQL5 · macOS · Apple Silicon M1 M2 M3 M4 · Linux · Wine · Rosetta 2 · Windows VPS · Linux VPS · algorithmic trading · trading bot · forex · CFD · backtesting · RPyC bridge

© 2025–2026 Bahadır Umut İşçimen · PolyForm Noncommercial 1.0.0 · MetaTrader is a trademark of MetaQuotes Ltd.; this project is not affiliated with MetaQuotes.

探索相关项目

加载中…