コード例 #1
0
ファイル: cf-server.py プロジェクト: leoli321/balance
def order(environ, start_response):
    start_response('200 OK', [('Content-type', 'application/json')])
    params = environ['params']
    account = params["account"]
    symbol = params["symbol"]
    order_type = params.get("orderType")
    price = params.get("price")
    amount = params.get("amount")
    key_list = []
    if account == "0":
        for name in accounts_init:
            key_list.append(accounts_init[name])
    else:
        key_list.append(accounts_init[account])
    success = 0
    msg_list = []
    for key in key_list:
        status, msg = order_one(key, order_type, symbol, price, amount)
        success += status
        msg_list.append(msg)
    if success == len(key_list):
        yield Result(True, "ok").response()
    else:
        yield Result(
            False, "总共:{},成功:{}\n{}".format(len(key_list), success,
                                            '\n'.join(msg_list))).response()
コード例 #2
0
ファイル: cf-server.py プロジェクト: leoli321/balance
def withdraw(environ, start_response):
    start_response('200 OK', [('Content-type', 'application/json')])
    params = environ['params']
    account = params["account"]
    symbol = params["symbol"]
    amount = params.get("amount")
    to_address = params.get("toAddress")
    key_list = []
    if account == "0":
        for name in accounts_init:
            key_list.append(accounts_init[name])
    else:
        key_list.append(accounts_init[account])
    success = 0
    msg_list = []
    for key in key_list:
        status, msg = withdraw_one(key, symbol, amount, to_address)
        success += status
        msg_list.append(msg)
    if success == len(key_list):
        yield Result(True, "ok").response()
    else:
        yield Result(
            False, "总共:{},成功:{}\n{}".format(len(key_list), success,
                                            '\n'.join(msg_list))).response()
コード例 #3
0
ファイル: BinanceUtil.py プロジェクト: suishanwen/balance
def common_response(response):
    try:
        if response.status_code == 200:
            return Result(200, "ok", response.json())
        else:
            data = json.loads(response.text)
            return Result(response.status_code, data.get('msg'), data)
    except Exception as e:
        return Result(response.status_code, str(e))
コード例 #4
0
ファイル: cf-server.py プロジェクト: leoli321/balance
def get_currency(environ, start_response):
    start_response('200 OK', [('Content-type', 'application/json')])
    params = environ['params']
    symbol = params["symbol"]
    key = accounts_init[params["account"]]
    try:
        yield Result(
            True, "", {
                "fund": get_account_currency(symbol, key),
                "coin": get_spot_currency(symbol, key)
            }).response()
    except Exception as e:
        logger.error(str(e))
        yield Result(False, str(e)).response()