fivesocket-python
Call your MetaTrader 5 account from Python on macOS, Linux, Docker, or Windows over HTTPS. No Windows PC, no VPS, no Wine setup, and no open MT5 terminal.
If you have ever run pip install MetaTrader5 on a Mac or a Linux container and hit No matching distribution found for MetaTrader5, this is the hosted alternative. MetaQuotes only ships Windows wheels for the official package. FiveSocket runs the MT5 terminal on our side and exposes your broker account through a standard REST API.
This package uses Python's standard library only. Nothing to compile, no C extensions, no dependencies.
What you can do with it
- Read live balance, equity, margin, open positions, closed trades, and broker candles straight into pandas.
- Check prop-firm drawdown headroom for FTMO, FundedNext, and The5ers before placing a trade.
- Run bar-based strategy backtests on your own broker's candle history.
- Submit, modify, and close orders with
Idempotency-Keyprotection and automatic polling when an order returnscommit_unknown. Every order sent through FiveSocket is checked against your per-symbol volume caps and prop-firm rules first.
Install
pip install fivesocket
Or copy fivesocket/client.py directly into your project. It is one file and needs Python 3.10+.
Quick start
- Create an account at fivesocket.com and link an MT5 demo or live account in the browser. You get 7 days of free usage with no card required after linking.
- Create an API key in the dashboard (
readscope for data,trading:executeif you want to place orders). - Export your key and account ID:
export FIVESOCKET_KEY="mt5_live_..."
export FIVESOCKET_ACCOUNT_ID="acc_..."
- Read your balance, positions, and candles:
from fivesocket import FiveSocket
client = FiveSocket()
account_id = "acc_..."
print(client.get_balance(account_id))
print(client.list_positions(account_id))
candles = client.get_candles(account_id, symbol="EURUSD", timeframe="H1", count=100)
print(candles["candles"][-1])
Placing orders safely
FiveSocket requires an Idempotency-Key header on order writes and uses decimal strings for volume and prices so floating-point rounding never slips into a live lot size.
from fivesocket import FiveSocket
client = FiveSocket()
result = client.submit_order(
"acc_...",
symbol="EURUSD",
side="buy",
volume="0.01",
order_type="market",
)
print(result)
If the broker link drops mid-flight, FiveSocket returns HTTP 202 with outcome: "commit_unknown" and a commandId. Never fire a second market order when that happens. submit_order polls GET /v1/accounts/{accountId}/execution/commands/{commandId} for you until the broker confirms the final state.
Remember to test on a demo account first and configure your symbol allowlist and max volume caps before enabling trading:execute.
Checking prop-firm limits
status = client.get_prop_status("acc_...")
print(status)
If you want to check daily loss and max drawdown math before connecting an account, we also publish free browser calculators at fivesocket.com/tools.
When you should not use this
If you need sub-millisecond co-located HFT or you want to run compiled .ex5 Expert Advisors directly on an MT5 chart, rent a Windows VPS near your broker. FiveSocket is built for Python bots, n8n/TradingView relays, backtests, and AI assistants where maintaining a Windows box is the wrong job.
Examples and tests
Run the unit tests locally:
python3 -m unittest discover -s tests
See examples/ for ready-to-run scripts covering account reads, pandas DataFrames, and market orders.
Links
- Python guide: fivesocket.com/mt5-api-python
- MT5 on Mac guide: fivesocket.com/metatrader5-python-mac
- Full REST API reference: docs.fivesocket.com
- Hosted MT5 MCP server (Claude, ChatGPT, Cursor): fivesocket/mt5-mcp-server
- TradingView webhook relay: fivesocket/tradingview-mt5-webhook
License
MIT. See LICENSE.
Metadata
Release files for fivesocket 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fivesocket-0.1.0.tar.gz | 7.0 kB | With provenance | Details for fivesocket-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fivesocket-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for fivesocket-0.1.0-py3-none-any.whl |
Total release size: 13.4 kB
Release files / fivesocket-0.1.0.tar.gz
| Download URL | fivesocket-0.1.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d385ca2b584aa9c6f2e29241fe24e7c7806408a97f33558484c69706eb361ec6
|
|
BLAKE2b-256 checksum How to use checksums |
8f48c6db33372828952973b2ea31c53ba4fc8df77c0ac762cbc9d106d9fab398
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / fivesocket-0.1.0-py3-none-any.whl
| Download URL | fivesocket-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5117f918470ecfa1a0f7773c43a2c6421e3574d244300a7c176da73d5df2cf29
|
|
BLAKE2b-256 checksum How to use checksums |
016b05870c58167ed4cbb1914f216765ef4db49ee772ddba33d9f7d664baf564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for fivesocket 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fivesocket-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.