query_instruments
function backtide.storage.query_instruments(instrument_type=None, provider=None, exchange=None, limit=None)
Return stored instrument metadata, optionally filtered.
When called with no arguments, returns all instruments. When
instrument_type, provider, and/or exchange are given, only
matching rows are returned.
See Also
Get instruments given their symbols.
Return stored OHLCV bars as a dataframe.
Example
>>> from backtide.storage import query_instruments
>>> all_instruments = query_instruments(limit=5)
>>> print(all_instruments)
[Instrument(symbol="AAPL", name="Apple Inc.", base=None, quote="USD", instrument_type="stocks", exchange="XNAS", provider=Yahoo), Instrument(symbol="MSFT", name="Microsoft Corporation", base=None, quote="USD", instrument_type="stocks", exchange="XNAS", provider=Yahoo), Instrument(symbol="SPY", name="State Street SPDR S&P 500 ETF T", base=None, quote="USD", instrument_type="etf", exchange="ARCX", provider=Yahoo)]
>>> stocks = query_instruments("stocks", "yahoo", limit=5)
>>> print(stocks)
[Instrument(symbol="AAPL", name="Apple Inc.", base=None, quote="USD", instrument_type="stocks", exchange="XNAS", provider=Yahoo), Instrument(symbol="MSFT", name="Microsoft Corporation", base=None, quote="USD", instrument_type="stocks", exchange="XNAS", provider=Yahoo)]
>>> xnas = query_instruments("stocks", exchange="XNAS", limit=5)
>>> print(xnas)
[Instrument(symbol="AAPL", name="Apple Inc.", base=None, quote="USD", instrument_type="stocks", exchange="XNAS", provider=Yahoo), Instrument(symbol="MSFT", name="Microsoft Corporation", base=None, quote="USD", instrument_type="stocks", exchange="XNAS", provider=Yahoo)]