bitunix-automated-crypto-trading 2.6.7__py3-none-any.whl → 2.6.8__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/AsyncThreadRunner.py +81 -81
- bitunix_automated_crypto_trading/BitunixApi.py +278 -278
- bitunix_automated_crypto_trading/BitunixSignal.py +1099 -1099
- bitunix_automated_crypto_trading/BitunixWebSocket.py +254 -254
- bitunix_automated_crypto_trading/DataFrameHtmlRenderer.py +74 -74
- bitunix_automated_crypto_trading/NotificationManager.py +23 -23
- bitunix_automated_crypto_trading/ThreadManager.py +68 -68
- bitunix_automated_crypto_trading/TickerManager.py +635 -635
- bitunix_automated_crypto_trading/bitunix.py +597 -594
- bitunix_automated_crypto_trading/config.py +90 -90
- bitunix_automated_crypto_trading/logger.py +84 -84
- {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/METADATA +36 -36
- bitunix_automated_crypto_trading-2.6.8.dist-info/RECORD +17 -0
- bitunix_automated_crypto_trading/config.txt +0 -60
- bitunix_automated_crypto_trading/sampleenv.txt +0 -5
- bitunix_automated_crypto_trading/static/chart.css +0 -28
- bitunix_automated_crypto_trading/static/chart.js +0 -362
- bitunix_automated_crypto_trading/static/modal.css +0 -68
- bitunix_automated_crypto_trading/static/modal.js +0 -147
- bitunix_automated_crypto_trading/static/script.js +0 -166
- bitunix_automated_crypto_trading/static/styles.css +0 -118
- bitunix_automated_crypto_trading/templates/charts.html +0 -98
- bitunix_automated_crypto_trading/templates/login.html +0 -19
- bitunix_automated_crypto_trading/templates/main.html +0 -551
- bitunix_automated_crypto_trading/templates/modal-chart.html +0 -26
- bitunix_automated_crypto_trading/templates/modal-config.html +0 -34
- bitunix_automated_crypto_trading/templates/modal-logs.html +0 -15
- bitunix_automated_crypto_trading-2.6.7.dist-info/RECORD +0 -31
- {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/WHEEL +0 -0
- {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/entry_points.txt +0 -0
- {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/top_level.txt +0 -0
@@ -1,23 +1,23 @@
|
|
1
|
-
from datetime import datetime
|
2
|
-
import pytz
|
3
|
-
from
|
4
|
-
logger = Logger(__name__).get_logger()
|
5
|
-
|
6
|
-
class NotificationManager:
|
7
|
-
def __init__(self, max_size=100):
|
8
|
-
self.max_size = max_size
|
9
|
-
self.notifications = []
|
10
|
-
|
11
|
-
def add_notification(self, notification):
|
12
|
-
# Add the new notification at the top
|
13
|
-
timezone = pytz.timezone('America/Chicago')
|
14
|
-
timestamp = datetime.now(timezone).strftime('%Y-%m-%d %H:%M:%S')
|
15
|
-
self.notifications.insert(0, f'({timestamp}) {notification}')
|
16
|
-
logger.info(f'({timestamp}) {notification}')
|
17
|
-
# Ensure the list doesn't exceed the maximum size
|
18
|
-
if len(self.notifications) > self.max_size:
|
19
|
-
self.notifications.pop()
|
20
|
-
|
21
|
-
def get_notifications(self):
|
22
|
-
return self.notifications
|
23
|
-
|
1
|
+
from datetime import datetime
|
2
|
+
import pytz
|
3
|
+
from logger import Logger
|
4
|
+
logger = Logger(__name__).get_logger()
|
5
|
+
|
6
|
+
class NotificationManager:
|
7
|
+
def __init__(self, max_size=100):
|
8
|
+
self.max_size = max_size
|
9
|
+
self.notifications = []
|
10
|
+
|
11
|
+
def add_notification(self, notification):
|
12
|
+
# Add the new notification at the top
|
13
|
+
timezone = pytz.timezone('America/Chicago')
|
14
|
+
timestamp = datetime.now(timezone).strftime('%Y-%m-%d %H:%M:%S')
|
15
|
+
self.notifications.insert(0, f'({timestamp}) {notification}')
|
16
|
+
logger.info(f'({timestamp}) {notification}')
|
17
|
+
# Ensure the list doesn't exceed the maximum size
|
18
|
+
if len(self.notifications) > self.max_size:
|
19
|
+
self.notifications.pop()
|
20
|
+
|
21
|
+
def get_notifications(self):
|
22
|
+
return self.notifications
|
23
|
+
|
@@ -1,69 +1,69 @@
|
|
1
|
-
#usage
|
2
|
-
#start threads
|
3
|
-
#self.threadManager.start_thread("GetportfolioData", 1, self.GetportfolioData)
|
4
|
-
#self.threadManager.start_thread("GetPendingPositionData", 0, self.GetPendingPositionData)
|
5
|
-
#self.threadManager.start_thread("GetOrderData", 1, self.GetPendingOrderData)
|
6
|
-
#self.threadManager.start_thread("GetTradeHistoryData", 1, self.GetTradeHistoryData)
|
7
|
-
#self.threadManager.start_thread("BuySellList", 60, self.BuySellList)
|
8
|
-
#self.threadManager.start_thread("AutoTradeProcess", 60, self.AutoTradeProcess)
|
9
|
-
|
10
|
-
import time
|
11
|
-
import threading
|
12
|
-
from
|
13
|
-
logger = Logger(__name__).get_logger()
|
14
|
-
|
15
|
-
def job_func(*args, **kwargs):
|
16
|
-
print(f"Job running with arguments: {args}, {kwargs}")
|
17
|
-
|
18
|
-
def run_threaded(job_func, args):
|
19
|
-
job_thread = threading.Thread(target=job_func, args=args)
|
20
|
-
job_thread.start()
|
21
|
-
|
22
|
-
class ManagedThread(threading.Thread):
|
23
|
-
def __init__(self, interval, target, *args, **kwargs):
|
24
|
-
super().__init__()
|
25
|
-
self.target = target
|
26
|
-
self.interval = interval
|
27
|
-
self.args = args
|
28
|
-
self.kwargs = kwargs
|
29
|
-
self._stop_event = threading.Event()
|
30
|
-
|
31
|
-
def run(self):
|
32
|
-
while not self._stop_event.is_set():
|
33
|
-
stime=time.time()
|
34
|
-
try:
|
35
|
-
self.target(self, *self.args, **self.kwargs)
|
36
|
-
except Exception as e:
|
37
|
-
logger.info(f"error in thread {self.name}, {e}, {e.args}, {type(e).__name__}")
|
38
|
-
elapsed_time = time.time() - stime
|
39
|
-
if self.interval==0:
|
40
|
-
break
|
41
|
-
time_to_wait = max(0.05, self.interval - elapsed_time)
|
42
|
-
time.sleep(time_to_wait)
|
43
|
-
|
44
|
-
def stop(self):
|
45
|
-
self._stop_event.set()
|
46
|
-
|
47
|
-
def should_stop(self):
|
48
|
-
return self._stop_event.is_set()
|
49
|
-
|
50
|
-
class ThreadManager:
|
51
|
-
def __init__(self):
|
52
|
-
self.threads = []
|
53
|
-
|
54
|
-
def start_thread(self, name, interval, thread, *args, **kwargs):
|
55
|
-
thread = ManagedThread(interval, thread, *args, **kwargs)
|
56
|
-
thread.name = name
|
57
|
-
thread.start()
|
58
|
-
self.threads.append(thread)
|
59
|
-
thread.join(interval)
|
60
|
-
return thread
|
61
|
-
|
62
|
-
def stop_all_threads(self):
|
63
|
-
for thread in self.threads:
|
64
|
-
thread.stop()
|
65
|
-
for thread in self.threads:
|
66
|
-
thread.join()
|
67
|
-
self.threads = []
|
68
|
-
|
1
|
+
#usage
|
2
|
+
#start threads
|
3
|
+
#self.threadManager.start_thread("GetportfolioData", 1, self.GetportfolioData)
|
4
|
+
#self.threadManager.start_thread("GetPendingPositionData", 0, self.GetPendingPositionData)
|
5
|
+
#self.threadManager.start_thread("GetOrderData", 1, self.GetPendingOrderData)
|
6
|
+
#self.threadManager.start_thread("GetTradeHistoryData", 1, self.GetTradeHistoryData)
|
7
|
+
#self.threadManager.start_thread("BuySellList", 60, self.BuySellList)
|
8
|
+
#self.threadManager.start_thread("AutoTradeProcess", 60, self.AutoTradeProcess)
|
9
|
+
|
10
|
+
import time
|
11
|
+
import threading
|
12
|
+
from logger import Logger
|
13
|
+
logger = Logger(__name__).get_logger()
|
14
|
+
|
15
|
+
def job_func(*args, **kwargs):
|
16
|
+
print(f"Job running with arguments: {args}, {kwargs}")
|
17
|
+
|
18
|
+
def run_threaded(job_func, args):
|
19
|
+
job_thread = threading.Thread(target=job_func, args=args)
|
20
|
+
job_thread.start()
|
21
|
+
|
22
|
+
class ManagedThread(threading.Thread):
|
23
|
+
def __init__(self, interval, target, *args, **kwargs):
|
24
|
+
super().__init__()
|
25
|
+
self.target = target
|
26
|
+
self.interval = interval
|
27
|
+
self.args = args
|
28
|
+
self.kwargs = kwargs
|
29
|
+
self._stop_event = threading.Event()
|
30
|
+
|
31
|
+
def run(self):
|
32
|
+
while not self._stop_event.is_set():
|
33
|
+
stime=time.time()
|
34
|
+
try:
|
35
|
+
self.target(self, *self.args, **self.kwargs)
|
36
|
+
except Exception as e:
|
37
|
+
logger.info(f"error in thread {self.name}, {e}, {e.args}, {type(e).__name__}")
|
38
|
+
elapsed_time = time.time() - stime
|
39
|
+
if self.interval==0:
|
40
|
+
break
|
41
|
+
time_to_wait = max(0.05, self.interval - elapsed_time)
|
42
|
+
time.sleep(time_to_wait)
|
43
|
+
|
44
|
+
def stop(self):
|
45
|
+
self._stop_event.set()
|
46
|
+
|
47
|
+
def should_stop(self):
|
48
|
+
return self._stop_event.is_set()
|
49
|
+
|
50
|
+
class ThreadManager:
|
51
|
+
def __init__(self):
|
52
|
+
self.threads = []
|
53
|
+
|
54
|
+
def start_thread(self, name, interval, thread, *args, **kwargs):
|
55
|
+
thread = ManagedThread(interval, thread, *args, **kwargs)
|
56
|
+
thread.name = name
|
57
|
+
thread.start()
|
58
|
+
self.threads.append(thread)
|
59
|
+
thread.join(interval)
|
60
|
+
return thread
|
61
|
+
|
62
|
+
def stop_all_threads(self):
|
63
|
+
for thread in self.threads:
|
64
|
+
thread.stop()
|
65
|
+
for thread in self.threads:
|
66
|
+
thread.join()
|
67
|
+
self.threads = []
|
68
|
+
|
69
69
|
threadManager = ThreadManager()
|