Skip to content

Innaccurate Historical Data #248

@WhileE

Description

@WhileE

Description

Inaccurate historical data for some equities. I just threw together a simple test to look at data visualization options, and immediately noticed some oddities with TQQQ/SQQQ, same code works perfectly fine with AAPL?

Is there something I'm missing because they're ETF's, or is there an underlying bug that I'm not aware of? I searched a bit in the issues, but didn't see anything related.

Code

def init(symbol, state: StrategyState):
    interface: Interface = state.interface
    resolution: float = state.resolution
    variables = state.variables
    variables["history"] = interface.history(symbol, 800, resolution, return_as='deque')["close"]

def bar_event(bar, symbol, state):
    pass

if __name__ == "__main__":
    alpaca = Alpaca()
    s = Strategy(alpaca)
    s.add_bar_event(bar_event, "AAPL", resolution="1d", init=init)
    
    result = s.backtest(initial_values={"USD": 1000}, to="3y", GUI_output=False)
    history = result.history['AAPL']
    fig = make_subplots(rows=1, cols=1, shared_xaxes=True, vertical_spacing=None)
    
    fig.add_trace(
        go.Candlestick(
            x=pd.to_datetime(history.time,unit='s'),
            open=history.open,
            high=history.high,
            low=history.low,
            close=history.close),
         col=1,row=1
    )    
    fig.show()

TQQQ in Blankly

TQQQ-3y_1d

TQQQ Actual

ACTUAL_TQQQ-3y_1d

AAPL in Blankly

AAPL-3y_1d

AAPL Actual

ACTUAL_AAPL-3y_1d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions