Untitled
unknown
plain_text
10 months ago
1.2 kB
9
Indexable
def sync_broker_accounts(self, accounts, terminal_path):
mt5.initialize(path=terminal_path)
arr_info = []
for acc in accounts:
check_account = (
self._db_session.query(BrokerAccounts)
.filter_by(account_id=str(acc["account_id"]))
.first()
)
print(check_account)
if check_account is None:
_result = mt5.login(
int(acc["account_id"]), acc["password"], acc["server"]
)
if _result:
arr_info.append(mt5.account_info())
for data in arr_info:
data_again = self.get_all_raw_data(data)
new_log = BrokerAccounts(
account_logs=data_again, # Dữ liệu JSON
broker_name=data_again["account"]["company"],
platform_name="MetaTrader5",
account_id=data_again["account"]["login"],
)
self._db_session.add(new_log)
self._db_session.commit()
return {"status": True, "msg": "Update Success"}Editor is loading...
Leave a Comment