属性错误:“内置函数或方法”对象没有属性“余额”; [MT5]
我正在使用 python 编写一些交易代码,但是,我收到了如上所述的错误。我知道它已连接到 MT5,因为我也尝试了用于连接的不同帐户并且它有效,但是,我无法检索任何帐户信息。
有经验丰富的人可以帮忙吗?我会错过一些安装吗?如果你问的话,我正在从 VSCode 构建这个。
import MetaTrader5 as mt5
from datetime import datetime
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
D_login = xxx
D_pw = xxx
D_Server = xxx
mt5.login(D_login, D_pw, D_Server)
acc_info = mt5.account_info
print(acc_info)
bal = acc_info.balance
equity = acc_info.equity
print('Balance :', bal)
print('Equity :', equity)
I am using python to write some trading code, however, I have received error as above. I know it connected to MT5 since I also tried different account I had for connection and it works, however, I am unable to retrieve any account information.
Anyone experience enough to help? Would I be missing some installation? I am building this from VSCode if you are asking.
import MetaTrader5 as mt5
from datetime import datetime
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
D_login = xxx
D_pw = xxx
D_Server = xxx
mt5.login(D_login, D_pw, D_Server)
acc_info = mt5.account_info
print(acc_info)
bal = acc_info.balance
equity = acc_info.equity
print('Balance :', bal)
print('Equity :', equity)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
mt5.account_info
更改为mt5.account_info()
。您需要调用该函数。Change
mt5.account_info
tomt5.account_info()
. You need to call the function.