Files
quantumbotx/core/bots/helpers.py
T
Chrisnov c66b32a7bc Versi refactoring dan penataan ulang kode untuk meningkatkan struktur dan keterbacaan.
Perubahan ini mencakup:
 - Penataan ulang struktur direktori
 - Peningkatan dokumentasi
 - Penghapusan kode yang tidak terpakai
 - Peningkatan performa di beberapa fungsi

 Commit ini bertujuan untuk mempersiapkan basis kode untuk pengembangan lebih lanjut.

 Referensi: #1234
 ---
2025-07-19 21:39:01 +08:00

24 lines
623 B
Python

import locale
import MetaTrader5 as mt5
locale.setlocale(locale.LC_NUMERIC, 'C')
def parse_decimal(val):
try:
return float(str(val).replace(',', '.'))
except Exception:
return 0.0
def initialize_mt5(account, password, server):
if not mt5.initialize():
print("Gagal inisialisasi MT5!", mt5.last_error())
return False
if not mt5.login(account, password=password, server=server):
print(f"Gagal login MT5 ke {server}, kode: {mt5.last_error()}")
mt5.shutdown()
return False
print(f"Login sukses ke akun MT5: {account} @ {server}")
return True