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.
Files changed (31) hide show
  1. bitunix_automated_crypto_trading/AsyncThreadRunner.py +81 -81
  2. bitunix_automated_crypto_trading/BitunixApi.py +278 -278
  3. bitunix_automated_crypto_trading/BitunixSignal.py +1099 -1099
  4. bitunix_automated_crypto_trading/BitunixWebSocket.py +254 -254
  5. bitunix_automated_crypto_trading/DataFrameHtmlRenderer.py +74 -74
  6. bitunix_automated_crypto_trading/NotificationManager.py +23 -23
  7. bitunix_automated_crypto_trading/ThreadManager.py +68 -68
  8. bitunix_automated_crypto_trading/TickerManager.py +635 -635
  9. bitunix_automated_crypto_trading/bitunix.py +597 -594
  10. bitunix_automated_crypto_trading/config.py +90 -90
  11. bitunix_automated_crypto_trading/logger.py +84 -84
  12. {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/METADATA +36 -36
  13. bitunix_automated_crypto_trading-2.6.8.dist-info/RECORD +17 -0
  14. bitunix_automated_crypto_trading/config.txt +0 -60
  15. bitunix_automated_crypto_trading/sampleenv.txt +0 -5
  16. bitunix_automated_crypto_trading/static/chart.css +0 -28
  17. bitunix_automated_crypto_trading/static/chart.js +0 -362
  18. bitunix_automated_crypto_trading/static/modal.css +0 -68
  19. bitunix_automated_crypto_trading/static/modal.js +0 -147
  20. bitunix_automated_crypto_trading/static/script.js +0 -166
  21. bitunix_automated_crypto_trading/static/styles.css +0 -118
  22. bitunix_automated_crypto_trading/templates/charts.html +0 -98
  23. bitunix_automated_crypto_trading/templates/login.html +0 -19
  24. bitunix_automated_crypto_trading/templates/main.html +0 -551
  25. bitunix_automated_crypto_trading/templates/modal-chart.html +0 -26
  26. bitunix_automated_crypto_trading/templates/modal-config.html +0 -34
  27. bitunix_automated_crypto_trading/templates/modal-logs.html +0 -15
  28. bitunix_automated_crypto_trading-2.6.7.dist-info/RECORD +0 -31
  29. {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/WHEEL +0 -0
  30. {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/entry_points.txt +0 -0
  31. {bitunix_automated_crypto_trading-2.6.7.dist-info → bitunix_automated_crypto_trading-2.6.8.dist-info}/top_level.txt +0 -0
@@ -1,166 +0,0 @@
1
- function toggleDropdown() {
2
- const dropdownContent = document.getElementById("dropdown-content");
3
- dropdownContent.classList.toggle("show");
4
-
5
- // Adjust the position if the dropdown is near the bottom of the viewport
6
- const rect = dropdownContent.getBoundingClientRect();
7
- if (rect.bottom > window.innerHeight) {
8
- dropdownContent.style.top = `-${rect.height}px`;
9
- } else {
10
- dropdownContent.style.top = '100%';
11
- }
12
- }
13
-
14
- function displayNotifications(messages) {
15
- const lastMessage = document.getElementById("message");
16
- const dropdownContent = document.getElementById("dropdown-content");
17
-
18
- // Display the last message
19
- lastMessage.textContent = messages[0];
20
- // Display the rest of the messages in the dropdown
21
- dropdownContent.innerHTML = '';
22
- messages.slice(0).reverse().forEach(message => {
23
- const div = document.createElement("div");
24
- div.textContent = message;
25
- dropdownContent.appendChild(div);
26
- });
27
- }
28
-
29
-
30
- // Attach click event to a table and handle cell clicks dynamically
31
- function attachTableClickHandler(tableId, targetColumnIndex, endpoint) {
32
- const table = document.getElementById(tableId);
33
-
34
- if (!table) {
35
- console.error(`Table with ID "${tableId}" not found.`);
36
- return;
37
- }
38
-
39
- table.addEventListener('click', async (event) => {
40
- const target = event.target;
41
- const columnIndex = target.cellIndex;
42
-
43
- // Check if clicked element is a TD and matches the target column index
44
- if (target.tagName === 'TD' && columnIndex === targetColumnIndex) {
45
- const row = target.parentNode;
46
-
47
- const headerCell = target
48
- .closest('table')
49
- .querySelector(`thead tr th:nth-child(${columnIndex + 1})`);
50
-
51
- const columnName = headerCell ? headerCell.innerText : `Column ${columnIndex + 1}`;
52
-
53
- try {
54
- const symbol = row.cells[targetColumnIndex].innerText;
55
-
56
- const response = await fetch(endpoint, {
57
- method: 'POST',
58
- headers: {
59
- 'Content-Type': 'application/x-www-form-urlencoded',
60
- },
61
- body: `symbol=${encodeURIComponent(symbol)}`, // Sanitize input
62
- });
63
-
64
- if (!response.ok) {
65
- throw new Error(`HTTP error! Status: ${response.status}`);
66
- }
67
-
68
- const result = await response.json();
69
- openURL(result.message); // Call the custom openURL function
70
- } catch (error) {
71
- console.error(`Error fetching data for column "${columnName}":`, error);
72
- alert("An error occurred while processing your request.");
73
- }
74
- }
75
- });
76
- }
77
-
78
- // Attach click event to a table and handle cell clicks dynamically
79
- function attachTableClickHandlerFunction(tableId, targetColumnIndex, func) {
80
- const table = document.getElementById(tableId);
81
-
82
- if (!table) {
83
- console.error(`Table with ID "${tableId}" not found.`);
84
- return;
85
- }
86
-
87
- table.addEventListener('click', async (event) => {
88
- const target = event.target;
89
- const columnIndex = target.cellIndex;
90
-
91
- // Check if clicked element is a TD and matches the target column index
92
- if (target.tagName === 'TD' && columnIndex === targetColumnIndex) {
93
- const row = target.parentNode;
94
-
95
- const headerCell = target
96
- .closest('table')
97
- .querySelector(`thead tr th:nth-child(${columnIndex + 1})`);
98
-
99
- const columnName = headerCell ? headerCell.innerText : `Column ${columnIndex + 1}`;
100
- const symbol = row.cells[targetColumnIndex].innerText;
101
-
102
- try {
103
- func(symbol);
104
- } catch (error) {
105
- alert("An error occurred while processing your request.");
106
- }
107
- }
108
- });
109
- }
110
-
111
- function openURL(url) {
112
- window.location.href = url;
113
- }
114
-
115
- // Batch Save State to Server
116
- async function saveStates(states) {
117
- let response, data;
118
-
119
- // Send a POST request to /save_states with the states object
120
- response = await fetch('/save_states', {
121
- method: 'POST',
122
- headers: {
123
- 'Content-Type': 'application/json',
124
- },
125
- body: JSON.stringify(states), // Pass the states as a JSON object
126
- });
127
-
128
- // Parse the response
129
- data = await response.json();
130
-
131
- // Log the server's response
132
- console.log(data.message); // Should print "States saved" if successful
133
- }
134
-
135
- // Batch Fetch State from Server
136
- async function fetchStates(payload) {
137
- // Send a POST request to /get_states with the list of element IDs
138
- const response = await fetch('/get_states', {
139
- method: 'POST',
140
- headers: {
141
- 'Content-Type': 'application/json',
142
- },
143
- body: JSON.stringify(payload), // Pass element IDs in the request body
144
- });
145
-
146
- // Parse the JSON response
147
- data = await response.json();
148
-
149
- // Iterate over the states and update the UI elements accordingly
150
- for (const elementId of payload.element_ids) {
151
- const state = data.states[elementId] || "No state found";
152
-
153
- if (state !== "No state found") {
154
- const element = document.getElementById(elementId);
155
- if (element) {
156
- if (element.type === 'checkbox') {
157
- element.checked = (state.toString().toLowerCase() === "true");
158
- } else if (element.tagName === 'SELECT' || element.tagName === 'INPUT') {
159
- element.value = state;
160
- }
161
- }
162
- }
163
- }
164
- }
165
-
166
-
@@ -1,118 +0,0 @@
1
- body {
2
- margin: 0;
3
- display: flex;
4
- flex-direction: column;
5
- height: 100vh;
6
- }
7
-
8
- header {
9
- background: #f8f9fa;
10
- padding: 1em;
11
- text-align: center;
12
- position: fixed;
13
- top: 0;
14
- width: 100%;
15
- z-index: 1;
16
- }
17
-
18
- footer {
19
- background: #f8f9fa;
20
- padding: 1em;
21
- text-align: center;
22
- position: fixed;
23
- bottom: 0;
24
- width: 100%;
25
- z-index: 1;
26
- }
27
-
28
- .mainbody {
29
- flex: 1;
30
- margin-top: 1px; /* Adjust this value according to the height of your header */
31
- margin-bottom: 60px; /* Adjust this value according to the height of your footer */
32
- overflow-y: auto;
33
- padding: 1em;
34
- }
35
-
36
- .row {
37
- display: block;
38
- margin-bottom: 10px;
39
- border: 2px solid black;
40
- padding: 10px;
41
- }
42
-
43
- .container {
44
- display: flex;
45
- justify-content: space-between;
46
- }
47
-
48
- .left, .right {
49
- width: 45%;
50
- padding: 10px;
51
- border: 1px solid black;
52
- }
53
-
54
- .message {
55
- background-color: #3a4141 ;
56
- color: white;
57
- padding: 16px;
58
- font-size: 16px;
59
- border: none;
60
- cursor: pointer;
61
- }
62
-
63
- .dropdown-content {
64
- display: none;
65
- position: absolute;
66
- background-color: #f9f9f9;
67
- min-width: 250px;
68
- box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
69
- z-index: 1;
70
- }
71
-
72
- .dropdown-content div {
73
- color: black;
74
- padding: 12px 16px;
75
- text-decoration: none;
76
- display: block;
77
- }
78
-
79
- .dropdown-content div:hover {
80
- background-color: #f1f1f1;
81
- }
82
-
83
- .show {
84
- display: block;
85
- }
86
-
87
- table {
88
- border-collapse: collapse;
89
- width: 100%;
90
- }
91
-
92
- th, td {
93
- text-align: left;
94
- padding: 8px;
95
- }
96
-
97
- th {
98
- background-color: #f4f4f4;
99
- }
100
-
101
- tr:nth-child(even) {
102
- background-color: #f9f9f9;
103
- }
104
-
105
- tr:hover {
106
- background-color: #f1f1f1;
107
- cursor: pointer;
108
- }
109
-
110
- @media (max-width: 768px) {
111
- body, p, span, div {
112
- font-size: 8px;
113
- padding: 5px;
114
- }
115
- h1 {
116
- font-size: 20px;
117
- }
118
- }
@@ -1,98 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
- <title>Candlestick Chart</title>
6
- <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
7
- <script src="https://cdn.jsdelivr.net/npm/chartjs-chart-financial"></script>
8
- <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns"></script>
9
- <link rel="stylesheet" href="static/styles.css">
10
- <link rel="stylesheet" href="static/chart.css">
11
- </head>
12
- <body>
13
- <div class="chart-body">
14
- <div class="chart-grid">
15
- <div class="right">
16
- <div class="label">Symbol</div>
17
- <div id='symbol'></div>
18
- </div>
19
- <div class="right">
20
- <div class="label">Close</div>
21
- <div id='close'></div>
22
- </div>
23
- <div id="chart1m" class="chart-container"> </div>
24
- <div id="chart5m" class="chart-container"> </div>
25
- <div id="chart15m" class="chart-container"> </div>
26
- <div id="chart1h" class="chart-container"> </div>
27
- <div id="chart1d" class="chart-container"> </div>
28
- </div>
29
- </div>
30
- <script src="/static/chart.js"></script>
31
- <script>
32
- function getQueryParam(param) {
33
- const urlParams = new URLSearchParams(window.location.search);
34
- return urlParams.get(param);
35
- }
36
- const symbol = getQueryParam('symbol');
37
-
38
- const host = window.location.hostname;
39
- const websocket = new WebSocket(`ws://${host}:8000/wscharts?ticker=${symbol}`);
40
- websocket.onopen = function() {
41
- // Send a ping every 30 seconds
42
- setInterval(() => {
43
- if (websocket.readyState === WebSocket.OPEN) {
44
- websocket.send("ping");
45
- }
46
- }, 30000);
47
- }
48
-
49
- websocket.onmessage = function(event) {
50
- if (event.data === "pong") {
51
- return;
52
- }
53
- const messageElement = JSON.parse(event.data);
54
- document.getElementById('symbol').innerHTML = messageElement.symbol;
55
- document.getElementById('close').innerHTML = messageElement.close;
56
-
57
- const data1m = messageElement.chart1m;
58
- const data5m = messageElement.chart5m;
59
- const data15m = messageElement.chart15m;
60
- const data1h = messageElement.chart1h;
61
- const data1d = messageElement.chart1d;
62
- const buysell = messageElement.buysell;
63
- const ema_study = messageElement.ema_study;
64
- const ema_chart = messageElement.ema_chart;
65
- const macd_study = messageElement.macd_study;
66
- const macd_chart = messageElement.macd_chart;
67
- const bbm_study = messageElement.bbm_study;
68
- const bbm_chart = messageElement.bbm_chart;
69
- const rsi_study = messageElement.rsi_study;
70
- const rsi_chart = messageElement.rsi_chart;
71
-
72
-
73
- createOrUpdateChart('chart1m', data1m, buysell, ema_study, ema_chart, macd_study, macd_chart, bbm_study, bbm_chart, rsi_study, rsi_chart, 'minute');
74
- createOrUpdateChart('chart5m', data5m, buysell, ema_study, ema_chart, macd_study, macd_chart, bbm_study, bbm_chart, rsi_study, rsi_chart, 'minute');
75
- createOrUpdateChart('chart15m', data15m, buysell, ema_study, ema_chart, macd_study, macd_chart, bbm_study, bbm_chart, rsi_study, rsi_chart, 'minute');
76
- createOrUpdateChart('chart1h', data1h, buysell, ema_study, ema_chart, macd_study, macd_chart, bbm_study, bbm_chart, rsi_study, rsi_chart, 'hour');
77
- createOrUpdateChart('chart1d', data1d, buysell, ema_study, ema_chart, macd_study, macd_chart, bbm_study, bbm_chart, rsi_study, rsi_chart, 'day');
78
- };
79
-
80
- websocket.onerror = function(error) {
81
- };
82
-
83
- websocket.onclose = function() {
84
- charts.forEach(chart => {
85
- delete charts[chart];
86
- });
87
- };
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
- </script>
97
- </body>
98
- </html>
@@ -1,19 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
- <title>Login</title>
6
- </head>
7
- <body>
8
- <h1>Login</h1>
9
- <form action="/auth/login" method="post">
10
- <label for="username">Username:</label>
11
- <input type="text" id="username" name="username">
12
- <br>
13
- <label for="password">Password:</label>
14
- <input type="password" id="password" name="password">
15
- <br>
16
- <button type="submit">Login</button>
17
- </form>
18
- </body>
19
- </html>