28 lines
899 B
Python
28 lines
899 B
Python
import asyncio
|
|
from exchanges.binance import BinancePerpStream
|
|
from exchanges.okx import OKXPerpStream
|
|
from exchanges.bybit import BybitPerpStream
|
|
from exchanges.hyperliquid import HyperliquidPerpStream
|
|
from logger import log_opportunity
|
|
from spread_calculator import check_arbitrage_opportunities
|
|
|
|
latest_ticks = {}
|
|
|
|
async def consumer(exchange, stream):
|
|
async for tick in stream():
|
|
latest_ticks[(tick['exchange'], tick['symbol'])] = tick
|
|
opportunities = check_arbitrage_opportunities(tick, latest_ticks)
|
|
for opp in opportunities:
|
|
log_opportunity(opp)
|
|
|
|
async def main():
|
|
tasks = [
|
|
consumer('binance', BinancePerpStream(["USDT"]).stream),
|
|
consumer('okx', OKXPerpStream(["USDT"]).stream),
|
|
consumer('bybit', BybitPerpStream(["USDT"]).stream)
|
|
]
|
|
await asyncio.gather(*tasks)
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|