Exemplo n.º 1
0
def test_fetch():
    """ test for fetch method """
    q = Quote()
    q.set_source("vanguard_au")
    actual = q.fetch("vanguard", ["BOND"])

    assert actual is not None
    assert actual
def test_download():
    symbols = ['VUKE']
    # , 'VMID', 'VGOV'
    q = Quote()
    q.set_source(source)

    actual = q.fetch('FWB', symbols)

    assert actual is not None
Exemplo n.º 3
0
def test_ms_price_dl():
    """ test price download """
    uat = Quote()
    uat.set_source("morningstar")
    #actual = uat.download("ASX:VHY", "AUD", "morningstar")
    result = uat.fetch("ASX", ["VHY"])
    actual = result[0]

    assert actual is not None
    assert actual.currency == "AUD"
def test_aud_eur_fixerio():
    """ a basic test.
    Use the default provider (fixerio) and fetch a rate.
    """
    q = Quote()
    actual = q.currency("AUD", "EUR")

    assert actual is not None
    assert isinstance(actual, PriceModel)
    assert actual.value != Decimal(0)
def test_parameters_case_insensitive():
    """ parameters must be case insensitive """
    q = Quote()
    # the default provider should be used
    #q.set_source("fixerio")
    actual = q.currency("AuD", "eur")

    assert actual is not None
    assert actual.value != Decimal(0)
    assert isinstance(actual, PriceModel)
Exemplo n.º 6
0
def test_fetch_vuke():
    '''
    basic fetching and parsing functionality 
    https://www.boerse-frankfurt.de/etp/IE00B810Q511
    '''
    symbols = ['VUKE']
    q = Quote()
    q.set_source(source)

    actual = q.fetch(exchange, symbols)

    assert actual is not None
Exemplo n.º 7
0
def test_fixerio():
    uat = Quote()
    #actual = uat.download("AUD", "EUR", "fixerio")
    uat.set_source("fixerio")
    result = uat.currency("AUD", "EUR")

    assert result

    actual = result[0]

    assert actual is not None
    assert actual
Exemplo n.º 8
0
def test_no_symbols():
    """ handle empty symbol list """
    q = Quote()
    symbols = []
    actual = None

    with pytest.raises(Exception) as ex:
        actual = q.fetch("yo", symbols)

    assert ex is not None
    assert ex.typename == 'ValueError'
    assert ex.value.args[0] == "The symbols are missing."
Exemplo n.º 9
0
def test_result_hash():
    """ The result is a Price Model object.
    Also tests connectivity and parsing.
    """
    from pricedb import PriceModel

    q = Quote()
    q.set_source("vanguard_au")
    actual = q.fetch("vanguard", ["BOND"])

    assert actual
    assert isinstance(actual[0], PriceModel)
Exemplo n.º 10
0
    def __download_price(self, symbol: str, currency: str, agent: str):
        """ Downloads and parses the price """
        from finance_quote_python import Quote

        assert isinstance(symbol, str)
        assert isinstance(currency, str)
        assert isinstance(agent, str)

        if not symbol:
            return None

        #self.logger.info(f"Downloading {symbol}... ")

        dl = Quote()
        dl.logger = self.logger

        dl.set_source(agent)
        dl.set_currency(currency)

        result = dl.fetch(agent, [symbol])

        if not result:
            raise ValueError(f"Did not receive a response for {symbol}.")

        price = result[0]

        if not price:
            raise ValueError(f"Price not downloaded/parsed for {symbol}.")
        else:
            # Create price data entity, to be inserted.
            self.add_price(price)

        return price
Exemplo n.º 11
0
def test_parsing():
    """ Test that the expected schema is retrieved """
    from decimal import Decimal

    q = Quote()
    q.set_source("vanguard_au")
    actual = q.fetch("vanguard", ["BOND"])

    assert actual
    # test that the source schema has not changed.
    price = actual[0]
    assert price.currency
    assert price.datum
    assert price.symbol
    assert price.symbol.namespace == "vanguard".upper()
    assert price.value
    assert isinstance(price.value, Decimal)
Exemplo n.º 12
0
def test_sources():
    """ Fetch the list of available sources / agents """
    from finance_quote_python.finance import DownloadSources
    q = Quote()
    sources = q.sources

    assert sources is not None
    assert sources
    assert len(sources) == len(DownloadSources)
def test_fetch_vuke():
    '''
    basic fetching and parsing functionality 
    '''
    symbols = ['VUKE']
    q = Quote()
    q.set_source(source)
    q.set_currency('EUR')

    actual = q.fetch(exchange, symbols)

    assert actual is not None
Exemplo n.º 14
0
def test_new():
    """ just create a new object without new() """
    q = Quote()
    assert q is not None