Measuring Intraday Fading with Subsampled Price Direction
Summary
The document asks how to define a stock that fades through the day in a way that can be measured. An open-to-close decline alone may miss a rise earlier in the session followed by a sharp late drop. The questioner suggests requiring an early high of day that is not revisited, while the response proposes measuring direction across sampled intraday prices.
The proposed statistic assigns each sampled price change a positive or negative sign and averages those signs; a larger negative value indicates more downward moves. Sampling less frequently can produce a stronger directional reading than using every observation, since frequent changes may offset one another. A simulation of intraday price paths illustrates this sampling effect, but it does not establish that the measure identifies real stock fades or predicts returns. The definition depends on sampling interval and threshold choices, which should be evaluated on the intended data and use case.
Key ideas
- An open-to-close decline may not capture the timing and persistence of an intraday fade.
- A directional score can be formed by averaging the signs of sampled price changes.
- The response illustrates that more frequent sampling can dilute the score as moves offset one another.
- A simulated price-path example demonstrates the sampling behavior but does not validate a stock trading signal.
Tags
Full text
# Stock fades off all day
# Stock fades off all day
I have collected data to analyse statistically certain patterns. One of them gives me quite a high certainty it will fade off all day. Visually, when I observe a graph, it's straightforward if a stock fades all day or not (even if there's some occasional gaps). A simple definition of a stock which fades all day might be that the open price is high than the close price. The problem is it might go up till 2:00PM and fade quite dramatically till the close. Is there a way to define "fades all day" so that it can be implemented.
EDIT
A way to define it, it could be that the open is higher than the close and it reached its last high of day between 9:30AM and 11:30AM and never reached back its HOD before 4:00AM.
## Answer by will (score 1, accepted)
https://quant.stackexchange.com/a/74757
How much intraday data do you have / want to consume?
i.e. you could do something like take a snap every d$t$ and then demand that it's monotonic, or make some slightly looser variant of that rule or something (i.e. above a certain percentage of d$t$ time periods are down moves).
You have a ton of flexibility though.
for example:
```
import numpy as np
from matplotlib import pyplot
from matplotlib.colors import LinearSegmentedColormap
s0 = 100
σ = 0.2
n_paths = 1000
n_t = 24*60
tt = np.linspace(0,1/365,n_t)
n_t = len(tt)
ln_ss = np.zeros(shape=(n_t,n_paths))
#rr = np.random.randn(n_t,n_paths)
for it, t in enumerate(tt[1:], start=1):
dt = t - tt[it-1]
ln_ss[it,:] = ln_ss[it-1,:] - 0.5*σ*σ*dt + np.sqrt(dt)*σ*rr[it]
ss = s0 * np.exp(ln_ss)
cmap = LinearSegmentedColormap.from_list('a', ['xkcd:red', 'xkcd:goldenrod', 'xkcd:turquoise'])
def get_trend_signal(x, sub_sample=None):
if sub_sample != None:
x = x[::sub_sample]
dx = x[1:] - x[:-1]
dx[dx>0] = 1
dx[dx<=0] = -1
return sum(dx)/len(dx)
tt *= 24*365
subsamples = [None, 10, 30, 60, 120]
cc = ['red', 'green', 'blue', 'purple', 'orange']
n_subsamples = len(subsamples)
fig = pyplot.figure(figsize=(20,20))
ax_paths = [fig.add_subplot(2,n_subsamples,i+1) for i in range(n_subsamples)]
ax_hist = fig.add_subplot(2,1,2)
for i_subsample, subsample in enumerate(subsamples):
signals = []
for i_path in range(n_paths):
path = ss[:,i_path]
signal = get_trend_signal(path, sub_sample=subsample)
signals.append(signal)
ax_paths[i_subsample].plot(tt, ss[:,i_path], c=cmap((signal+1)/2), alpha=0.2)
ax_paths[i_subsample].set_xlabel('time (hours)')
ax_paths[i_subsample].set_ylabel('price (years)')
ax_paths[i_subsample].set_xlim(0,24)
if subsample is None:
label = 'no subsampling'
else:
label = f'subsampled every {subsample} minutes'
ax_hist.hist(signals, bins=np.arange(-1,1,0.05), label=label, alpha=0.5, facecolor=cc[i_subsample], density=True)
ax_hist.set_xlabel('signal')
ax_hist.legend()
pyplot.show()
```
Where the code montecarlos some prices intraday, and then takes the difference of prices through the day, then coutns a positive difference as a 1 and a negative difference as a -1, and takes the mean of all the values, subsampled at different intervals, and then colours the paths based on the signal strength. You can clearly see that if you sample too many times, your samples all end up averaging out to zero, while if you sample less frequently you get a stronger signal.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.