`LeanData.TryParsePath` fails on an absolute universe file path

Aperta Adatta ai principianti
#10,005 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
data

Direzione di ricerca

L'indice fisso filePathParts[2] usato per il mercato si trova in ParseUniversePath, che viene chiamato da LeanData.TryParsePath. Leggi prima TryParsePath per capire dove viene trovato startIndex, poi passa il mercato a partire da startIndex + 1 invece dell'indice fisso. Aggiungi i due casi a LeanDataTests.UniversesDataPath ed esegui quel test; è completato quando tutti gli 8 casi passano.

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

Descrizione

Expected Behavior

LeanData.TryParsePath parses a universe file path wherever the data folder sits, for example /Lean/Data/option/usa/universes/aapl/20241112.csv. The market is usa.

Actual Behavior

TryParsePath returns false for that path. ParseUniversePath takes the market from a fixed index, filePathParts[2]. That index holds the market only when the path has exactly 1 folder before the security type, as in Data/option/usa/.... For /Lean/Data/option/usa/..., index 2 is option, so the market is option.

DownloaderDataProvider.Fetch calls TryParsePath on the file key. In the engine image the data folder is /Lean/Data, so a missing universe file looks like it is not downloaded. A backtest logs this line once:

ERROR:: LocalDiskMapFileProvider.GetMapFileResolver(option): The specified directory does not exist: /Lean/Data/equity/option/map_files
Potential Solution

TryParsePath already finds the position of the security type, startIndex. Pass the market from info[startIndex + 1] to ParseUniversePath, or pass startIndex, in place of the fixed index.

Reproducing the Problem

Add these 2 cases to LeanDataTests.UniversesDataPath:

[TestCase("/Lean/Data/option/usa/universes/aapl/20241112.csv", SecurityType.Option, Market.USA, Resolution.Daily, "AAPL", "2024/11/12", false)]
[TestCase("/Lean/Data/future/cme/universes/es/20111230.csv", SecurityType.Future, Market.CME, Resolution.Daily, "ES", "2011/12/30", false)]

On master at 138382568, both new cases fail on Assert.IsTrue(LeanData.TryParsePath(...)), and the 6 existing cases pass:

Expected: True
But was:  False

I saw the log line above in a daily option backtest with a downloader data provider, in a local build. A run of the same algorithm with the local data provider did not log it.

System Information

Windows 11, .NET SDK 10.0.403, master at 138382568. The log line came from the engine image, on Linux.

Checklist
  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
Lingua principale
C#
Stelle
22.3k
Fork
5.4k
Merge medio
1g 15h
PR unite (30g)
51

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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/Lean

Tutte le issue di QuantConnect/Lean

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.