# Wrong historical data for past 4 years

**URL:** <https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802>\
**Category:** Alpaca Market Data\
**Created:** [August 11, 2024, 9:17pm UTC](https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802 "2024-08-11T21:17:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![goon1983](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@goon1983](https://forum.alpaca.markets/u/goon1983)\
**Post date:** [August 11, 2024, 9:17pm UTC](https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802/1 "2024-08-11T21:17:09Z")

</div>

My code is below. It tres to get bars data of last 4 years:

```python
current_date = datetime.now()
days_ago = current_date - timedelta(days=4*365)
start_time = pd.to_datetime(days_ago).tz_localize('America/New_York')
request_params = StockBarsRequest(
    symbol_or_symbols="TQQQ",
    timeframe=TimeFrame.Day,
    start=start_time
)
bars_df = data_client.get_stock_bars(request_params).df.tz_convert('America/New_York', level=1)

```

Data from above code of Alpaca:

```auto
symbol. timestamp open high low close                                             
TQQQ 2020-08-13 00:00:00-04:00 128.0800 131.1800 126.53 127.90   
             2020-08-14 00:00:00-04:00 128.6600 129.1900 125.41 127.53   
             2020-08-17 00:00:00-04:00 129.8700 132.3600 129.66 131.74   
             2020-08-18 00:00:00-04:00 133.4300 136.4001 131.29 135.61  

```

From Yahoo-Finance. the data is

 ![Screenshot 2024-08-11 at 2.09.37 PM](https://us1.discourse-cdn.com/flex020/uploads/alp/original/2X/7/7e959fcc5aaccc27b420d41dcbacc75a177be81e.png)

All values are different.

Any ideas how to get the right data ?  
BTW, I tried both paper and live account. Data from both are wrong.

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [August 11, 2024, 11:06pm UTC](https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802/2 "2024-08-11T23:06:37Z")

</div>

@goon1983 By default the Alpaca prices are the ‘raw’ prices. Those are the actual traded prices on those days. The Yahoo data is ‘split adjusted’. Their prices account for stock splits so one can more easily compare current to past prices (without large price jumps if/when there is a stock split). You can fetch split adjusted data from Alpaca too. Simply add the parameter `adjustment='split'`. It’s also a good practice to explicitly specify the data feed (typically one wants SIP data). Something like this

```auto
request_params = StockBarsRequest(
    symbol_or_symbols="TQQQ",
    timeframe=TimeFrame.Day,
    start=start_time,
    adjustment='split',
    feed='sip'
)

```

You will then get data which matches the Yahoo data.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/alp/original/2X/1/1e7fc92b257825da362ba5d90037c657df387be6.png)

Additionally, it doesn’t matter whether you access data from a paper or live account. The data is the same. The data subscription is tied to the `owner_id`. The only thing the account number is used for is to lookup the `owner_id`.

---

<div class="post-metadata">

**Author:** ![goon1983](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@goon1983](https://forum.alpaca.markets/u/goon1983)\
**Post date:** [August 12, 2024, 4:22am UTC](https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802/3 "2024-08-12T04:22:31Z")

</div>

> [@Dan\_Whitnable\_Alpaca](#):
>
> ```auto
> feed='sip'
> 
> ```

Thanks @Dan_Whitnable_Alpaca for clarification.

BTW,

1. how long we can go back for historical data now? 5 years for regular user?

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [August 12, 2024, 12:17pm UTC](https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802/4 "2024-08-12T12:17:53Z")

</div>

@goon1983 Alpaca has historical equity data beginning 2016-01-04 (8+ years). This same data is available for both the free Basic and the paid data subscriptions.

---

<div class="post-metadata">

**Author:** ![goon1983](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@goon1983](https://forum.alpaca.markets/u/goon1983)\
**Post date:** [August 12, 2024, 9:12pm UTC](https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802/5 "2024-08-12T21:12:31Z")

</div>

Thanks @Dan_Whitnable_Alpaca . Another question about extra sticker in get\_stock\_bars.

I used the blow code to get bars data of a list of symbols but it returns extra ones. Below is the example. The BIOS is not in my required list but get\_stock\_bars returns its data.  
Any idea to explain this?

```auto
required symbols: {'ATXS', 'BOTT', 'SLAB', 'BYFC', 'NRIX', 'UDMY', 'BLBD', 'GHIXU', 'ATHA', 'ADUS', 'MTEKW', 'LUNG', 'DXR', 'JTEK', 'MGNX', 'BOCNU', 'RVSN', 'FYC', 'INDB', 'CNXN', 'TVGN', 'IROHR', 'GSMGW', 'CARV', 'RICK', 'BNOX', 'SPRO', 'BYNOU', 'CAFG', 'IVDAW', 'ICLN', 'PITA', 'DHAIW', 'NVDU', 'BRNS', 'INDY', 'WRAP', 'UAL', 'DTST', 'IPXX', 'AIMDW', 'AGNCN', 'SDA', 'TETE', 'METU', 'KYTX', 'LLYVA', 'CYCCP', 'CRGOW', 'WRND', 'VACHU', 'AFRM', 'HPAI', 'FLEX', 'OCGN', 'PXLW', 'LNTH', 'INNV', 'CDTX', 'BNIX', 'VC', 'COLM', 'INO', 'IAC', 'PLUS', 'TTGT', 'OPCH', 'FTNT', 'ATMC', 'MSEX', 'RPRX', 'UTRE', 'INTC', 'AACIW', 'HQGO', 'ARTW', 'AIQ', 'BABX', 'VFLO', 'CROX', 'LFMDP', 'STRS', 'CCLDO', 'FSTR', 'SEEL', 'RGF', 'DPRO', 'FPXE', 'WTMA', 'WISA', 'FCEF', 'IMOM', 'PWOD', 'BULD', 'GOGO', 'SMMT', 'PTEC', 'MCSE', 'MGX', 'WGMI'}

```

```auto
returned symbols {'ATXS', 'BOTT', 'SLAB', 'BYFC', 'NRIX', 'UDMY', 'BLBD', 'GHIXU', 'ATHA', 'ADUS', 'MTEKW', 'BIOS', 'DXR', 'LUNG', 'JTEK', 'MGNX', 'BOCNU', 'RVSN', 'FYC', 'INDB', 'CNXN', 'TVGN', 'IROHR', 'GSMGW', 'CARV', 'RICK', 'BNOX', 'SPRO', 'BYNOU', 'CAFG', 'IVDAW', 'ICLN', 'PITA', 'DHAIW', 'NVDU', 'BRNS', 'INDY', 'WRAP', 'UAL', 'DTST', 'AIMDW', 'AGNCN', 'SDA', 'TETE', 'METU', 'KYTX', 'LLYVA', 'CYCCP', 'CRGOW', 'WRND', 'VACHU', 'AFRM', 'HPAI', 'FLEX', 'OCGN', 'PXLW', 'LNTH', 'INNV', 'CDTX', 'BNIX', 'VC', 'COLM', 'INO', 'IAC', 'PLUS', 'OPCH', 'TTGT', 'FTNT', 'ATMC', 'MSEX', 'RPRX', 'UTRE', 'INTC', 'AACIW', 'HQGO', 'WGMI', 'ARTW', 'AIQ', 'BABX', 'VFLO', 'CROX', 'LFMDP', 'STRS', 'CCLDO', 'FSTR', 'RGF', 'SEEL', 'DPRO', 'FPXE', 'WTMA', 'WISA', 'FCEF', 'IMOM', 'PWOD', 'BULD', 'GOGO', 'SMMT', 'PTEC', 'MCSE', 'MGX', 'IPXX'}

```

```auto
Warning: Extra symbols found in data: {'BIOS'}

```

Below is the code

```auto
request_params = StockBarsRequest(
            symbol_or_symbols=tickers_batch,
            timeframe=TimeFrame.Day,
            start=start_time,
            adjustment='all',
            feed='sip'
        )
        # Fetch data and convert time zone
        bars_df = data_client.get_stock_bars(request_params).df
        
        if not bars_df.empty:
            requested_symbols = set(tickers_batch)
            returned_symbols = set(bars_df.index.get_level_values('symbol'))
            extra_symbols = returned_symbols - requested_symbols
            if extra_symbols:
                print("required symbols: ", set(tickers_batch))
                print("returned symbols", set(bars_df.index.get_level_values('symbol')))
                print(f"Warning: Extra symbols found in data: {extra_symbols}")

```

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [August 13, 2024, 3:19am UTC](https://forum.alpaca.markets/t/wrong-historical-data-for-past-4-years/14802/6 "2024-08-13T03:19:24Z")

</div>

@goon1983 Option Care Health, Inc. (OPCH) changed its symbol from BIOS to OPCH on 2020-02-03. For some reason, there is exactly one bar for BIOS on 2020-02-03 probably related to that symbol change. All the data for OPCH (ie the new symbol is correct and carries backwards to the old symbol (ie 2020-02-03 is not missing). I’ve notified the Data Team to look into this. Thanks for bringing it up.
