Esempio n. 1
0
def market_buy_order(cad, book):
    url = "https://api.quadrigacx.com/v2/buy"
    cad = float(cad)
    print("Buy order")

    while cad > 100:
        time.sleep(1)
        ticker = float(get_current_trades("eth_cad")["ask"])
        print("ask", ticker)

        amount = (round(((cad / ticker) * .98), 8))
        print("amount of eth", amount)
        signature = sig.hash()
        payload = {
            'key': signature['key'],
            'nonce': signature['nonce'],
            'signature': signature['signature'],
            'amount': amount,
            'book': book
        }
        r = requests.post(url, data=payload)
        values = r.json()
        print("Buy order placed")
        time.sleep(1)
        cad = float(get_account_balance("cad_available"))
        print("cad remaining", cad)
Esempio n. 2
0
def market_sell_all(book):
    url = "https://api.quadrigacx.com/v2/sell"
    time.sleep(1)
    signature = sig.hash()

    eth = get_account_balance('eth_available')
    amount = float(eth)

    if amount > 0:
        signature = sig.hash()
        payload = {
            'key': signature['key'],
            'nonce': signature['nonce'],
            'signature': signature['signature'],
            'amount': amount,
            'book': book
        }
        r = requests.post(url, data=payload)
        values = r.json()
        print("Sell all order placed")
        return values
    return
Esempio n. 3
0
def get_open_order(id):
    url = "https://api.quadrigacx.com/v2/lookup_order"

    signature = sig.hash()

    payload = {
        'key': signature['key'],
        'nonce': signature['nonce'],
        'signature': signature['signature'],
        'id': id
    }
    r = requests.post(url, data=payload)
    values = r.json()

    return values
Esempio n. 4
0
def get_open_orders(book="btc_cad"):
    url = "https://api.quadrigacx.com/v2/open_orders"

    signature = sig.hash()

    payload = {
        'key': signature['key'],
        'nonce': signature['nonce'],
        'signature': signature['signature'],
        'book': book
    }
    r = requests.post(url, data=payload)
    values = r.json()

    return values
Esempio n. 5
0
def get_account_balance(currency):
    url = "https://api.quadrigacx.com/v2/balance"

    time.sleep(1)
    signature = sig.hash()

    payload = {
        'key': signature['key'],
        'nonce': signature['nonce'],
        'signature': signature['signature']
    }
    r = requests.post(url, data=payload)
    values = r.json()

    return values[currency]
Esempio n. 6
0
def market_sell_order(amount, book):
    url = "https://api.quadrigacx.com/v2/sell"

    signature = sig.hash()

    payload = {
        'key': signature['key'],
        'nonce': signature['nonce'],
        'signature': signature['signature'],
        'amount': amount,
        'book': book
    }
    r = requests.post(url, data=payload)
    values = r.json()

    return values
Esempio n. 7
0
def limit_buy_order(amount, price, book):
    url = "https://api.quadrigacx.com/v2/buy"

    signature = sig.hash()

    payload = {
        'key': signature['key'],
        'nonce': signature['nonce'],
        'signature': signature['signature'],
        'amount': amount,
        'price': price,
        'book': book
    }
    r = requests.post(url, data=payload)
    values = r.json()

    return values
Esempio n. 8
0
def get_user_transactions(offset=0, limit=50, sort="desc", book="btc_cad"):
    url = "https://api.quadrigacx.com/v2/user_transactions"

    signature = sig.hash()

    payload = {
        'key': signature['key'],
        'nonce': signature['nonce'],
        'signature': signature['signature'],
        'offset': offset,
        'limit': limit,
        'sort': sort,
        'book': book
    }
    r = requests.post(url, data=payload)
    values = r.json()

    return values