[go: up one dir, main page]

0% found this document useful (0 votes)
18 views2 pages

Arbitrage Checker - Py

The document is a Python script that checks for arbitrage opportunities across multiple cryptocurrency exchanges using the CCXT library. It initializes a list of exchanges, fetches price data for specific trading pairs, and identifies potential profit opportunities by comparing bid and ask prices. The script runs in a loop, continuously checking for arbitrage opportunities every 30 seconds and displaying the top five profitable trades.

Uploaded by

potro451980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Arbitrage Checker - Py

The document is a Python script that checks for arbitrage opportunities across multiple cryptocurrency exchanges using the CCXT library. It initializes a list of exchanges, fetches price data for specific trading pairs, and identifies potential profit opportunities by comparing bid and ask prices. The script runs in a loop, continuously checking for arbitrage opportunities every 30 seconds and displaying the top five profitable trades.

Uploaded by

potro451980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import ccxt

import time

# List of exchanges to check for arbitrage


exchange_ids = [
'binance', 'okx', 'gateio', 'bitmex', 'bitget', 'bybit', 'kucoin',
'bitmart', 'mexc', 'huobi','exmo', 'coinex', 'bitvavo', 'bit2me'
]

# Initialize exchanges
exchanges = {}
for exchange_id in exchange_ids:
try:
exchange_class = getattr(ccxt, exchange_id)
exchange = exchange_class({
'enableRateLimit': True,
})
exchanges[exchange_id] = exchange
except Exception as e:
print(f"Error loading {exchange_id}: {e}")

# Markets to analyze for arbitrage


symbol = 'BTC/USDT', 'ETH/USDT', 'NEO/USDT', 'EURC/USDT', 'EURC/EUR', 'EURC/USDC',
'EURT/USDT'

def fetch_prices(symbol):
prices = {}
for name, exchange in exchanges.items():
try:
ticker = exchange.fetch_ticker(symbol)
bid = ticker.get('bid')
ask = ticker.get('ask')
if bid and ask:
prices[name] = {'bid': bid, 'ask': ask}
except Exception as e:
print(f"Error fetching ticker from {name}: {e}")
return prices

def find_arbitrage_opportunities(prices):
opportunities = []
for ex1, data1 in prices.items():
for ex2, data2 in prices.items():
if ex1 != ex2:
buy_price = data2['ask']
sell_price = data1['bid']
profit = sell_price - buy_price
if profit > 0:
opportunities.append({
'buy_from': ex2,
'sell_to': ex1,
'buy_price': buy_price,
'sell_price': sell_price,
'profit': profit
})
return sorted(opportunities, key=lambda x: x['profit'], reverse=True)

# Main script
if __name__ == "__main__":
while True:
print("Checking for arbitrage opportunities...")
prices = fetch_prices(symbol)
if prices:
opportunities = find_arbitrage_opportunities(prices)
for opp in opportunities[:5]: # Top 5
print(
f"Buy from {opp['buy_from']} at {opp['buy_price']:.2f}, "
f"Sell to {opp['sell_to']} at {opp['sell_price']:.2f}, "
f"Profit: {opp['profit']:.2f}"
)
else:
print("No price data found.")
time.sleep(30) # Wait before next check

You might also like