Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ccxt
- # import library with exchange classes
- import couchdb
- # import library for connecting to database
- import time
- # needed for limiting api call
- # connect to couchdb server
- couch = couchdb.Server()
- """
- # get trading pairs
- def get_trading_pairs( mode = 0 ):
- if( mode == 0 ):
- # read configuration file
- elif( mode == 1 ):
- # get 24h volume rankings by currency
- """
- trading_pairs = ['BTC/USD', 'BTC/EUR', 'BTC/USDT', 'XRP/USD', 'XRP/USDT', 'LTC/USD', 'LTC/USDT']
- exchanges = [ ccxt.bitstamp(), ccxt.bitfinex(), ccxt.gdax(), ccxt.okex() ]
- # checkIfDBExists checks if there is designated database for trading pairs and if not creates it
- def check_if_DB_exists( couchDBServer, trading_symbol = "BTC/USD" ):
- if( trading_symbol not in couchDBServer ):
- couchDBServer.create(trading_symbol)
- # check_if_exch_has_market checks if trading pair exists on exchange
- # return true if it does, false if it doesn't
- def check_if_exch_has_market( exchange, trading_symbol = "BTC/USD" ):
- # get all markets from exchange
- available_markets = exchange.load_markets()
- # check if trading pair exists on exchange
- if((trading_symbol in available_markets)):
- return True
- else:
- return False
- # write_data_to_database
- def write_data_to_database( data, couchDBServer, trading_symbol = "BTC/USD" ):
- couchDBServer[trading_symbol].save(data)
- """
- for pair in trading_pairs:
- check_if_DB_exists(couch, pair)
- """
- exchange_pair_list = {}
- exchange_pairs
- for exchange in exchanges:
- #print(exchange.name)
- exchange_pair_list.append( exchange.name )
- for pair in trading_pairs:
- if( check_if_exch_has_market(exchange, pair) ):
- print("Found trading pair %s in exchange: %s" % (pair, exchange.name))
Add Comment
Please, Sign In to add comment