Skip to content

long-dotcom/CopyTraderAgent

Repository files navigation

CopyTraderAgent

中文 | 日本語 | 한국어

CopyTraderAgent is a Windows desktop copy-trading manager for MetaTrader 5.

It supports one master account and multiple child accounts. The master side can either copy to local child terminals directly or publish trade events through Redis so child terminals on other machines can execute them independently.

This project is for automation research and operational tooling. It is not investment advice. Use it at your own risk and test thoroughly on demo accounts before using it with live funds.

Features

  • MT5 only. MT4 is not supported.
  • One master account, multiple child accounts.
  • Local mode: master terminal and child terminals run on the same machine.
  • Redis mode: master publishes trade events, child executors consume and execute them.
  • Copies new changes only after startup. Existing historical positions and orders are not backfilled.
  • Supports market positions, partial reductions, full closes, SL/TP updates, pending orders, pending order updates, and pending order removals.
  • Per-child lot multiplier.
  • Per-child symbol mapping.
  • Strict symbol mapping: unmapped symbols are ignored.
  • Optional master Magic filter.
  • Per-child Magic, slippage, and comment template.
  • Comment template is required for enabled child accounts and must include {master_ticket}; COPY:{master_ticket} is recommended.
  • Failed child execution is retried and does not block other child accounts.
  • GUI configuration, logs, and one-exe build workflow.
  • GUI language support for Chinese and English.

Run Modes

local             Master terminal -> local child terminals
master_publisher  Master terminal -> Redis event stream
child_executor    Redis event stream -> local child terminals

In Redis mode, the master side publishes raw trade events only. Child-side settings such as lot multiplier, symbol mapping, Magic, slippage, and comment template are configured on the child executor machine.

Default Redis streams:

copytrader:events
copytrader:results

Copy Rules

Lot calculation:

child_lot = master_lot * child_multiplier

The result is rounded upward according to the child symbol's minimum lot and volume step.

Symbol mapping is strict. Example:

XAUUSD=XAUUSD
EURUSD=EURUSDm

If the master opens GBPUSD and the child has no GBPUSD=... mapping, that trade is skipped.

Comment template is required for reliable position binding. Recommended example:

COPY:{master_ticket}

When set, {master_ticket} is replaced with the master position/order ticket.

Development Run

cd D:\codex\CopyTraderAgent
python -m pip install -r requirements.txt
.\scripts\run_manager.ps1

Build

cd D:\codex\CopyTraderAgent
.\scripts\build_exe.ps1 -Clean

Output:

dist\CopyTraderAgent.exe
dist\copy_trader_config.json

Run:

dist\CopyTraderAgent.exe

CopyTraderAgent.exe contains both the GUI and the background engine entrypoint.

Configuration

The GUI saves configuration to:

copy_trader_config.json

For open-source usage, commit copy_trader_config.example.json and keep the real local copy_trader_config.json out of Git. The real file may contain local MT5 paths, Redis endpoints, and account-specific settings.

Main settings:

  • Run mode
  • UI language (zh or en)
  • Redis URL
  • Redis event stream
  • Redis result stream
  • Child executor start stream ID
  • Master MT5 terminal path
  • Master Magic filter
  • Child MT5 terminal path
  • Child lot multiplier
  • Child Magic
  • Child slippage
  • Child comment template
  • Child symbol mapping
  • Poll interval
  • Retry count
  • Retry delay
  • GUI log max lines
  • Redis stream max length
  • Child error memory max length

Requirements

  • Windows
  • Python 3.10+ for development runs
  • MetaTrader 5 terminals installed locally
  • Redis for distributed master/child mode
  • PyInstaller for building the standalone exe

License

MIT License. See LICENSE.

About

CopyTraderAgent is a Windows desktop copy-trading manager for MetaTrader 5. It supports local and Redis-based distributed copy trading, with one master account, multiple child accounts, per-child lot multipliers, strict symbol mapping, Magic filtering, SL/TP syncing, pending order syncing, retries, and a GUI-based configuration workflow.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors