Outlier Detection after Detrending a Time Series With Missing Values or NaN
Problem
  
  The time series (end-of-day stock prices) has several 'uncomfortable' properties:
  
  
  It is non-stationary and can have components of low and high frequency (trends and sudden price moves)
  


These are not outliers though. These are valid signal behaviour.


  
  There can be missing data for some days, typically single occurrences, but sometimes a whole consecutive segment is missing
  Some values are erroneous (implausibly high or low i.e. due to misplaced decimal sign). These are the real outliers and don't belong to the series.
  


To reduce the effect of implausibly high or low values you can use a rolling median filter at a suitable time scale (e.g. depending on your sampling frequency, you might want to get the median of a day's transactions).

Missing data is a more challenging problem. A few missing values might be "patched" with some interpolation scheme but if you have almost a day's worth transactions missing, it is probably better to break the analysis into segments too. Otherwise, you would be assuming a lot for a part of the signal that you don't really know what happened in reality.

Hope this helps.