Package: aiomql
Aiomql - Bot Building Framework and Asynchronous MetaTrader5 LibraryInstallationpipinstallaiomqlKey FeaturesAsynchronous Python Library For MetaTrader5Asynchronous Bot Building FrameworkBuild bots for trading in different financial markets using a bot factoryUse threadpool executors to run multiple strategies on multiple instruments concurrentlyRecords 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 strategiesManage Trading periods using SessionsRisk ManagementRun multiple bots concurrently with different accounts from the same broker or different brokersAs an asynchronous MetaTrader5 LibrayimportasynciofromaiomqlimportMetaTraderasyncdefmain():mt5=MetaTrader()awaitmt5.initialize()awaitmt5.login(123456,'*******','Broker-Server')symbols=awaitmt5.symbols_get()print(symbols)asyncio.run(main())As a Bot Building FrameWork using a Sample StrategyThe 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.fromdatetimeimporttimeimportloggingfromaiomqlimportBot,ForexSymbol,FingerTrap,Session,Sessions,RAM,SimpleTrader,TimeFramelogging.basicConfig(level=logging.INFO)defbuild_bot():bot=Bot()# create sessions for the strategieslondon=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 strategyparams={'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 strategiesst2=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 requiredst6=FingerTrap(symbol=ForexSymbol(name='EURUSD'))# add strategies to the botbot.add_strategies([st1,st2,st3,st4,st5,st6])bot.execute()# run the botbuild_bot()API DocumentationseeAPI Documentationfor more detailsContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.SupportFeeling generous, like the package or want to see it become a more mature package?Consider supporting the project by buying me a coffee.