class PumpDumpCyriptopia: API = () def __init__(self): # setup api KEY, SECRET = self.get_secret() self.API = Api(KEY, SECRET) def get_secret(self): return str(config.api_key), str(config.secret) def pumpDump(self, SYMBOL, percentageOfBtc=100, profitPercentage=100, buyingPercentage=60): # do before entering coin to save the API call during the pump BALANCE_BTC, ERROR = self.API.get_balance('BTC') if ERROR is not None: print ERROR PUMP_BALANCE = BALANCE_BTC["Available"] * (percentageOfBtc / 100) COIN_PRICE, ERROR = self.API.get_market(SYMBOL + "_BTC") if ERROR is not None: print ERROR ASK_PRICE = COIN_PRICE['AskPrice'] COIN_SUMMARY, ERROR = self.API.get_market(SYMBOL + "_BTC") if ERROR is not None: print ERROR LAST_PRICE = COIN_SUMMARY['LastPrice'] CLOSE_PRICE = COIN_SUMMARY['Close'] ASK_BUY = ASK_PRICE + (buyingPercentage / 100 * ASK_PRICE) ASK_SELL = ASK_PRICE + (profitPercentage / 100 * ASK_PRICE) # calculates the number of PUMP_COIN(s) to buy, taking into # consideration Cryptopia's 0.20% fee. c_fee = 0.00201 cryptoipa_fee = PUMP_BALANCE * c_fee NUM_COINS = float((PUMP_BALANCE - cryptoipa_fee)) / ASK_BUY if LAST_PRICE > CLOSE_PRICE + 0.20 * CLOSE_PRICE: print '\nYou joined too late or this was pre-pumped! \ Close Price : {:.8f} . Last Price : {:.8f}'.format( CLOSE_PRICE, LAST_PRICE) return BUY_PRICE = ASK_BUY * NUM_COINS SELL_PRICE = ASK_SELL * NUM_COINS PROFIT = SELL_PRICE - BUY_PRICE print '\n[+] Buy order placed for {:.8f} {} coins at {:.8f} BTC \ each for a total of {} BTC'.format(NUM_COINS, SYMBOL, ASK_BUY, BUY_PRICE) # TRADE, ERROR = self.API.submit_trade(SYMBOL + '/BTC', 'Buy', ASK_BUY, NUM_COINS) if ERROR is not None: print ERROR print '\n[+] Placing sell order at {:.8f} (+{}%)...'.format( ASK_SELL, profitPercentage) COINS_OWNED, ERROR = self.API.get_balance(SYMBOL) if ERROR is not None: print ERROR COINS_OWNED = COINS_OWNED['Available'] while COINS_OWNED == 0: time.sleep(0.1) COINS_OWNED, ERROR = self.API.get_balance(SYMBOL) if ERROR is not None: print ERROR break COINS_OWNED = COINS_OWNED['Available'] TRADE, ERROR = self.API.submit_trade(SYMBOL + '/BTC', 'Sell', ASK_SELL, NUM_COINS) if ERROR is not None: print ERROR print '\n[+] Sell order placed of {:.8f} {} coins at {:.8f} BTC each for \ a total of {:.8f} BTC'.format(NUM_COINS, SYMBOL, ASK_SELL, SELL_PRICE) print '[*] PROFIT if sell order fills: {:.8f} BTC'.format(PROFIT)
def sigint_handler(): """Handler for ctrl+c""" print('\n[!] CTRL+C pressed. Exiting...') sys.exit(0) EXIT_CYCLE = False while not EXIT_CYCLE: # setup api KEY, SECRET = get_secret("secrets.json") API = Api(KEY, SECRET) # do before entering coin to save the API call during the pump BALANCE_BTC, ERROR = API.get_balance('BTC') if ERROR is not None: print(ERROR) break AVAILABLE_BTC = BALANCE_BTC['Available'] signal.signal(signal.SIGINT, sigint_handler) print('Crypto Crew Technologies Welcomes you to our Pump Trade Bot!\n') print('Buy and Sell orders will be instantly placed on Cryptopia at \ a specified % above the ASK price.\n') TRAINING = input(" Live Mode (1) = Real orders will be placed.'\n\ Training Mode (2) = No real orders will be placed.\n\n\ Enter 1 for Live Mode or 2 for Training Mode - (1 or 2) ?: " ) ALLOW_ORDERS = False # Set to True to enable limit trading...
print '\n[!] CTRL+C pressed. Exiting...' sys.exit(0) EXIT_CYCLE = False while not EXIT_CYCLE: # setup api KEY, SECRET = get_secret("secrets.json") API = Api(KEY, SECRET) COIN = raw_input("Choisissez le coin à observer : \ \nSoyez précis !\nEcrivez en majuscule (ex : WISH)\n") # do before entering coin to save the API call during the pump BALANCE, ERROR = API.get_balance(COIN) if ERROR is not None: print "L'erreur suivante a été retournée : \n" + ERROR AVAILABLE = 0 # AVAILABLE = BALANCE['Available'] signal.signal(signal.SIGINT, sigint_handler) ALLOW_ORDERS = True print 'Vous avez', AVAILABLE, COIN, 'disponible(s).' PAIRS, ERROR = API.get_tradepairs() print 'Choisissez votre paire :'
return str(secrets_json['key']), str(secrets_json['secret']) def sigint_handler(): """Handler for ctrl+c""" print '\n[!] CTRL+C pressed. Exiting...' sys.exit(0) EXIT_CYCLE = False while not EXIT_CYCLE: # setup api KEY, SECRET = get_secret("secrets.json") API = Api(KEY, SECRET) # do before entering coin to save the API call during the pump BALANCE_BTC, ERROR = API.get_balance('BTC') if ERROR is not None: print ERROR break AVAILABLE_BTC = BALANCE_BTC['Available'] # Set to True to enable limit trading... ALLOW_ORDERS = False signal.signal(signal.SIGINT, sigint_handler) print 'Crypto Crew Technologies Welcomes you to our Pump Trade Bot!' print '\nBuy and Sell orders will be instantly placed on Cryptopia at \ a specified % above the ASK price.\n' TRAINING = raw_input(" Live Mode (1) = Real orders will be placed.'\n\
config['CONF_FILE'] = os.path.join(os.path.dirname(__file__),'trading.conf') parser = configparser.ConfigParser(allow_no_value=True) # These avoid error if not exists in conf parser.set(configparser.DEFAULTSECT, 'public_key', None) parser.set(configparser.DEFAULTSECT, 'private_key', None) parser.read(config['CONF_FILE']) if not parser.has_section(exchange): parser.add_section(exchange) save = (input("Save? Y/N").lower() == 'y') or True # always save #if not config[exchange][0]: key0 = input("Insert PUBLIC API KEY for exchange "+exchange+" ") key1 = input("Insert PRIVATE API KEYfor exchange "+exchange+" ") parser.set(exchange,'public_key', key0) parser.set(exchange,'private_key', key1) if save: with open(config['CONF_FILE'], 'w+') as conf: parser.write(conf) config[exchange] = (parser.get(exchange,'public_key'),parser.get(exchange,'private_key')) return config exchange = "cryptopia" config = readConfig(exchange) cryptopia = Api(*config[exchange]) #call a request to the api, like balance in BTC... balance, error = cryptopia.get_balance('CREA') if error: print ('ERROR: %s' % error) else: print ('Request successful. My Balance: {}'.format(balance))
def main(): ''' Program driver: Input your configuration below ''' # Replace with your API key and API secret. # Do not host this file anywhere publicly # or your key/secret will be scraped by a bot. # API KEY and SECRET CAN BE FOUND AT https://www.cryptopia.co.nz/Security # Remember to check 'Enable API' # Remember to check 'Enable Withdrawal' # Remember to check 'AddressBook Withdraw Only' API_KEY = 'Your API key' API_SECRET = 'Your API secret' # Replace with your wallet address. # Make sure you add this wallet address to your withdraw address book in https://www.cryptopia.co.nz/Security WALLET_ADDRESS = 'Wallet Address' # Replace with coin you want to check balance of and sell to BTC. SELL_CURRENCY = 'LTC' # Symbol of currency you wish to withdraw from the exchange WITHDRAW_CURRENCY = 'BTC' # Sell balance threshold i.e. balance of SELL_CURRENCY must be above SELL_THRESHOLD to sell. SELL_THRESHOLD = .0005 # Withdraw balance threshold i.e. balance of WITHDRAW_CURRENCY must be above WITHDRAW_THRESHOLD to withdraw. WITHDRAW_THRESHOLD = .0011 # How often to execute the script? i.e. input of 5 will run the script every 5 seconds SECONDS_TO_SLEEP = 10 # ---------------- DO change values ABOVE --------------------------- # ---------------- DON'T change values BELOW ---------------------- # Initialize API with key and secret values api = Api(API_KEY, API_SECRET) # Balance check loop script_running = True market = SELL_CURRENCY + '/BTC' while script_running: print "\n--------------------------------\n" print 'Starting next cycle...' # Check if balances meet requirements to sell print "\n--------------------------------\n" print 'Preparing to check balance of ' + SELL_CURRENCY + ' you have deposited to the exchange...' balance, error = api.get_balance(SELL_CURRENCY) if error: print 'Error getting balance for ' + SELL_CURRENCY + '.' print 'Error message: ' + error + '.' else: print 'You have a balance of ' + str(balance['Available']) + ' ' + SELL_CURRENCY + '.' # Check if balance is above sell threshold if balance['Available'] > SELL_THRESHOLD: # Request SELL_CURRENCY/BTC market data url = 'https://www.cryptopia.co.nz/api/GetMarkets/BTC' response = requests.get(url).json() data = response['Data'] # Find SELL_CURRENCY/BTC row for item in data: if item['Label'] == market: rate = item['AskPrice'] break # Check if minimum trading limit is met min_check = '{0:f}'.format(rate*balance['Available']) min_to_meet_limit = '{0:f}'.format((.0005*balance['Available'])/(rate*balance['Available'])) print '\nPreparing to check if minimum trading limit is met...' if rate*balance['Available'] < .0005: print 'Sorry, minimum trading limit is the equivalent of .0005 BTC.' print 'You are currently attempting to trade the equivalent of ' + str(min_check) + ' BTC.' print 'You would need to trade at least ' + str(min_to_meet_limit) + ' ' + SELL_CURRENCY + '.\n' else: # Create sell order. print 'Minimum trading limit met.' print 'Creating sell order for ' + str(balance['Available']) + \ ' ' + SELL_CURRENCY + ' at market asking price of ' + \ str(rate) + ' BTC to 1 ' + SELL_CURRENCY + '.' result, error = api.submit_trade(market, 'Sell', rate, balance['Available']) if error: print 'Error while attempting to create sell order.' print 'Error message: ' + error + '.' else: print 'Sell order successful.' # Check if balances meet requirements to withdraw print "\n--------------------------------\n" print 'Preparing to check balance of ' + WITHDRAW_CURRENCY + ' you have deposited to the exchange...' balance, error = api.get_balance(WITHDRAW_CURRENCY) if error: print 'Error getting balance for ' + WITHDRAW_CURRENCY + '.' print 'Error message: ' + error + '.' else: print 'You have a balance of ' + str(balance['Available']) + ' ' + WITHDRAW_CURRENCY + '.' # Check if balance is above withdraw threshold if balance['Available'] > WITHDRAW_THRESHOLD: # Check if balance is above minimum withdraw limit if balance['Available'] < .0011: print 'Sorry, minimum withdrawal limit is .0011 BTC.' print 'You are currently attempting to withdraw ' + str(balance['Available']) + ' BTC.' else: print 'Withdrawing ' + str(balance['Available']) + WITHDRAW_CURRENCY + \ ' to wallet address: ' + WALLET_ADDRESS + '.' result, error = api.submit_withdraw(WITHDRAW_CURRENCY, WALLET_ADDRESS, balance['Available']) if error: print 'Error while attempting to withdraw to wallet.' print 'Error message: ' + error + '.' else: print 'Withdraw order successful.' # Sleep for allotted time. print "\n--------------------------------\n" print "Cycle complete, sleeping for " + str(SECONDS_TO_SLEEP) + " seconds." time.sleep(SECONDS_TO_SLEEP)
return str(secrets_json['key']), str(secrets_json['secret']) def sigint_handler(): """Handler for ctrl+c""" print '\n[!] CTRL+C pressed. Exiting...' sys.exit(0) EXIT_CYCLE = False while not EXIT_CYCLE: # setup api KEY, SECRET = get_secret("secrets.json") API = Api(KEY, SECRET) # do before entering coin to save the API call during the pump BALANCE_BTC, ERROR = API.get_balance('BTC') if ERROR is not None: print ERROR break AVAILABLE_BTC = BALANCE_BTC['Available'] # Set to True to enable limit trading... ALLOW_ORDERS = False signal.signal(signal.SIGINT, sigint_handler) print 'Crypto Crew Technologies Welcomes you to our Pump Trade Bot!' print '\nBuy and Sell orders will be instantly placed on Cryptopia at \ a specified % above the ASK price.\n' TRAINING = raw_input(" Live Mode (1) = Real orders will be placed.'\n\