def list_prices(date, currency, last): """ Display all prices """ app = PriceDbApplication() app.logger = logger if last: # fetch only the last prices prices = app.get_latest_prices() else: prices = app.get_prices(date, currency) for price in prices: print(price) print(f"{len(prices)} records found.")
def last(symbol: str): """ displays last price, for symbol if provided """ app = PriceDbApplication() # convert to uppercase if symbol: symbol = symbol.upper() # extract namespace sec_symbol = SecuritySymbol("", "") sec_symbol.parse(symbol) latest = app.get_latest_price(sec_symbol) assert isinstance(latest, PriceModel) print(f"{latest}") else: # Show the latest prices available for all securities. latest = app.get_latest_prices() for price in latest: print(f"{price}")
def test_namespace_parameter(session): """ Test that the namespace parameter filters out appropriate symbols. Debugging test. """ from pricedb.dal import Security # Arrange app = PriceDbApplication(session) repo = app.get_security_repository() sec = Security() sec.symbol = "BOND" sec.namespace = "VANGUARD" sec.updater = "vanguard_au" sec.currency = "AUD" repo.session.add(sec) # Act app.download_prices(namespace="vanguard") # Assert prices = app.get_latest_prices() assert prices
def test_latest_prices(): """ Get the latest prices """ app = PriceDbApplication() latest = app.get_latest_prices() assert latest is not None