コード例 #1
0
def test_trade_from_poloniex():
    amount = FVal(TEST_AMOUNT_STR)
    rate = FVal(TEST_RATE_STR)
    perc_fee = FVal(TEST_PERC_FEE_STR)
    cost = amount * rate
    trade = trade_from_poloniex(TEST_POLO_TRADE, 'BTC_ETH')

    assert isinstance(trade, Trade)
    assert isinstance(trade.timestamp, int)
    assert trade.timestamp == 1500758317
    assert trade.trade_type == TradeType.SELL
    assert trade.rate == rate
    assert trade.amount == amount
    assert trade.pair == 'ETH_BTC'
    assert trade.fee == cost * perc_fee
    assert trade.fee_currency == 'BTC'
    assert trade.location == Location.POLONIEX
コード例 #2
0
def test_poloniex_trade_with_asset_needing_conversion():
    amount = FVal(613.79427133)
    rate = FVal(0.00022999)
    perc_fee = FVal(0.0015)
    poloniex_trade = {
        'globalTradeID': 192167,
        'tradeID': FVal(3727.0),
        'date': '2017-07-22 21:18:37',
        'rate': rate,
        'amount': amount,
        'total': FVal(0.14116654),
        'fee': perc_fee,
        'orderNumber': FVal(2315432.0),
        'type': 'sell',
        'category': 'exchange',
    }
    trade = trade_from_poloniex(poloniex_trade, 'AIR_BTC')
    assert trade.pair == 'BTC_AIR-2'
    assert trade.location == Location.POLONIEX
コード例 #3
0
def test_poloniex_trade_deserialization_errors():
    test_trade = TEST_POLO_TRADE.copy()
    test_trade['date'] = '2017/07/22 1:18:37'
    with pytest.raises(DeserializationError):
        trade_from_poloniex(test_trade, 'BTC_ETH')

    test_trade = TEST_POLO_TRADE.copy()
    test_trade['type'] = 'lololol'
    with pytest.raises(DeserializationError):
        trade_from_poloniex(test_trade, 'BTC_ETH')

    test_trade = TEST_POLO_TRADE.copy()
    test_trade['amount'] = None
    with pytest.raises(DeserializationError):
        trade_from_poloniex(test_trade, 'BTC_ETH')

    test_trade = TEST_POLO_TRADE.copy()
    test_trade['rate'] = None
    with pytest.raises(DeserializationError):
        trade_from_poloniex(test_trade, 'BTC_ETH')

    test_trade = TEST_POLO_TRADE.copy()
    test_trade['fee'] = ['a']
    with pytest.raises(DeserializationError):
        trade_from_poloniex(test_trade, 'BTC_ETH')

    test_trade = TEST_POLO_TRADE.copy()
    del test_trade['rate']
    with pytest.raises(DeserializationError):
        trade_from_poloniex(test_trade, 'BTC_ETH')