bitunix-automated-crypto-trading 3.0.2__py3-none-any.whl → 3.0.5__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/BitunixSignal.py +24 -82
- {bitunix_automated_crypto_trading-3.0.2.dist-info → bitunix_automated_crypto_trading-3.0.5.dist-info}/METADATA +1 -1
- {bitunix_automated_crypto_trading-3.0.2.dist-info → bitunix_automated_crypto_trading-3.0.5.dist-info}/RECORD +6 -6
- {bitunix_automated_crypto_trading-3.0.2.dist-info → bitunix_automated_crypto_trading-3.0.5.dist-info}/WHEEL +0 -0
- {bitunix_automated_crypto_trading-3.0.2.dist-info → bitunix_automated_crypto_trading-3.0.5.dist-info}/entry_points.txt +0 -0
- {bitunix_automated_crypto_trading-3.0.2.dist-info → bitunix_automated_crypto_trading-3.0.5.dist-info}/top_level.txt +0 -0
@@ -17,6 +17,7 @@ logger = Logger(__name__).get_logger()
|
|
17
17
|
colors = Colors()
|
18
18
|
import gc
|
19
19
|
from concurrent.futures import ProcessPoolExecutor
|
20
|
+
import sqlite3
|
20
21
|
|
21
22
|
cst = pytz.timezone('US/Central')
|
22
23
|
|
@@ -84,6 +85,11 @@ class BitunixSignal:
|
|
84
85
|
self.lastAutoTradeTime = time.time()
|
85
86
|
self.lastTickerDataTime = time.time()
|
86
87
|
|
88
|
+
#sqllite database connection
|
89
|
+
self.connection = sqlite3.connect("bitunix.db")
|
90
|
+
self.cursor = self.connection.cursor()
|
91
|
+
self.cursor.execute("CREATE TABLE IF NOT EXISTS benchmark (id INTEGER PRIMARY KEY, process_name TEXT, time INTEGER)")
|
92
|
+
|
87
93
|
async def update_settings(self, settings):
|
88
94
|
self.settings = settings
|
89
95
|
self.tickerObjects.update_settings(settings)
|
@@ -129,38 +135,6 @@ class BitunixSignal:
|
|
129
135
|
self.GetPositionHistoryDataTask = AsyncThreadRunner(self.GetPositionHistoryData, interval=int(self.settings.POSITION_HISTORY_API_INTERVAL))
|
130
136
|
self.GetPositionHistoryDataTask.start_thread(thread_name="GetPositionHistoryData")
|
131
137
|
|
132
|
-
#run restartable asynch thread
|
133
|
-
await self.restartable_jobs()
|
134
|
-
|
135
|
-
async def restart_jobs(self):
|
136
|
-
|
137
|
-
#stop websocket async thread jobs
|
138
|
-
await self.bitunixPrivateWebSocketClient.stop_websocket()
|
139
|
-
await self.ProcessPrivateDataTask.stop_thread()
|
140
|
-
|
141
|
-
if self.settings.USE_PUBLIC_WEBSOCKET:
|
142
|
-
await self.bitunixPublicDepthWebSocketClient.stop_websocket()
|
143
|
-
await self.UpdateDepthDataTask.stop_thread()
|
144
|
-
|
145
|
-
await self.bitunixPublicTickerWebSocketClient.stop_websocket()
|
146
|
-
await self.UpdateTickerDataTask.stop_thread()
|
147
|
-
|
148
|
-
#kill the loop to restart public websocket
|
149
|
-
#not using for now
|
150
|
-
#await self.restartPublicWebsocketTask.stop_thread()
|
151
|
-
|
152
|
-
#stop onetime / periodic async thread jobs
|
153
|
-
await self.LoadKlineHistoryTask.stop_thread()
|
154
|
-
await self.GetTickerDataTask.stop_thread()
|
155
|
-
await self.AutoTradeProcessTask.stop_thread()
|
156
|
-
|
157
|
-
#start jobs
|
158
|
-
await self.load_tickers()
|
159
|
-
await self.restartable_jobs()
|
160
|
-
|
161
|
-
async def restartable_jobs(self):
|
162
|
-
#start cancelable async jobs
|
163
|
-
#websocket jobs
|
164
138
|
self.ProcessPrivateDataTask = AsyncThreadRunner(self.bitunixPrivateWebSocketClient.run_websocket, 0, self.ProcessPrivateData)
|
165
139
|
self.ProcessPrivateDataTask.start_thread(thread_name="ProcessPrivateData")
|
166
140
|
|
@@ -184,39 +158,6 @@ class BitunixSignal:
|
|
184
158
|
self.AutoTradeProcessTask = AsyncThreadRunner(self.AutoTradeProcess, interval=int(self.settings.SIGNAL_CHECK_INTERVAL))
|
185
159
|
self.AutoTradeProcessTask.start_thread(thread_name="AutoTradeProcess")
|
186
160
|
|
187
|
-
#start the loop to restart public websocket
|
188
|
-
#if self.settings.USE_PUBLIC_WEBSOCKET:
|
189
|
-
# self.restartPublicWebsocketTask = AsyncThreadRunner(self.restartPublicWebsocket, interval=0)
|
190
|
-
# self.restartPublicWebsocketTask.start_thread(thread_name="restartPublicWebsocket")
|
191
|
-
|
192
|
-
#this is a normal task runing in a async thread, that can be cancelled
|
193
|
-
# this runs in a async thread to stop and start the public websocket, as we found some lagging when it runs continously
|
194
|
-
#not used now
|
195
|
-
async def restartPublicWebsocket(self):
|
196
|
-
while True:
|
197
|
-
await asyncio.sleep(int(self.settings.PUBLIC_WEBSOCKET_RESTART_INTERVAL))
|
198
|
-
|
199
|
-
if self.settings.VERBOSE_LOGGING:
|
200
|
-
self.notifications.add_notification('Restarting public websocket')
|
201
|
-
logger.info(f"Restarting public websocket")
|
202
|
-
|
203
|
-
if self.settings.USE_PUBLIC_WEBSOCKET:
|
204
|
-
await self.UpdateDepthDataTask.stop_thread()
|
205
|
-
await self.UpdateTickerDataTask.stop_thread()
|
206
|
-
|
207
|
-
await asyncio.sleep(30)
|
208
|
-
|
209
|
-
if self.settings.USE_PUBLIC_WEBSOCKET:
|
210
|
-
self.bitunixPublicDepthWebSocketClient.tickerList = self.tickerList
|
211
|
-
self.UpdateDepthDataTask = AsyncThreadRunner(self.bitunixPublicDepthWebSocketClient.run_websocket, 0, self.UpdateDepthData)
|
212
|
-
self.UpdateDepthDataTask.start_thread(thread_name="UpdateDepthData")
|
213
|
-
|
214
|
-
self.bitunixPublicTickerWebSocketClient.tickerList = self.tickerList
|
215
|
-
self.UpdateTickerDataTask = AsyncThreadRunner(self.bitunixPublicTickerWebSocketClient.run_websocket, 0, self.UpdateTickerData)
|
216
|
-
self.UpdateTickerDataTask.start_thread(thread_name="UpdateTickerData")
|
217
|
-
|
218
|
-
if self.settings.VERBOSE_LOGGING:
|
219
|
-
self.notifications.add_notification('Restared public websocket')
|
220
161
|
|
221
162
|
###########################################################################################################
|
222
163
|
async def DefinehtmlRenderers(self):
|
@@ -300,7 +241,7 @@ class BitunixSignal:
|
|
300
241
|
logger.info(f"GetTickerData: elapsed time {time.time()-start}")
|
301
242
|
|
302
243
|
|
303
|
-
#websocket data
|
244
|
+
#websocket data to update ticker lastprice and other relavent data
|
304
245
|
async def UpdateTickerData(self, message):
|
305
246
|
if message=="":
|
306
247
|
return
|
@@ -327,7 +268,7 @@ class BitunixSignal:
|
|
327
268
|
if self.settings.VERBOSE_LOGGING:
|
328
269
|
logger.info(f"Function: UpdateTickerData, time:{ts}, symbol:{symbol}, highest:{highest}, lowest:{lowest}, volume:{volume}, volumeInCurrency:{volumeInCurrency}")
|
329
270
|
|
330
|
-
#websocket data
|
271
|
+
#websocket data to update bid and ask
|
331
272
|
async def UpdateDepthData(self, message):
|
332
273
|
if message=="":
|
333
274
|
return
|
@@ -457,14 +398,14 @@ class BitunixSignal:
|
|
457
398
|
#if not self.settings.USE_PUBLIC_WEBSOCKET:
|
458
399
|
#get bid las ask using api for the symbols in pending psotion
|
459
400
|
if not self.positiondf.empty:
|
460
|
-
if self.settings.USE_PUBLIC_WEBSOCKET:
|
401
|
+
if not self.settings.USE_PUBLIC_WEBSOCKET:
|
461
402
|
await asyncio.create_task(self.apply_last_data(','.join(self.positiondf['symbol'].astype(str).tolist())))
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
403
|
+
await asyncio.gather(
|
404
|
+
*[
|
405
|
+
asyncio.create_task(self.apply_depth_data(row['symbol']))
|
406
|
+
for index, row in self.positiondf.iterrows()
|
407
|
+
]
|
408
|
+
)
|
468
409
|
|
469
410
|
|
470
411
|
except Exception as e:
|
@@ -496,8 +437,9 @@ class BitunixSignal:
|
|
496
437
|
try:
|
497
438
|
self.positionHistoryData = await self.bitunixApi.GetPositionHistoryData()
|
498
439
|
if self.positionHistoryData and 'positionList' in self.positionHistoryData:
|
499
|
-
self.positionHistorydf = pd.DataFrame(self.positionHistoryData['positionList'], columns=["symbol", "side","realizedPNL", "ctime", "maxQty", "closePrice","fee", "funding"])
|
440
|
+
self.positionHistorydf = pd.DataFrame(self.positionHistoryData['positionList'], columns=["symbol", "side","realizedPNL", "ctime", "mtime","maxQty", "closePrice","fee", "funding"])
|
500
441
|
self.positionHistorydf['ctime'] = pd.to_datetime(self.positionHistorydf['ctime'].astype(float), unit='ms').dt.tz_localize('UTC').dt.tz_convert(cst).dt.strftime('%Y-%m-%d %H:%M:%S')
|
442
|
+
self.positionHistorydf['mtime'] = pd.to_datetime(self.positionHistorydf['mtime'].astype(float), unit='ms').dt.tz_localize('UTC').dt.tz_convert(cst).dt.strftime('%Y-%m-%d %H:%M:%S')
|
501
443
|
self.positionHistorydf['charts'] = self.positionHistorydf.apply(self.add_charts_button, axis=1)
|
502
444
|
self.positionHistorydf['bitunix'] = self.positionHistorydf.apply(self.add_bitunix_button, axis=1)
|
503
445
|
|
@@ -597,14 +539,14 @@ class BitunixSignal:
|
|
597
539
|
#get bid las ask using api for max_auto_trades rows
|
598
540
|
if not self.signaldf.empty:
|
599
541
|
m = min(self.signaldf.shape[0], int(self.settings.MAX_AUTO_TRADES))
|
600
|
-
if self.settings.USE_PUBLIC_WEBSOCKET:
|
542
|
+
if not self.settings.USE_PUBLIC_WEBSOCKET:
|
601
543
|
await asyncio.create_task(self.apply_last_data(','.join(self.signaldf['symbol'][:m].astype(str).tolist())))
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
544
|
+
await asyncio.gather(
|
545
|
+
*[
|
546
|
+
asyncio.create_task(self.apply_depth_data(row['symbol']))
|
547
|
+
for index, row in self.signaldf[:m].iterrows()
|
548
|
+
]
|
549
|
+
)
|
608
550
|
|
609
551
|
except Exception as e:
|
610
552
|
logger.info(f"Function: BuySellList, {e}, {e.args}, {type(e).__name__}")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
bitunix_automated_crypto_trading/AsyncThreadRunner.py,sha256=JDpAUiTZLB9KV4tGPonAvAUJyBqZz2-ehblH6vsunz8,3142
|
2
2
|
bitunix_automated_crypto_trading/BitunixApi.py,sha256=wJhknpmVFrckoL89h-nlWUAMsPxhIacY0nOGJT9M6Vw,11360
|
3
|
-
bitunix_automated_crypto_trading/BitunixSignal.py,sha256=
|
3
|
+
bitunix_automated_crypto_trading/BitunixSignal.py,sha256=EP2PW8rXlLObj4ycgUxLH900BlleJzqosAecj6KA45A,60878
|
4
4
|
bitunix_automated_crypto_trading/BitunixWebSocket.py,sha256=mbuvk8UFWKgv4KLV07TgLgxLVTRJnOKuf02mLB-VoCY,11143
|
5
5
|
bitunix_automated_crypto_trading/DataFrameHtmlRenderer.py,sha256=Pqdzhh_nfIxFEZH9L_R5QXB8moDPbgeTGT_hmBkHWMg,2899
|
6
6
|
bitunix_automated_crypto_trading/NotificationManager.py,sha256=pqDquEe-oujD2v8B543524vo62aRMjfB4YW-3DMhVGQ,795
|
@@ -10,8 +10,8 @@ bitunix_automated_crypto_trading/__init__.py,sha256=1hzk6nX8NnUCr1tsq8oFq1qGCNhN
|
|
10
10
|
bitunix_automated_crypto_trading/bitunix.py,sha256=ooahU8kEhibVKYbUBdd2yxvTDiXGSvn1ENmepDoqA1g,24671
|
11
11
|
bitunix_automated_crypto_trading/config.py,sha256=sZ4pXnpFxdN3rqXSyhYnXsb6dUQzvDYW6A4q7fFNO_k,3628
|
12
12
|
bitunix_automated_crypto_trading/logger.py,sha256=FB5g2ZqTUuaIcqrzaUFtp1ZtQi-4STYL_VHLDuv9Ysg,2930
|
13
|
-
bitunix_automated_crypto_trading-3.0.
|
14
|
-
bitunix_automated_crypto_trading-3.0.
|
15
|
-
bitunix_automated_crypto_trading-3.0.
|
16
|
-
bitunix_automated_crypto_trading-3.0.
|
17
|
-
bitunix_automated_crypto_trading-3.0.
|
13
|
+
bitunix_automated_crypto_trading-3.0.5.dist-info/METADATA,sha256=KBLm8zce1nx5w_7m7uY2OGEdsinMvE075LuEywA5HKU,996
|
14
|
+
bitunix_automated_crypto_trading-3.0.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
15
|
+
bitunix_automated_crypto_trading-3.0.5.dist-info/entry_points.txt,sha256=UXREYHuSl2XYd_tOtLIq0zg3d1kX3lixX5SpN8yGBw4,82
|
16
|
+
bitunix_automated_crypto_trading-3.0.5.dist-info/top_level.txt,sha256=uyFzHUCOsp8elnG2Ovor6xXcf7dxRxY-C-Txiwix64Q,33
|
17
|
+
bitunix_automated_crypto_trading-3.0.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|