Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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()
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",
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
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
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
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")
import asyncio
from aiomql import Account
async def manage_account():
async with Account() as account:
print("Account successfully connected!")
print(account.dict)
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