Hello,

Fairly new to quantopian, self-taught python. Not the most experienced programmer.

My algorithm has hit a roadblock that I do not understand.

## I have isolated the problematic code:

```
closes_15m = data.history(context.spylong,'close',390,'1m').resample('15T', label = 'right').mean() #.last()
highs_15m = data.history(context.spylong,'high',390,'1m').resample('15T', label = 'right').mean() #.last()
lows_15m = data.history(context.spylong,'low',390,'1m').resample('15T', label = 'right').mean() #.last()
ema_8 = talib.EMA(closes_15m, timeperiod=8)
ema_20 = talib.EMA(closes_15m, timeperiod=20)
ema_high = talib.EMA(highs_15m, timeperiod=14)
ema_low = talib.EMA(lows_15m, timeperiod=14)
```

After some scrutinizing, I found two issues so far:

1). When I run the algorithm and have it print highs_15m, it prints the highs for bars after market close. Literally, at timestamps past 16:00, such as 16:15:00, it will give me a high value which I guess is an aftermarket bar's high? I do not understand why it is calculating aftermarket bar highs and I would like it not to.

2). When I run the algorithm and have it print ema_high, every trading day it will wait for 13 bars (warming up I presume) and then at the end of the 14th bar (reminder: bars are each 15m), it will print values until at some point which if I recall correctly is 3 bars or so prior to market close, it will start to print NaN's and it will print out a lot of these NaN's even well after market close.

## Here is the log output for phenomenon 1:

2017-07-06 09:45 PRINT 2017-07-05 14:00:00+00:00 34.291923

2017-07-05 14:15:00+00:00 34.195533

2017-07-05 14:30:00+00:00 34.139867

2017-07-05 14:45:00+00:00 34.266929

2017-07-05 15:00:00+00:00 34.385571

2017-07-05 15:15:00+00:00 34.447071

2017-07-05 15:30:00+00:00 34.466000

2017-07-05 15:45:00+00:00 34.427889

2017-07-05 16:00:00+00:00 34.400000

2017-07-05 16:15:00+00:00 34.386375

2017-07-05 16:30:00+00:00 34.448100

2017-07-05 16:45:00+00:00 34.466385

2017-07-05 17:00:00+00:00 34.497083

2017-07-05 17:15:00+00:00 34.515000

2017-07-05 17:30:00+00:00 34.543727

2017-07-05 17:45:00+00:00 34.543143

2017-07-05 18:00:00+00:00 34.503667

2017-07-05 18:15:00+00:00 34.511538

2017-07-05 18:30:00+00:00 34.526667

2017-07-05 18:45:00+00:00 34.600000

2017-07-05 19:00:00+00:00 34.528273

2017-07-05 19:15:00+00:00 34.463615

2017-07-05 19:30:00+00:00 34.506727

2017-07-05 19:45:00+00:00 34.551308

2017-07-05 20:00:00+00:00 34.566000

2017-07-05 20:15:00+00:00 34.580000

2017-07-05...

2017-07-06 10:00 PRINT 2017-07-05 14:15:00+00:00 34.190929

2017-07-05 14:30:00+00:00 34.139867

2017-07-05 14:45:00+00:00 34.266929

2017-07-05 15:00:00+00:00 34.385571

2017-07-05 15:15:00+00:00 34.447071

2017-07-05 15:30:00+00:00 34.466000

2017-07-05 15:45:00+00:00 34.427889

2017-07-05 16:00:00+00:00 34.400000

2017-07-05 16:15:00+00:00 34.386375

2017-07-05 16:30:00+00:00 34.448100

2017-07-05 16:45:00+00:00 34.466385

2017-07-05 17:00:00+00:00 34.497083

2017-07-05 17:15:00+00:00 34.515000

2017-07-05 17:30:00+00:00 34.543727

2017-07-05 17:45:00+00:00 34.543143

2017-07-05 18:00:00+00:00 34.503667

2017-07-05 18:15:00+00:00 34.511538

2017-07-05 18:30:00+00:00 34.526667

2017-07-05 18:45:00+00:00 34.600000

2017-07-05 19:00:00+00:00 34.528273

2017-07-05 19:15:00+00:00 34.463615

2017-07-05 19:30:00+00:00 34.506727

2017-07-05 19:45:00+00:00 34.551308

2017-07-05 20:00:00+00:00 34.566000

2017-07-05 20:15:00+00:00 34.580000

2017-07-05 20:30:00+00:00 NaN

2017-07-05...

2017-07-06 10:15 PRINT 2017-07-05 14:30:00+00:00 34.139143

2017-07-05 14:45:00+00:00 34.266929

## 2017-07-05 15:00:00+00:00 34.385571

## Here is the log output for phenomenon 2:

2017-07-06 09:45 PRINT [ nan nan nan nan nan

nan nan nan nan nan

nan nan nan 34.38098045 34.40268003

34.42140841 34.43237617 34.44293115 34.45409588 34.47354976

34.48084616 34.47854872 34.48230586 34.49150611 34.50143863

34.51191348 nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan ...

2017-07-06 10:00 PRINT [ nan nan nan nan nan

nan nan nan nan nan

nan nan nan 34.39863756 34.41790493

34.42933983 34.44029965 34.45181525 34.47157322 34.47913315

34.47706411 34.4810192 34.490391 34.5004722 34.51107591

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan ...

2017-07-06 10:15 PRINT [ nan nan nan nan nan

nan nan nan nan nan

nan nan nan 34.42374402 34.43440037

34.44468545 34.45561628 34.47486744 34.48198815 34.47953844

34.48316362 34.4922495 34.5020829 34.51247185 nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

nan nan nan nan nan

## nan nan ...

Please help as I am absolutely and utterly confused and without any inkling of why or how this is happening.

Thanks in advance!