From dd303b49a980d0cb20cf1d71e8865e731cdbbe95 Mon Sep 17 00:00:00 2001 From: Beesquit Date: Sun, 25 May 2025 23:26:35 +0300 Subject: [PATCH] Small fixes --- src/arbus.py | 2 +- src/bybit.py | 5 ++++- src/jsonProcessing.py | 3 +++ src/main.py | 5 +++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/arbus.py b/src/arbus.py index 0c0d49f..fd9db6c 100644 --- a/src/arbus.py +++ b/src/arbus.py @@ -11,7 +11,7 @@ def setStartTime(): startTime = time.time() def getPnL(pair): - with open("tradingLog.log", "r") as f: + with open("./data/tradingLog.log", "r") as f: lines = f.readlines() logEntries = [] diff --git a/src/bybit.py b/src/bybit.py index a72f2d9..18d5f2b 100644 --- a/src/bybit.py +++ b/src/bybit.py @@ -59,7 +59,7 @@ class tradingData: self.orderSize = orderSize self.priceDecimals, self.qtyDecimals, self.minimumQty = self.getFilters(pair) self.previousPrice = -1 - self.counter = 0 + self.orderCounter = 0 def getBalance(self, pair): @@ -147,6 +147,7 @@ class tradingData: stopLoss = str(sl), tpslMode = "Full" ) + self.orderCounter += 1 orderID = response.get('result').get('orderId') generalLogger.info(f"Placed oder on {self.pair} with TP {tp}; SL {sl}") @@ -209,10 +210,12 @@ class tradingData: j['long'] = False j['longIDs'] = ['-1', '-1', '-1'] generalLogger.info(f"Long order on {self.pair} level {j['price']} triggered TP/SL") + self.orderCounter -= 1 if orderID in shortIDs: j['short'] = False j['shortIDs'] = ['-1', '-1', '-1'] generalLogger.info(f"Short order on {self.pair} level {j['price']} triggered TP/SL") + self.orderCounter -= 1 if orderStatus == 'Filled': for j in self.levels: longIDs = j['longIDs'] diff --git a/src/jsonProcessing.py b/src/jsonProcessing.py index 806da17..0fbafb4 100644 --- a/src/jsonProcessing.py +++ b/src/jsonProcessing.py @@ -32,6 +32,9 @@ async def parseParams(params): # Returnes dictionary of string params as paramsLines in options paramsList = params.split() paramsDict = {} + if len(paramsList) != len(options.paramsLines): + return -1 + for i in range(len(options.paramsLines)): paramsDict[options.paramsLines[i]] = paramsList[i] return paramsDict diff --git a/src/main.py b/src/main.py index 89de3a6..1913b19 100644 --- a/src/main.py +++ b/src/main.py @@ -30,7 +30,8 @@ import options async def set_commands(): commands = [BotCommand(command='start', description='Старт'), BotCommand(command='help', description='Инструкция'), - BotCommand(command='info', description='Статус'), + BotCommand(command='info', description='Информация о стратегиях'), + BotCommand(command='status', description='Статус'), BotCommand(command='strategy', description='Запустить стратегию'), BotCommand(command='stop', description='Остановить стратегию') ] @@ -115,8 +116,8 @@ async def capture_params(message: Message, state: FSMContext): data = await state.get_data() t = await jsonProcessing.savePairParams(pair=data.get("pair"), params=data.get("params")) - params = await jsonProcessing.parseParams(params=data.get("params")) if t == 0: + params = await jsonProcessing.parseParams(params=data.get("params")) client = await bybit.getClient( credentials.api_key, credentials.api_secret,