Example #1
0
def test_get_open_orders(apikey, secret):
    '''test get_open_orders'''

    polo = Poloniex(apikey, secret, 130)
    open_orders = polo.get_open_orders()

    assert isinstance(open_orders, dict)
Example #2
0
def test_sell_limit(apikey, secret):
    '''test sell'''

    polo = Poloniex(apikey, secret, 20)

    assert polo.sell_limit("btc-ppc", 0.000001, 0.001) == {
        'error': 'Total must be at least 0.0001.'
    }
Example #3
0
def test_margin_sell(apikey, secret):
    '''test sell'''

    polo = Poloniex(apikey, secret, 130)

    assert polo.margin_sell("btc-ltc", 0.000001, 0.001) == {
        'error': 'Total must be at least 0.0001.'
    }
Example #4
0
def test_buy_limit(apikey, secret):
    '''test buy'''

    polo = Poloniex(apikey, secret, 20)
    with pytest.raises(APIError):
        assert polo.buy_limit("btc-ppc", 0.000001, 0.001) == {
            'error': 'Total must be at least 0.0001.'
        }
Example #5
0
def test_sell_margin(apikey, secret):
    '''test sell'''

    polo = Poloniex(apikey, secret, 20)
    with pytest.raises(APIError):
        assert polo.sell_margin("btc-ltc", 0.000001, 0.001) == {
            'error': 'Total must be at least 0.0001.'
        }
Example #6
0
def test_margin_buy(apikey, secret):
    '''test buy'''

    polo = Poloniex(apikey, secret, 130)

    assert polo.margin_buy("btc-eth", 0.000001, 0.001) == {
        'error': 'Total must be at least 0.0001.'
    }
Example #7
0
def test_active_loans(apikey, secret):
    '''test get_active_loans'''

    polo = Poloniex(apikey, secret, 130)
    active_loans = polo.get_active_loans()

    assert isinstance(active_loans, dict)
    assert sorted(active_loans.keys()) == sorted(['provided', 'used'])
Example #8
0
def test_get_deposit_address(apikey, secret):
    '''test get_deposit_address'''

    polo = Poloniex(apikey, secret, 130)
    deposit_addr = polo.get_deposit_address("btc")

    assert isinstance(deposit_addr, str)
    assert deposit_addr.startswith("1")
Example #9
0
def test_get_avaliable_balances(apikey, secret):
    '''test get_avaliable_balances'''

    polo = Poloniex(apikey, secret, 130)
    avaliable_balances = polo.get_available_balances()

    assert isinstance(avaliable_balances, dict)
    assert sorted(avaliable_balances.keys()) == sorted(['exchange', 'margin'])
Example #10
0
def test_get_fee_info(apikey, secret):
    '''test get_fee_info'''

    polo = Poloniex(apikey, secret, 130)
    fee_info = polo.get_fee_info()

    assert isinstance(fee_info, dict)
    assert sorted(fee_info.keys()) == sorted(
        ['makerFee', 'takerFee', 'thirtyDayVolume', 'nextTier'])
Example #11
0
def test_get_margin_account_summary(apikey, secret):

    polo = Poloniex(apikey, secret, 130)
    margin_account_summary = polo.get_margin_account_summary()

    assert isinstance(margin_account_summary, dict)
    assert sorted(margin_account_summary.keys()) == sorted([
        'currentMargin', 'lendingFees', 'netValue', 'pl', 'totalBorrowedValue',
        'totalValue'
    ])
Example #12
0
def test_get_withdrawal_history(apikey, secret):
    '''test get_deposit_history'''

    polo = Poloniex(apikey, secret, 130)
    withdrawal_history = polo.get_withdrawal_history()

    assert isinstance(withdrawal_history, list)
    assert sorted(withdrawal_history[0].keys()) == sorted([
        'withdrawalNumber', 'currency', 'address', 'amount', 'fee',
        'timestamp', 'status', 'ipAddress'
    ])
Example #13
0
def test_get_deposit_history(apikey, secret):
    '''test get_deposit_history'''

    polo = Poloniex(apikey, secret, 130)
    deposit_history = polo.get_deposit_history()

    assert isinstance(deposit_history, list)
    assert sorted(deposit_history[0].keys()) == sorted([
        'currency', 'address', 'amount', 'confirmations', 'txid', 'timestamp',
        'status'
    ])
Example #14
0
def test_get_order_history(apikey, secret):
    '''test get_order_history'''

    polo = Poloniex(apikey, secret, 130)
    order_history = polo.get_order_history("btc_eth")

    assert isinstance(order_history, list)
    assert sorted(order_history[0].keys()) == sorted([
        'globalTradeID', 'tradeID', 'date', 'rate', 'amount', 'total', 'fee',
        'orderNumber', 'type', 'category'
    ])
Example #15
0
def test_generate_new_address(apikey, secret):
    '''test generate_new_address'''

    polo = Poloniex(apikey, secret, 130)

    assert polo.generate_new_address("eth")["success"] == 1
Example #16
0
def test_get_open_loan_offers(apikey, secret):
    '''test get_open_loan_offers'''

    polo = Poloniex(apikey, secret, 130)

    assert isinstance(polo.get_open_loan_offers(), list)
Example #17
0
import pytest
from cryptotik import Poloniex
from cryptotik.exceptions import APIError
from decimal import Decimal

private = pytest.mark.skipif(not pytest.config.getoption("--apikey"),
                             reason="needs --apikey option to run.")

polo = Poloniex()


def test_format_pair():
    '''test string formating to match API expectations'''

    assert polo.format_pair("btc-ppc") == "BTC_PPC"


def test_get_base_currencies():

    polo.get_base_currencies()


def test_get_markets():
    '''test get_markets'''

    assert isinstance(polo.get_markets(), list)
    assert "BTC_LTC" in polo.get_markets()


def test_get_market_ticker():
    '''test get_market_ticker'''
Example #18
0
def test_get_balances(apikey, secret):
    '''test get_balances'''

    polo = Poloniex(apikey, secret, 130)

    assert isinstance(polo.get_balances("btc"), str)