diff --git a/src/bybit.py b/src/bybit.py index 8aa2764..1850452 100644 --- a/src/bybit.py +++ b/src/bybit.py @@ -33,6 +33,8 @@ async def getClient(apiKey, apiSecret, testnet): def handlePrice(message): + if message['price'] == '': + print('meow') print(message) @@ -41,10 +43,23 @@ def handleMessage(message): async def socketStrategy(pair: str, params): + print('Starting strategy with ', pair) + + # 'highEnd', + # 'lowEnd', + # 'highBreak', + # 'lowBreak', + # 'netLevelsAmount', + # 'takeDelta', + # 'stopDelta', + # 'orderSize' + + paramsDict = await arbus.parseParams(params) + ws = WebSocket( testnet = options.testnet, channel_type = options.category, - callback = handleMessage + # callback = handleMessage ) ws_private = WebSocket( @@ -52,13 +67,15 @@ async def socketStrategy(pair: str, params): channel_type = "private", api_key = credentials.api_key, api_secret = credentials.api_secret, - callback = handleMessage - # trace_logging = True, + # callback = handleMessage + # trace_logging = True ) + print(ws.is_connected()) + ws.ticker_stream( symbol = pair, - callback = handleMessage + callback = handlePrice ) i = 0 @@ -66,6 +83,8 @@ async def socketStrategy(pair: str, params): while t: t = await arbus.checkPair(pair) if t != 1: + # ws.exit() + # ws_private.exit() break await asyncio.sleep(options.loopSleepTime) i += 1 @@ -104,13 +123,10 @@ async def strategy(client: HTTP, pair: str, params): marketUnit = 'quoteCoin' ) - print(r2, '\n') if r2['retMsg'] == 'OK': print('Order placed succesfully!') - - await asyncio.sleep(20) i += 1 diff --git a/src/main.py b/src/main.py index 354cf54..037d28d 100644 --- a/src/main.py +++ b/src/main.py @@ -107,8 +107,8 @@ async def capture_params(message: Message, state: FSMContext): if client == -1: msg_text = (f'Аутентификация не удалась, сообщите администратору если увидете данное сообщение.') else: - asyncio.create_task(bybit.socketStrategy( data.get("pair"), data.get("params"))) - asyncio.create_task(bybit.strategy(client, data.get("pair"), data.get("params"))) + asyncio.create_task(bybit.socketStrategy(data.get("pair"), data.get("params"))) + # asyncio.create_task(bybit.strategy(client, data.get("pair"), data.get("params"))) msg_text = (f'Вы запустили стратегию на паре {data.get("pair")} с данными параметрами:\n{data.get("params")}\n') elif t == -1: msg_text = (f'Параметры введены в неверном формате, пожалуйста начните заново.') diff --git a/src/options.py b/src/options.py index 6556af7..9c4e7bf 100644 --- a/src/options.py +++ b/src/options.py @@ -11,7 +11,8 @@ leverage = 1 # Leverage notification = 1 # Telegram notifications (not currently supported) -loopSleepTime = 20 # Time passing between loops/checks +marketBuyRange = 0.5 +loopSleepTime = 1 # Time passing between loops/checks paramsLines = ['highEnd', 'lowEnd',