Research resampling example sums quote sizes instead of taking the last size

Aperta Adatta ai principianti
#2,838 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, python
Ambito
documentation

Direzione di ricerca

L'esempio Python si trova in 04 Research Environment/03 Datasets/01 Key Concepts/99 Examples.html intorno alle righe 81 e 84, dove asksize e bidsize sono aggregati con sum. Confrontalo con l'esempio C# alle righe 40 e 56-57 e con la definizione di QuoteBar in 06 LEAN Engine/03 Data Format/02 Core Data Types/03 Quote Bar.html. Esegui la riproduzione nell'issue per confermare che sum dà 50 e last dà 10. È fatto quando l'aggregazione in Python usa last e il testo circostante descrive il risultato come una stima della dimensione quotata, non del volume scambiato.

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

Descrizione

Problem

In 04 Research Environment/03 Datasets/01 Key Concepts/99 Examples.html, the Python example aggregates asksize and bidsize with sum (lines 81 and 84), describing the results as total ask/bid volume. These columns are quote-size snapshots, not traded quantities. Summing successive snapshots does not produce a five-minute QuoteBar's last size or traded volume.

The adjacent C# example uses QuoteBarConsolidator and LastAskSize / LastBidSize (lines 40 and 56–57), so the two examples produce different results for the same input. 06 LEAN Engine/03 Data Format/02 Core Data Types/03 Quote Bar.html correctly defines each size as the last size in the period.

Minimal reproduction

import pandas as pd

history = pd.DataFrame(
    {"asksize": [10] * 5, "bidsize": [10] * 5},
    index=pd.date_range("2024-01-02 10:00", periods=5, freq="min"),
)
print(history.resample("5min").agg({"asksize": "sum", "bidsize": "sum"}))
print(history.resample("5min").last())

Observed: the documented aggregation returns 50 for each side; the last snapshot is 10. With the same price estimate, the Python example therefore calculates five times the C# example's value for this input.

Suggested correction

Aggregate the size columns with last to match QuoteBar consolidation, and describe the result as a quoted-size/notional estimate rather than total traded volume. This is an existing discrepancy in the example, independent of any change to Lean's runtime behavior.

Lingua principale
HTML
Stelle
266
Fork
189
Merge medio
7h 37m
PR unite (30g)
78

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 Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.