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)

Chiusa
#2,836 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #2837 di @quantconnect-kronos — integrata

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
28/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
html, php

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
HTML
Stelle
267
Fork
190
Merge medio
8h 38m
PR unite (30g)
69

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di QuantConnect/Documentation

Tutte le issue di QuantConnect/Documentation

Issue simili

Altre issue su Data Engineering

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.