websocker WIP
This commit is contained in:
44
src/bybit.py
44
src/bybit.py
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user