mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-28 03:07:53 +00:00
c66b32a7bc
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 ---
21 lines
788 B
Python
21 lines
788 B
Python
# core/db/models.py
|
|
import sqlite3
|
|
|
|
def log_trade_action(bot_id, action, details):
|
|
try:
|
|
with sqlite3.connect('bots.db') as conn:
|
|
cursor = conn.cursor()
|
|
cursor.execute(
|
|
'INSERT INTO trade_history (bot_id, action, details) VALUES (?, ?, ?)',
|
|
(bot_id, action, details)
|
|
)
|
|
if action.startswith("POSISI") or action.startswith("GAGAL") or action.startswith("AUTO"):
|
|
notif_msg = f"Bot ID {bot_id} - {details}"
|
|
cursor.execute(
|
|
'INSERT INTO notifications (bot_id, message) VALUES (?, ?)',
|
|
(bot_id, notif_msg)
|
|
)
|
|
conn.commit()
|
|
except Exception as e:
|
|
print(f"[DB ERROR] Gagal mencatat aksi: {e}")
|