Skip to main content

This library contains a series of tools to create a trading bot for Forex trading using Metatrader.

Project description

TRADEO - A forex trading framework using MetaTrader

Logo

This library contains a series of tools to create a trading bot for Forex trading. It uses the DWX Connect (modified) to send commands and receive information of MetaTrader. This library is created based on a linux installation of MetaTrader.

Test codecov.io

Installation

Install the library

PIP

pip install tradeo

POETRY

poetry add tradeo

Or you can add manually in pyproject.toml file if you want download it from a specific branch:

tradeo = { git = "git@github.com:sorul/tradeo.git", branch = "develop" }

Usage

  • You can create strategies inheriting tradeo.strategies.strategy.Strategy class. An example of this it would be basic_strategy.py

  • You can customize the handler of metatrader responses inheriting tradeo.event_handlers.event_handler.EventHandler class. An example of this it would be basic_handler.py

  • An example of a main script using this library would be basic_forex.py that inheriting tradeo.executable.executable.Executable.

[!NOTE]
The configuration of Metatrader is necessary for the functioning of Tradeo. There is an example of both the configuration and the use of the library in a real project: sorul_tradingbot

Utilities

  • tradeo.utils.logger module: It contains a logger that can be used in your project. It can be configured to log in a file, in the console or in a syslog server. It also has the possibility of sending logs to a Telegram chat.
  • tradeo.trading_methods module: It contains some trading methods that can be used in your strategies, such as calculating the pivots, calculating POH, VAL, VAH, calculating the EMA, RSI, etc.

Execution of your project if you import this library

It's necessary to export certain environment variables before running the bot.

# Timezone configuration
export TB_LOCAL_TIMEZONE=Europe/Madrid
export TB_BROKER_TIMEZONE=Etc/GMT-2

# Trading configuration
export TB_SYMBOLS=EURUSD,USDCAD,USDCHF
export TB_ACCOUNT_CURRENCY=EUR
export TB_TIMEFRAME=M5
export TB_LOOKBACK_DAYS=10

# Forex-Client configuration
export TB_CHECK_MESSAGES_THREAD=true
export TB_CHECK_MARKET_DATA_THREAD=false
export TB_CHECK_BAR_DATA_THREAD=false
export TB_CHECK_OPEN_ORDERS_THREAD=true
export TB_CHECK_HISTORICAL_DATA_THREAD=true
export TB_CHECK_HISTORICAL_TRADES_THREAD=false

# Metatrader configuration
export TB_WINE_HOME="${HOME}/.wine"
export TB_MT_FILES_PATH="${TB_WINE_HOME}/drive_c/.../MQL5/Files"

# Logging configuration
export TB_ACTIVATE_SYSLOG=false
export TB_LOG_LEVEL=INFO
export TB_SYSLOG_ADDRESS=logs2.papertrailapp.com
export TB_SYSLOG_PORT=12345

# Telegram configuration
export TB_ACTIVATE_TELEGRAM=false
export TB_TG_LOG_LEVEL=INFO
export TB_TG_FOREX_TOKEN=0000000000:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
export TB_TG_FOREX_CHAT_ID=-999999999

The different possibilities for exporting environment variables depend on the user's preference. For example, we can place all the variables in a ".env" file and then execute the command using a Makefile and poetry:

Makefile

run_forex:
	source .env && ~/.local/bin/poetry run run_forex

Edit the crontab (crontab -e):

@reboot cd <path_to_your_project> && make start_metatrader

*/5 * * * 0-5  cd <path_to_your_project> && make run_forex

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tradeo-0.24.2.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tradeo-0.24.2-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

Details for the file tradeo-0.24.2.tar.gz.

File metadata

  • Download URL: tradeo-0.24.2.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for tradeo-0.24.2.tar.gz
Algorithm Hash digest
SHA256 6f83fe8a74759a4606cfb4692de407ea5b56d8037b4af32c062ea4695d170a2e
MD5 e4dab4ad6fb5fc9555b75528320d866a
BLAKE2b-256 3fb27d412c901a0780034d4c478407f2f40400a29d4fab1c0c20c05358408a6d

See more details on using hashes here.

File details

Details for the file tradeo-0.24.2-py3-none-any.whl.

File metadata

  • Download URL: tradeo-0.24.2-py3-none-any.whl
  • Upload date:
  • Size: 46.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for tradeo-0.24.2-py3-none-any.whl
Algorithm Hash digest
SHA256 38b15a2803704111728d11a4c33b8490d758dcd8c32f4f884895924ecaeb031d
MD5 96e5dcf6335ff40eac2b32575745f514
BLAKE2b-256 f55dba1cbd4ac670675fade8e805fa6b51d5a7fd17c4920cdb588fcf5464f7f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page