示例#1
0
def binance_create_order(chat_id, **params):
    full_api = getbinanceapi(chat_id)['binance_api']
    api_key = full_api.split(':')[0].strip()
    api_secret = full_api.split(':')[1].strip()
    client = Client(api_key, api_secret)
    binance_timesync(client)
    try:
        js_info = client.create_order(**params)
        return js_info
    except Exception as e:
        print(e)
        return str(e)
示例#2
0
def binance_getbalance(chat_id, asset):
    full_api = getbinanceapi(chat_id)['binance_api']
    api_key = full_api.split(':')[0].strip()
    api_secret = full_api.split(':')[1].strip()
    client = Client(api_key, api_secret)
    binance_timesync(client)

    try:
        js_info = client.get_asset_balance(asset=asset)
        print(js_info)
        return js_info
    except Exception as e:
        print(e)
示例#3
0
def binance_get_symbol_ticker(chat_id, symbol):
    full_api = getbinanceapi(chat_id)['binance_api']
    api_key = full_api.split(':')[0].strip()
    api_secret = full_api.split(':')[1].strip()
    client = Client(api_key, api_secret)
    binance_timesync(client)
    try:
        js_info = client.get_symbol_ticker()
        for t in js_info:
            if t['symbol'] == symbol:
                return t['price']
    except Exception as e:
        print(e)
    return None
示例#4
0
def binance_get_all_tickers(chat_id):
    full_api = getbinanceapi(chat_id)['binance_api']
    api_key = full_api.split(':')[0].strip()
    api_secret = full_api.split(':')[1].strip()
    client = Client(api_key, api_secret)
    binance_timesync(client)
    js_info = []
    try:
        js_info = client.get_all_tickers()
        #print(js_info)
        return js_info
    except Exception as e:
        print(e)
    return js_info
示例#5
0
def getbinancehistory(chat_id):
    full_api = getbinanceapi(chat_id)['binance_api']
    api_key = full_api.split(':')[0].strip()
    api_secret = full_api.split(':')[1].strip()
    client = Client(api_key, api_secret)
    binance_timesync(client)