Example #1
0
def getBalance(idName):
    API_KEY = configJson[idName]['bk_apiKey']
    API_SECRET = configJson[idName]['bk_apiSecret']
    if API_KEY == '' or API_SECRET == '':
        print('this user have no API KEY or API SECRET to send order')
        return None
    bitkub = Bitkub()
    bitkub.set_api_key(API_KEY)
    bitkub.set_api_secret(API_SECRET)
    balance = bitkub.balances()
    data = {}
    if balance['error'] == 0:
        for sym in balance['result']:
            if balance['result'][sym]['available'] > 0:
                available = balance['result'][sym]['available']
                available_h = max([
                    available, configJson[idName]['available'],
                    configJson[idName]['availableHigh']
                ])
                p_drawdown = (abs(available_h - available) / available_h) * 100
                p_drawdown = round(p_drawdown, 2)
                data[sym] = {
                    'available': available,
                    'reserved': balance['result'][sym]['reserved']
                }
                #update balance data sheet
                if sym == 'THB':
                    gSheet.setValue('Config',
                                    findKey='idName',
                                    findValue=idName,
                                    key='available',
                                    value=available)
                    gSheet.setValue('Config',
                                    findKey='idName',
                                    findValue=idName,
                                    key='availableHigh',
                                    value=available_h)
                    gSheet.setValue('Config',
                                    findKey='idName',
                                    findValue=idName,
                                    key='percentageDrawdown',
                                    value=p_drawdown)
    return data
Example #2
0
def getBalance(idName):
    API_KEY = configJson[idName]['bk_apiKey']
    API_SECRET = configJson[idName]['bk_apiSecret']
    if API_KEY == '' or API_SECRET == '':
        print('this user have no API KEY or API SECRET to send order')
        return None
    bitkub = Bitkub()
    bitkub.set_api_key(API_KEY)
    bitkub.set_api_secret(API_SECRET)
    balance = bitkub.balances()
    data = {}
    if balance['error'] == 0:
        for sym in balance['result']:
            if balance['result'][sym]['available'] > 0:
                data[sym] = {
                    'available': balance['result'][sym]['available'],
                    'reserved': balance['result'][sym]['reserved']
                }
    return data