bitunix-automated-crypto-trading 1.1.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.
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
@@ -0,0 +1,5 @@
1
+ API_KEY=your_api_key
2
+ SECRET_KEY=your_secret_key
3
+ SECRET=your_token_secret
4
+ PASSWORD=whatever_is_here_is_your_webpage_password
5
+ HOST=0.0.0.0
@@ -1,5 +0,0 @@
1
- bitunix_automated_crypto_trading-1.1.0.dist-info/METADATA,sha256=l4xH5VPDIx0CQzxj9827GPQ47gMnCk5sW9CWxr8Ifjs,13634
2
- bitunix_automated_crypto_trading-1.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
3
- bitunix_automated_crypto_trading-1.1.0.dist-info/entry_points.txt,sha256=h3mo-V8kaikc2r8IumkA9pGoGhwfjmzbcorsI0nEuC4,41
4
- bitunix_automated_crypto_trading-1.1.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
- bitunix_automated_crypto_trading-1.1.0.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- bitunix = bitunix:main