# Polygon data not consistent with other data source

**URL:** <https://forum.alpaca.markets/t/polygon-data-not-consistent-with-other-data-source/3335>\
**Category:** Alpaca Market Data\
**Created:** [November 16, 2020, 10:48pm UTC](https://forum.alpaca.markets/t/polygon-data-not-consistent-with-other-data-source/3335 "2020-11-16T22:48:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanke\_zulu](https://avatars.discourse-cdn.com/v4/letter/y/f6c823/32.png) [@yanke\_zulu](https://forum.alpaca.markets/u/yanke_zulu)\
**Post date:** [November 16, 2020, 10:48pm UTC](https://forum.alpaca.markets/t/polygon-data-not-consistent-with-other-data-source/3335/1 "2020-11-16T22:48:11Z")

</div>

Hi  
I am trying to get polygon data with following code, however I am facing two problem  
1-the data I receive is not consistent with other source,in my case AAPL daily data  
printed data is below  
2-I am receiving an error once assigning the data to backtrader, error below  
it seems data is received but can not be assigned to backtrader data frame

NY = ‘America/New\_York’

ALPACA\_API\_KEY =  
ALPACA\_SECRET\_KEY =  
ALPACA\_API\_BASE\_URL= “[https://paper-api.alpaca.markets](https://paper-api.alpaca.markets)”  
ALPACA\_PAPER = True

store = alpaca\_backtrader\_api.AlpacaStore(  
key\_id=ALPACA\_API\_KEY,  
secret\_key=ALPACA\_SECRET\_KEY,  
paper=ALPACA\_PAPER  
)

if not ALPACA\_PAPER:  
broker = store.getbroker() # or just alpaca\_backtrader\_api.AlpacaBroker()  
cerebro.setbroker(broker)

api = tradeapi.REST(ALPACA\_API\_KEY, ALPACA\_SECRET\_KEY, base\_url=ALPACA\_API\_BASE\_URL)

d\_start=pd.Timestamp(‘2020-10-01’, tz=NY).isoformat() ## day data  
d\_end=pd.Timestamp(‘2020-10-14’, tz=NY).isoformat()

data = api.polygon.historic\_agg\_v2(‘AAPL’, 1, ‘day’, \_from=d\_start, to=d\_end).df  
print(data)  
cerebro.adddata(data)

```
                        open high low close volume vwap

```

timestamp  
2020-10-01 00:00:00-04:00 117.64 117.72 115.8300 116.79 112824590.0 116.5940  
2020-10-02 00:00:00-04:00 112.89 115.37 112.2200 113.02 139442161.0 113.8688  
2020-10-05 00:00:00-04:00 113.92 116.65 113.5500 116.50 106010004.0 115.4564  
2020-10-06 00:00:00-04:00 115.70 116.12 112.2500 113.16 155506372.0 114.4525  
2020-10-07 00:00:00-04:00 114.62 115.51 114.1300 115.08 95862909.0 114.9180  
2020-10-08 00:00:00-04:00 116.27 116.40 114.5901 114.97 82756166.0 115.2687  
2020-10-09 00:00:00-04:00 115.28 117.00 114.9200 116.97 98222295.0 116.2439  
2020-10-12 00:00:00-04:00 120.06 125.18 119.2845 124.40 240242015.0 123.0341  
2020-10-13 00:00:00-04:00 125.27 125.39 119.6500 121.10 261890079.0 122.4302  
2020-10-14 00:00:00-04:00 120.99 123.03 119.6200 121.19 147227059.0 121.3124  
2020-10-15 00:00:00-04:00 118.72 121.20 118.1500 120.71 109249323.0 120.0721

-----------------error message  
Exception has occurred: AttributeError  
‘DataFrame’ object has no attribute ‘setenvironment’  
File “C:\Users\mucah\Alpaca-VisualStudioCode\PolygonData.py”, line 65, in   
cerebro.adddata(data)
