US Equity bar building: FINRA quotes excluded, one-sided periods carry the previous bar's other side, locked/crossed closing book squared onto one side (undocumented)

Cerrado
#2,836 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Ya se ha fusionado un pull request relacionado.

  • #2837 de @quantconnect-kronos — fusionado

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
28/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
html, php

Línea de trabajo

Start with the three statements in Resources/data-feeds/excluded-ticks.php, 03 Bar Building.php and 03 Quote Bar.html, and check linked PR #2837 first, since it already targets this work. Compare each statement with the replay description and the lines 97 to 103 of TickQuoteBarConsolidator.AggregateBar in Lean that the issue cites. Done means the three undocumented rules (FINRA quotes, one-sided periods, crossed closing books) are stated on the pages without contradicting the stored bars.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

kronos:develop:working

Summary

Three statements on the US Equity bar-building pages do not match what the stored US Equity second (and minute) quote bars contain. A user who rebuilt SPY second QuoteBars from the quote tick files following the documented rules found a small number of bars that match no quote tick; all of them come from the three undocumented points below. Each point was verified by replaying the SPY quote tick files into bars and comparing every bar's closing bid, closing ask, LastBidSize and LastAskSize with the stored second file on four full sessions (2007-05-02, 2007-07-03, 2008-01-09, 2019-06-03); with all three applied the replay reproduces 103,732 of 103,732 bars.

1. FINRA quotes are excluded too, not only FINRA trades

Resources/data-feeds/excluded-ticks.php (included by 03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/08 Data Preparation/03 Bar Building.php) lists the FINRA rule for trades only:

The trade is from the FINRA exchange and FINRA filtering is active for the security.

Once FINRA filtering is active for the day, a quote tick whose exchange is FINRA (D) does not set the bar's bid, ask or sizes either. Measured: SPY 2008-01-09 has 37,322 FINRA quote ticks that pass every other documented rule; keeping them changes 1,314 of the 31,182 stored second bars (SPY 2007-05-02: 91 of 22,910). Suggested wording: "The tick is from the FINRA exchange and FINRA filtering is active for the security" (so it covers quotes), with a sentence that a FINRA quote does not update the bid or ask of the bar after filtering is active.

2. A period with quotes on one side only still carries the other side

06 LEAN Engine/03 Data Format/02 Core Data Types/03 Quote Bar.html says:

If a period has no bid quotes, the four bid price columns are empty and the bid size is 0

That is the shape of the CME file the page illustrates, but not of the US Equity second and minute quote files. There a new period opens from the previous bar's closing bid, closing ask and both last sizes before its first quote is applied (TickQuoteBarConsolidator.AggregateBar in Lean, lines 97 to 103), so a period with quotes on one side only reports the other side's earlier close and size, and a bar can carry a bid or ask size with no quote on that side in the period. Suggested: state that the empty-column form applies to some asset classes (futures, options) and that US Equity second and minute bars open each period from the previous bar's close and last size on both sides.

3. A locked or crossed closing book is squared onto one side

Neither page mentions that when a period's closing bid is above its closing ask, the stored bar sets both sides to one closing price and one last size (one side's close and last size are copied onto the other), so the bar reads as a locked quote with equal sizes and matches no single quote tick. It affected 288 of 15,429 SPY second bars on 2007-07-03 and 13 of 34,211 on 2019-06-03. Suggested: one sentence under Bar Building saying the closing bid and ask of a bar are never left crossed, and that both sides then show the same price and size.

Intercom conversation 215476687728744.

Lenguaje dominante
HTML
Estrellas
267
Forks
190
Merge medio
8 h 38 min
PR fusionados (30 d)
69

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de QuantConnect/Documentation

Todos los issues de QuantConnect/Documentation

Issues similares

Más issues de Data Engineering

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.