bitunix-automated-crypto-trading 1.2.0__py3-none-any.whl → 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bitunix_automated_crypto_trading-1.2.0.dist-info → bitunix_automated_crypto_trading-1.3.0.dist-info}/METADATA +4 -3
- bitunix_automated_crypto_trading-1.3.0.dist-info/RECORD +20 -0
- bitunix_automated_crypto_trading-1.3.0.dist-info/entry_points.txt +2 -0
- bitunix_automated_crypto_trading-1.3.0.dist-info/top_level.txt +1 -0
- src/AsyncThreadRunner.py +81 -0
- src/BitunixApi.py +278 -0
- src/BitunixSignal.py +1099 -0
- src/BitunixWebSocket.py +254 -0
- src/DataFrameHtmlRenderer.py +74 -0
- src/NotificationManager.py +23 -0
- src/ResourceManager.py +35 -0
- src/ThreadManager.py +69 -0
- src/TickerManager.py +636 -0
- src/__init__.py +0 -0
- src/bitunix.py +590 -0
- src/clearenv.py +8 -0
- src/config.py +90 -0
- src/logger.py +85 -0
- src/sampleenv.txt +5 -0
- bitunix_automated_crypto_trading-1.2.0.dist-info/RECORD +0 -5
- bitunix_automated_crypto_trading-1.2.0.dist-info/entry_points.txt +0 -2
- bitunix_automated_crypto_trading-1.2.0.dist-info/top_level.txt +0 -1
- {bitunix_automated_crypto_trading-1.2.0.dist-info → bitunix_automated_crypto_trading-1.3.0.dist-info}/WHEEL +0 -0
src/logger.py
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
import logging
|
2
|
+
import os
|
3
|
+
from logging.handlers import RotatingFileHandler
|
4
|
+
from datetime import datetime, timezone
|
5
|
+
from zoneinfo import ZoneInfo
|
6
|
+
from colorama import init, Fore, Style
|
7
|
+
|
8
|
+
# Initialize colorama for Windows support
|
9
|
+
init()
|
10
|
+
|
11
|
+
class Colors:
|
12
|
+
RESET = Style.RESET_ALL
|
13
|
+
RED = Fore.RED
|
14
|
+
GREEN = Fore.GREEN
|
15
|
+
YELLOW = Fore.YELLOW
|
16
|
+
BLUE = Fore.BLUE
|
17
|
+
PURPLE = Fore.MAGENTA
|
18
|
+
CYAN = Fore.CYAN
|
19
|
+
LBLUE = Fore.LIGHTBLUE_EX
|
20
|
+
|
21
|
+
|
22
|
+
class ColoredFormatter(logging.Formatter):
|
23
|
+
COLORS = {
|
24
|
+
'DEBUG': Colors.BLUE,
|
25
|
+
'INFO': Colors.GREEN,
|
26
|
+
'WARNING': Colors.YELLOW,
|
27
|
+
'ERROR': Colors.RED,
|
28
|
+
'CRITICAL': Colors.PURPLE,
|
29
|
+
}
|
30
|
+
|
31
|
+
def format(self, record):
|
32
|
+
# Add color to the level name
|
33
|
+
color = self.COLORS.get(record.levelname, Colors.RESET)
|
34
|
+
record.msg = f"{color}{record.msg}{Colors.RESET}"
|
35
|
+
return super().format(record)
|
36
|
+
|
37
|
+
class CSTFormatter(logging.Formatter):
|
38
|
+
def formatTime(self, record, datefmt=None):
|
39
|
+
# Convert UTC time to CST
|
40
|
+
utc_time = datetime.fromtimestamp(record.created, tz=timezone.utc)
|
41
|
+
cst_time = utc_time.astimezone(ZoneInfo("US/Central"))
|
42
|
+
if datefmt:
|
43
|
+
return cst_time.strftime(datefmt)
|
44
|
+
else:
|
45
|
+
return cst_time.isoformat()
|
46
|
+
|
47
|
+
class Logger:
|
48
|
+
def __init__(self, logger_name, log_file='app.log', level=logging.DEBUG, max_bytes=5 * 1024 * 1024, backup_count=3):
|
49
|
+
"""
|
50
|
+
Initialize the logger.
|
51
|
+
|
52
|
+
:param logger_name: Name of the logger.
|
53
|
+
:param log_file: Log file path.
|
54
|
+
:param level: Logging level (default: DEBUG).
|
55
|
+
:param max_bytes: Max size of the log file before rotation (default: 5MB).
|
56
|
+
:param backup_count: Number of backup files to keep (default: 3).
|
57
|
+
"""
|
58
|
+
# Create the logger
|
59
|
+
self.logger = logging.getLogger(logger_name)
|
60
|
+
self.logger.setLevel(level)
|
61
|
+
colors=Colors()
|
62
|
+
|
63
|
+
# Check if handlers are already attached
|
64
|
+
if not self.logger.handlers:
|
65
|
+
# Create a file handler with rotation
|
66
|
+
file_handler = RotatingFileHandler(log_file, maxBytes=max_bytes, backupCount=backup_count)
|
67
|
+
file_formatter = CSTFormatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
68
|
+
file_handler.setFormatter(file_formatter)
|
69
|
+
|
70
|
+
# Create a console handler
|
71
|
+
console_handler = logging.StreamHandler()
|
72
|
+
console_formatter = CSTFormatter(f'{colors.RESET}%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
73
|
+
console_handler.setFormatter(console_formatter)
|
74
|
+
|
75
|
+
# Add handlers to the logger
|
76
|
+
self.logger.addHandler(file_handler)
|
77
|
+
self.logger.addHandler(console_handler)
|
78
|
+
|
79
|
+
def get_logger(self):
|
80
|
+
"""
|
81
|
+
Return the configured logger.
|
82
|
+
|
83
|
+
:return: Configured logger instance.
|
84
|
+
"""
|
85
|
+
return self.logger
|
src/sampleenv.txt
ADDED
@@ -1,5 +0,0 @@
|
|
1
|
-
bitunix_automated_crypto_trading-1.2.0.dist-info/METADATA,sha256=DD6jO130AoYoUeuv7fRR5Agh3a4j90LUzx4PbF79YdU,13634
|
2
|
-
bitunix_automated_crypto_trading-1.2.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
3
|
-
bitunix_automated_crypto_trading-1.2.0.dist-info/entry_points.txt,sha256=h3mo-V8kaikc2r8IumkA9pGoGhwfjmzbcorsI0nEuC4,41
|
4
|
-
bitunix_automated_crypto_trading-1.2.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
5
|
-
bitunix_automated_crypto_trading-1.2.0.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
|
File without changes
|