import ccxt import json import sys import time with open(f"../configs/{sys.argv[1]}.json") as k: config = json.load(k) #Load exchange keys pwd = config["password"] if "password" in config else "" exch = sys.argv[1] if exch=="okex": exch="okx" exchange_class = getattr(ccxt, sys.argv[1]) exchange = exchange_class({ "apiKey": config["key"], "secret": config["secret"], "password": pwd, "timeout": 30000, "enableRateLimit": True, }) exchange.load_markets() open_orders = [] pairs = {} def add_pair_to_dict(pair): if pair not in pairs: pairs[pair] = 1 else: pairs[pair] += 1 if sys.argv[1]=="binance": for p in config["pairs"]: print(f"Fetching {p}") orders = exchange.fetch_open_orders(symbol=p) time.sleep(.5) open_orders.extend(orders) else: open_orders = exchange.fetch_open_orders() for order in open_orders: if order["side"]=="buy": add_pair_to_dict(order["symbol"]) found = False for x in pairs: if pairs[x]>1: print(x,pairs[x]) orders = exchange.fetch_open_orders(symbol=x) for order in orders: if order["side"]=="buy": print(order) found = True if not found: print("No duplicates found")