Skip to content

Data.get ignores column argument for multi-symbol data #840

@jcazalis

Description

@jcazalis

Data.get(column='S') does not behave correctly: the column argument is ignored and it returns the same DataFrame as Data.get().

Minimal repro

import pandas as pd
import vectorbt as vbt

class RandomData(vbt.Data):
    @classmethod
    def download_symbol(cls, symbol, **kwargs):
        index = pd.date_range("2021-01-01", "2021-01-03")
        return pd.Series([1.0, 2.0, 3.0], index=index)  # unnamed Series

rand_data = RandomData.download(["RANDNX1", "RANDNX2"])
print(rand_data.get(column="RANDNX1"))

Output is

symbol                     RANDNX1  RANDNX2
2021-01-01 00:00:00+00:00      1.0      1.0
2021-01-02 00:00:00+00:00      2.0      2.0
2021-01-03 00:00:00+00:00      3.0      3.0

Observed behavior

get(column="RANDNX1") returns the same result as get()

Expected behavior

get(column="RANDNX1") should return only the data for symbol RANDNX1

Cause

It seems to come from the concat method, which doesn't behave properly. concat() returns a dict with None as the only key

rand_data.concat(level_name="RANDNX1")

Output is

{None: RANDNX1                    RANDNX1  RANDNX2
 2021-01-01 00:00:00+00:00      1.0      1.0
 2021-01-02 00:00:00+00:00      2.0      2.0
 2021-01-03 00:00:00+00:00      3.0      3.0}

Environment

vectorbt 0.28.5
Python 3.13.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions