简体   繁体   English

在 python 中初始化 metatrader

[英]Initializing metatrader in python

I am trying to use the Metatrader library to extract market data and build algorithms.我正在尝试使用 Metatrader 库来提取市场数据并构建算法。 The first lines to get started with this library just don't work开始使用这个库的第一行是行不通的

import MetaTrader5 as mt5
mt5.initialize()

These lines of code always return an output of False meaning that mt5 has not initialized, i have not seen this issue addressed anywhere else so i would really appreciate some help.这些代码行总是返回False的 output 意味着 mt5 尚未初始化,我还没有看到这个问题在其他任何地方得到解决,所以我非常感谢一些帮助。

You need to precise your login, your password, your server and download the MetaTrader 5 terminal EXE file() in order to connect to Metatrader.您需要输入您的登录名、密码、服务器并下载 MetaTrader 5 终端 EXE 文件 () 才能连接到 Metatrader。

 if not mt5.initialize(login=25115284, server="MetaQuotes-Demo",password="4zatlbqx"): print("initialize() failed, error code =",mt5.last_error()) quit()

(cf. https://www.mql5.com/en/docs/integration/python_metatrader5/mt5initialize_py ) (参见https://www.mql5.com/en/docs/integration/python_metatrader5/mt5initialize_py

You should also take a look at the last_error() section ( https://www.mql5.com/en/docs/integration/python_metatrader5/mt5lasterror_py ) of the Metatrader documentation and install Metatrader if it's not already https://www.metatrader5.com/en/automated-trading您还应该查看 Metatrader 文档的last_error()部分 ( https://www.mql5.com/en/docs/integration/python_metatrader5/mt5lasterror_py ),如果尚未安装 Metatrader,请安装Z5E056C500A1C4B6A7110B50D807://www。 metatrader5.com/en/automated-trading

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM