属性错误:“内置函数或方法”对象没有属性“余额”; [MT5]

发布于 2025-01-11 14:58:02 字数 554 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放血 2025-01-18 14:58:02

mt5.account_info 更改为 mt5.account_info()。您需要调用该函数。

Change mt5.account_info to mt5.account_info(). You need to call the function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文