Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from aiomql import OrderFilling, TimeFrame, OrderType | |
| # Accessing an enum value | |
| fok = OrderFilling.FOK | |
| print(fok) # Output: ORDER_FILLING_FOK | |
| # Accessing properties or methods | |
| hourly = TimeFrame.H1 | |
| print(hourly.seconds) # Output: 3600 | |
| secs = hourly.seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from datetime import datetime | |
| from pytz import timezone | |
| from aiomql import ForexSymbol, Positions, History, Order, OrderType, RAM, TradeAction, MetaTrader | |
| async def main(): | |
| async with MetaTrader() as mt5: | |
| pos = Positions() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import time | |
| from aiomql import Session, Sessions, Chaos, ForexSymbol | |
| # Create individual sessions | |
| # time is in 24-hour format and in UTC | |
| session1 = Session(start=time(8), | |
| end=time(16), | |
| on_start="close_all", | |
| on_end="close_all", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from aiomql import Strategy, ForexSymbol, TimeFrame, Tracker, OrderType, Sessions, Trader, ScalpTrader | |
| class EMAXOver(Strategy): | |
| ttf: TimeFrame # time frame for the strategy | |
| tcc: int # how many candles to consider | |
| fast_ema: int # fast moving average period | |
| slow_ema: int # slow moving average period | |
| tracker: Tracker # tracker to keep track of strategy state | |
| interval: TimeFrame # intervals to check for entry and exit signals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from aiomql import Order, Account, Symbol, OrderType | |
| async def main(): | |
| async with Account() as _: | |
| sym = Symbol(name="BTCUSD") | |
| await sym.initialize() | |
| volume = sym.volume_min |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from datetime import datetime | |
| from aiomql import MetaTrader, Tick, Ticks | |
| async def main(): | |
| start = datetime(2024, 11,20) | |
| async with MetaTrader() as mt5: | |
| # get the latest 100 ticks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from datetime import datetime | |
| from aiomql import Symbol, TimeFrame, Account | |
| async def main(): | |
| # Assume account details are in the config file | |
| async with Account(): | |
| # symbol object must be created with a name | |
| sym = Symbol(name="BTCUSD") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from aiomql import Account | |
| async def manage_account(): | |
| async with Account() as account: | |
| print("Account successfully connected!") | |
| print(account.dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from aiomql import Config | |
| # Initialize Config (looks for aiomql.json in the current directory or upwards) | |
| config = Config() | |
| # Access loaded attributes | |
| print(config.login) # Account login number | |
| print(config.server, config.root) | |
| # Dynamically Update Configuration |