aiomql


Nameaiomql JSON
Version 3.21 PyPI version JSON
download
home_pageNone
SummaryAsynchronous MetaTrader5 library and Algorithmic Trading Framework
upload_time2024-05-04 23:16:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords metatrader5 asynchronous algorithmic trading trading bot
VCS
bugtrack_url
requirements MetaTrader5 pandas setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Aiomql - Bot Building Framework and Asynchronous MetaTrader5 Library
![GitHub](https://img.shields.io/github/license/ichinga-samuel/aiomql?style=plastic)
![GitHub issues](https://img.shields.io/github/issues/ichinga-samuel/aiomql?style=plastic)
![PyPI](https://img.shields.io/pypi/v/aiomql)

### Installation
```bash
pip install aiomql
```

### Key Features
- Asynchronous Python Library For MetaTrader5
- Asynchronous Bot Building Framework
- Build bots for trading in different financial markets using a bot factory
- Use threadpool executors to run multiple strategies on multiple instruments concurrently
- Records and keep track of trades and strategies in csv files.
- Helper classes for Bot Building. Easy to use and extend.
- Compatible with pandas-ta.
- Sample Pre-Built strategies
- Visualization of charts using matplotlib and mplfinance
- Manage Trading periods using Sessions
- Risk Management
- Run multiple bots concurrently with different accounts from the same broker or different brokers

### As an asynchronous MetaTrader5 Libray
```python
import asyncio

from aiomql import MetaTrader


async def main():
    mt5 = MetaTrader()
    await mt5.initialize()
    await mt5.login(123456, '*******', 'Broker-Server')
    symbols = await mt5.symbols_get()
    print(symbols)
    
asyncio.run(main())
```

### As a Bot Building FrameWork using a Sample Strategy
***The following code is a sample bot that uses the FingerTrap strategy from the library.\
It assumes that you have a config file in the same directory as the script.\
The config file should be named aiomql.json and should contain the login details for your account.\
It demonstrates the use of sessions and risk management.\
Sessions allows you to specify the trading period for a strategy. You can also set an action to be performed at the end of a session.\
Risk Management allows you to manage the risk of a strategy. You can set the risk per trade and the risk to reward ratio.\
The trader class handles the placing of orders and risk management. It is an attribute of the strategy class.***

```python
from datetime import time
import logging

from aiomql import Bot, ForexSymbol, FingerTrap, Session, Sessions, RAM, SimpleTrader, TimeFrame

logging.basicConfig(level=logging.INFO)


def build_bot():
    bot = Bot()
    
    # create sessions for the strategies
    london = Session(name='London', start=8, end=time(hour=15, minute=30), on_end='close_all')
    new_york = Session(name='New York', start=13, end=time(hour=20, minute=30))
    tokyo = Session(name='Tokyo', start=23, end=time(hour=6, minute=30))
    
    # configure the parameters and the trader for a strategy
    params = {'trend_candles_count': 500, 'fast_period': 8, 'slow_period': 34, 'etf': TimeFrame.M5}
    gbpusd = ForexSymbol(name='GBPUSD')
    st1 = FingerTrap(symbol=gbpusd, params=params, trader=SimpleTrader(symbol=gbpusd, ram=RAM(risk=0.05, risk_to_reward=2)),
                     sessions=Sessions(london, new_york))
    
    # use the default for the other strategies
    st2 = FingerTrap(symbol=ForexSymbol(name='AUDUSD'), sessions=Sessions(tokyo, new_york))
    st3 = FingerTrap(symbol=ForexSymbol(name='USDCAD'), sessions=Sessions(new_york))
    st4 = FingerTrap(symbol=ForexSymbol(name='USDJPY'), sessions=Sessions(tokyo))
    st5 = FingerTrap(symbol=ForexSymbol(name='EURGBP'), sessions=Sessions(london))
    
    # sessions are not required
    st6 = FingerTrap(symbol=ForexSymbol(name='EURUSD'))
    
    # add strategies to the bot
    bot.add_strategies([st1, st2, st3, st4, st5, st6])
    bot.execute()

# run the bot
build_bot()
```
## API Documentation
see [API Documentation](https://github.com/Ichinga-Samuel/aiomql/tree/master/docs) for more details

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## Support
Feeling generous, like the package or want to see it become a more mature package?

Consider supporting the project by buying me a coffee.\
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/ichingasamuel)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiomql",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "MetaTrader5, Asynchronous, Algorithmic Trading, Trading Bot",
    "author": null,
    "author_email": "Ichinga Samuel <ichingasamuel@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/73/67/7371c51f3c42fc0ca581ba581b8f45f34544b7fd5b77b16082692755f2ab/aiomql-3.21.tar.gz",
    "platform": null,
    "description": "# Aiomql - Bot Building Framework and Asynchronous MetaTrader5 Library\r\n![GitHub](https://img.shields.io/github/license/ichinga-samuel/aiomql?style=plastic)\r\n![GitHub issues](https://img.shields.io/github/issues/ichinga-samuel/aiomql?style=plastic)\r\n![PyPI](https://img.shields.io/pypi/v/aiomql)\r\n\r\n### Installation\r\n```bash\r\npip install aiomql\r\n```\r\n\r\n### Key Features\r\n- Asynchronous Python Library For MetaTrader5\r\n- Asynchronous Bot Building Framework\r\n- Build bots for trading in different financial markets using a bot factory\r\n- Use threadpool executors to run multiple strategies on multiple instruments concurrently\r\n- Records and keep track of trades and strategies in csv files.\r\n- Helper classes for Bot Building. Easy to use and extend.\r\n- Compatible with pandas-ta.\r\n- Sample Pre-Built strategies\r\n- Visualization of charts using matplotlib and mplfinance\r\n- Manage Trading periods using Sessions\r\n- Risk Management\r\n- Run multiple bots concurrently with different accounts from the same broker or different brokers\r\n\r\n### As an asynchronous MetaTrader5 Libray\r\n```python\r\nimport asyncio\r\n\r\nfrom aiomql import MetaTrader\r\n\r\n\r\nasync def main():\r\n    mt5 = MetaTrader()\r\n    await mt5.initialize()\r\n    await mt5.login(123456, '*******', 'Broker-Server')\r\n    symbols = await mt5.symbols_get()\r\n    print(symbols)\r\n    \r\nasyncio.run(main())\r\n```\r\n\r\n### As a Bot Building FrameWork using a Sample Strategy\r\n***The following code is a sample bot that uses the FingerTrap strategy from the library.\\\r\nIt assumes that you have a config file in the same directory as the script.\\\r\nThe config file should be named aiomql.json and should contain the login details for your account.\\\r\nIt demonstrates the use of sessions and risk management.\\\r\nSessions allows you to specify the trading period for a strategy. You can also set an action to be performed at the end of a session.\\\r\nRisk Management allows you to manage the risk of a strategy. You can set the risk per trade and the risk to reward ratio.\\\r\nThe trader class handles the placing of orders and risk management. It is an attribute of the strategy class.***\r\n\r\n```python\r\nfrom datetime import time\r\nimport logging\r\n\r\nfrom aiomql import Bot, ForexSymbol, FingerTrap, Session, Sessions, RAM, SimpleTrader, TimeFrame\r\n\r\nlogging.basicConfig(level=logging.INFO)\r\n\r\n\r\ndef build_bot():\r\n    bot = Bot()\r\n    \r\n    # create sessions for the strategies\r\n    london = Session(name='London', start=8, end=time(hour=15, minute=30), on_end='close_all')\r\n    new_york = Session(name='New York', start=13, end=time(hour=20, minute=30))\r\n    tokyo = Session(name='Tokyo', start=23, end=time(hour=6, minute=30))\r\n    \r\n    # configure the parameters and the trader for a strategy\r\n    params = {'trend_candles_count': 500, 'fast_period': 8, 'slow_period': 34, 'etf': TimeFrame.M5}\r\n    gbpusd = ForexSymbol(name='GBPUSD')\r\n    st1 = FingerTrap(symbol=gbpusd, params=params, trader=SimpleTrader(symbol=gbpusd, ram=RAM(risk=0.05, risk_to_reward=2)),\r\n                     sessions=Sessions(london, new_york))\r\n    \r\n    # use the default for the other strategies\r\n    st2 = FingerTrap(symbol=ForexSymbol(name='AUDUSD'), sessions=Sessions(tokyo, new_york))\r\n    st3 = FingerTrap(symbol=ForexSymbol(name='USDCAD'), sessions=Sessions(new_york))\r\n    st4 = FingerTrap(symbol=ForexSymbol(name='USDJPY'), sessions=Sessions(tokyo))\r\n    st5 = FingerTrap(symbol=ForexSymbol(name='EURGBP'), sessions=Sessions(london))\r\n    \r\n    # sessions are not required\r\n    st6 = FingerTrap(symbol=ForexSymbol(name='EURUSD'))\r\n    \r\n    # add strategies to the bot\r\n    bot.add_strategies([st1, st2, st3, st4, st5, st6])\r\n    bot.execute()\r\n\r\n# run the bot\r\nbuild_bot()\r\n```\r\n## API Documentation\r\nsee [API Documentation](https://github.com/Ichinga-Samuel/aiomql/tree/master/docs) for more details\r\n\r\n## Contributing\r\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\n## Support\r\nFeeling generous, like the package or want to see it become a more mature package?\r\n\r\nConsider supporting the project by buying me a coffee.\\\r\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/ichingasamuel)\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Asynchronous MetaTrader5 library and Algorithmic Trading Framework",
    "version": "3.21",
    "project_urls": {
        "Bug Tracker": "https://github.com/Ichinga-Samuel/aiomql/issues",
        "Homepage": "https://github.com/Ichinga-Samuel/aiomql"
    },
    "split_keywords": [
        "metatrader5",
        " asynchronous",
        " algorithmic trading",
        " trading bot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32759203ebb2fc4bf642ab8da2dee2414a0c048337ae063443ee0fa90ca907cd",
                "md5": "ee54b297df780a645fd470ea8a70f0ed",
                "sha256": "7947484808e59dcb91d3d5029265db9f93d4d0369b9d3a3b833f5e1370f39884"
            },
            "downloads": -1,
            "filename": "aiomql-3.21-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ee54b297df780a645fd470ea8a70f0ed",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 62914,
            "upload_time": "2024-05-04T23:16:22",
            "upload_time_iso_8601": "2024-05-04T23:16:22.715341Z",
            "url": "https://files.pythonhosted.org/packages/32/75/9203ebb2fc4bf642ab8da2dee2414a0c048337ae063443ee0fa90ca907cd/aiomql-3.21-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73677371c51f3c42fc0ca581ba581b8f45f34544b7fd5b77b16082692755f2ab",
                "md5": "64201a1e2516e6ef15bb699dd6117b0b",
                "sha256": "de13f86fb73b1b4f8d903c9536fed4db2e97f53f28baa03269ee2e1f4319e2d3"
            },
            "downloads": -1,
            "filename": "aiomql-3.21.tar.gz",
            "has_sig": false,
            "md5_digest": "64201a1e2516e6ef15bb699dd6117b0b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 53772,
            "upload_time": "2024-05-04T23:16:24",
            "upload_time_iso_8601": "2024-05-04T23:16:24.700972Z",
            "url": "https://files.pythonhosted.org/packages/73/67/7371c51f3c42fc0ca581ba581b8f45f34544b7fd5b77b16082692755f2ab/aiomql-3.21.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-04 23:16:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Ichinga-Samuel",
    "github_project": "aiomql",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "MetaTrader5",
            "specs": [
                [
                    "~=",
                    "5.0.45"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "~=",
                    "2.1.1"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "~=",
                    "65.5.1"
                ]
            ]
        }
    ],
    "lcname": "aiomql"
}
        
Elapsed time: 0.25373s