quantlab.acquisition.wrds.nbbo_bars_sql.NbboBarsQuery#

class quantlab.acquisition.wrds.nbbo_bars_sql.NbboBarsQuery(day, pairs, session, request, has_nano)[source]#

Bases: object

The server-side resampling statement for one day table and one symbol batch.

Parameters:
daydatetime.date

The trading day, which names the table.

pairstuple of tuple of (str, str or None)

The batch’s (sym_root, sym_suffix) pairs.

sessionNbboBarsSession

The day’s session bounds, from NbboBarsRequest.session.

requestNbboBarsRequest

The bar size and the quote filters.

has_nanobool

Whether the day table has time_m_nano (from 2018-01-02).

Raises:
ValueError

If pairs is empty, or session is for another day.

Examples

>>> request = NbboBarsRequest("1m")
>>> session = request.session(request.calendar(), date(2024, 1, 24))
>>> query = NbboBarsQuery(
...     date(2024, 1, 24), (("AAPL", None),), session, request, has_nano=True
... )
>>> statement = query.statement()  # a psycopg2.sql.Composed COPY statement
statement()[source]#

Return the COPY (...) TO STDOUT statement.

Its CSV output has a header line and the RESULT_COLUMNS.

Returns:
psycopg2.sql.Composed

The statement.

Examples

With query built as in the class example:

query.statement()   # Composed([SQL("COPY (\nWITH raw AS (...