microsoft / microsoft/qlib

IndexError when using DataHandlerLP

Open
#1,831 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
48.7k
Forks
7.7k
PR merge metrics
No merged PRs in 30d

Description

Hello,

I am encountering an UnsortedIndexError when using DataHandlerLP in Qlib. It seems to be related to MultiIndex not being lexsorted. Could you provide guidance on how to resolve this issue?

UnsortedIndexError: 'MultiIndex slicing requires the index to be lexsorted: slicing on levels [0], lexsort depth 0'


handler = DataHandlerLP(
    data_loader={
        "class": "QlibDataLoader",
        "kwargs": {
            "config": {
                "feature": market_info,
                "label": ["Ref($close, -2)/Ref($close, -1) - 1"]
            },
        }
    },
    instruments="csi300",
    infer_processors=[
        {
            "class": 'RobustZScoreNorm', 
            'kwargs': {
                'clip_outlier': True, 
                'fields_group': 'feature', 
                'fit_start_time': '2009-01-01', 
                'fit_end_time': '2019-12-31'
            }
        },
        {
            'class': 'Fillna', 
            'kwargs': {
                'fields_group': 'feature',
            }
        },
    ],
    learn_processors=[
        {"class": 'DropnaLabel'},
        {
            "class": 'CSZScoreNorm', 
            'kwargs': {
                'fields_group': 'label',
            }
        },
    ],

)

Thank you.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied DataHandlerLP configuration and trace the MultiIndex slicing that raises UnsortedIndexError. The issue names no source file or test, so locate the relevant Qlib data-handling entry point first; done would require a documented or verified resolution for the lexsort failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.