def sell(wallet, amount, sprice):# ' ' ^ Sell wallets = btceapi.api.Trade(btceapi.api(config.API_KEY,config.API_SECRET), CUR1name.lower() + "_" + CUR2name.lower(), 'sell', sprice, float("%.4f"% amount)) if wallets['success'] == 1: wallet[CUR1name] = wallets['return']['funds'][CUR1name.lower()] wallet[CUR2name] = wallets['return']['funds'][CUR2name.lower()] else: print wallets['error'] return wallet
def buy(wallet, amount, bprice):# this buys 'amount' of cur1 at 'bprice', and returns a new wallet wallets = btceapi.api.Trade(btceapi.api(config.API_KEY,config.API_SECRET), CUR1name.lower() + "_" + CUR2name.lower(), 'buy', bprice, float("%.4f"% amount)) if wallets['success'] == 1: wallet[CUR1name] = wallets['return']['funds'][CUR1name.lower()] wallet[CUR2name] = wallets['return']['funds'][CUR2name.lower()] else: print wallets['error'] return wallet
def getCurrentPrice(self,currencyPair): btceApi = api('','',False) ticker = btceApi.get_param(currencyPair, 'ticker') return ticker['ticker']
def __init__(self, Keys): self.__API = api(api_key=Keys.Key, api_secret=Keys.Secret, wait_for_nonce=True) self.__A = MyAlgos()
def getCurrentPrice(self, currencyPair): btceApi = api('', '', False) ticker = btceApi.get_param(currencyPair, 'ticker') return ticker['ticker']
def orders(self, pair): api = btceapi.api(self._apikey, self._secret, True) return api.ActiveOrders(pair)
def info(self): api = btceapi.api(self._apikey, self._secret, True) return api.getInfo()
def sell(self, rate, qty): api = btceapi.api(self._apikey, self._secret, True) return api.Trade(self._active_pair, "sell", rate, qty)
def cancelorder(self, pair): api = btceapi.api(self._apikey, self._secret, True) return api.CancelOrder(pair)
def getwallet():# Gets the wallet for use initially accountdata = btceapi.api.getInfo(btceapi.api(config.API_KEY, config.API_SECRET)) wallet = {CUR1name : accountdata['return']['funds'][CUR1name.lower()], CUR2name : accountdata['return']['funds'][CUR2name.lower()]}; return wallet