websocker WIP

This commit is contained in:
2025-04-27 16:59:31 +03:00
parent de13a172e9
commit bf0eecc213
3 changed files with 50 additions and 3 deletions

View File

@ -2,6 +2,7 @@ import time
import asyncio
from pybit.unified_trading import HTTP
from pybit.unified_trading import WebSocket
import options
import credentials
@ -31,6 +32,49 @@ async def getClient(apiKey, apiSecret, testnet):
return -1
def handlePrice(message):
print(message)
def handleMessage(message):
print(message)
async def socketStrategy(pair: str, params):
ws = WebSocket(
testnet = options.testnet,
channel_type = options.category,
callback = handleMessage
)
ws_private = WebSocket(
testnet = options.testnet,
channel_type = "private",
api_key = credentials.api_key,
api_secret = credentials.api_secret,
callback = handleMessage
# trace_logging = True,
)
ws.ticker_stream(
symbol = pair,
callback = handleMessage
)
i = 0
t = await arbus.checkPair(pair)
while t:
t = await arbus.checkPair(pair)
if t != 1:
break
await asyncio.sleep(options.loopSleepTime)
i += 1
print('Ending strategy with ', pair)
print('Ended on the iteration number ', i)
return i
async def strategy(client: HTTP, pair: str, params):
startTime = time.time()
print('Starting strategy with ', pair)