Exemple #1
0
def kprivate_queryledgers(client, id=None):
    params = {}
    if id and len(id) <= 20 and isinstance(id, list):
        params['id'] = commasep(id)
    else:
        raise pykrakenrequests.exceptions.BadParamterError('error in ids')
    c = client._post("/0/private/QueryLedgers", params)
    return c['result']
Exemple #2
0
def kprivate_tradevolume(client, pair=None, feeinfo=None):
    params = {}
    if pair:
        params['pair'] = commasep(pair)
    if feeinfo:
        params['fee-info'] = feeinfo

    c = client._post("/0/private/TradeVolume")
    return c['result']
Exemple #3
0
def kprivate_openpositions(client, txid=None, docalcs=False):
    params = {}
    if txid and isinstance(txid, list):
        params['txid'] = commasep(txid)
    if docalcs:
        params['docalcs'] = docalcs

    c = client._post("/0/private/OpenPositions", params)
    return c['result']
Exemple #4
0
def kprivate_querytrades(client, txid=None, trades=False):
    params = {}
    if txid and len(txid) <= 20 and isinstance(txid, list):
        params['txid'] = commasep(txid)
    else:
        raise pykrakenrequests.exceptions.RequiredParameterError(
            'no txid found')
    if trades:
        params['trades'] = trades
    c = client._post("/0/private/QueryTrades", params)
    return c['result']
Exemple #5
0
def kprivate_queryorders(client, trades=False, userref=None, txid=None):
    params = {}
    if trades:
        params['trades'] = trades
    if userref:
        params['userref'] = userref
    if txid:
        params['txid'] = commasep(txid)

    c = client._post("/0/private/QueryOrders", params)
    return c['result']
Exemple #6
0
def kprivate_addorder(client,
                      pair=None,
                      typeo=None,
                      ordertype=None,
                      price=None,
                      price2=None,
                      volume=None,
                      leverage=None,
                      oflags=None,
                      starttm=None,
                      expiretm=None,
                      userref=None,
                      validate=None):
    params = {}
    if pair:
        params['pair'] = pair
    else:
        raise pykrakenrequests.exceptions.RequiredParameterError('pair')
    if typeo and typeo in ['buy', 'sell']:
        params['type'] = typeo
    else:
        raise pykrakenrequests.exceptions.RequiredParameterError('typeo')
    if ordertype and ordertype in (ORDER_TYPES_0 + ORDER_TYPES_1 +
                                   ORDER_TYPES_2):
        params['ordertype'] = ordertype
    else:
        raise pykrakenrequests.exceptions.RequiredParameterError('ordertype')

    if ordertype in ORDER_TYPES_0:
        if price:
            raise pykrakenrequests.exceptions.BadParamterError(
                'if price is set, ordertype cant be at market')
    elif ordertype in ORDER_TYPES_1:
        if price:
            params['price'] = price
        else:
            raise pykrakenrequests.exceptions.RequiredParameterError(
                'price required for this order type: {}'.format(ordertype))
    elif ordertype in ORDER_TYPES_2:
        if price and price2:
            params['price'] = price
            params['price2'] = price2
        else:
            raise pykrakenrequests.exceptions.RequiredParameterError(
                'price and price2 required for this order type: {}'.format(
                    ordertype))
    else:
        raise pykrakenrequests.exceptions.BadParamterError(
            'ordertype: {} not allowed, it should be in {} or {} or {}'.format(
                ordertype, ORDER_TYPES_0, ORDER_TYPES_1, ORDER_TYPES_2))
    if volume:
        params['volume'] = volume
    else:
        raise pykrakenrequests.exceptions.RequiredParameterError(
            'volume is required')

    if leverage:
        params['leverage'] = leverage

    if oflags:
        params['oflags'] = commasep(oflags)
    if starttm:
        params['starttm'] = parseOTime(starttm)
    if expiretm:
        params['expiretm'] = parseOTime(expiretm)
    if userref:
        params['userref'] = userref
    if validate:
        params['validate'] = validate

    c = client._post("/0/private/AddOrder", params)
    return c['result']