stockparfait / experiments

Statistical experiments with financial data
Apache License 2.0
0 stars 0 forks source link

Implement distribution experiment #11

Closed sergey-a-berezin closed 2 years ago

sergey-a-berezin commented 2 years ago

Plot the p.d.f. of a sample distribution for the log-profit of a stock or a collection of stocks.

The default option is to normalize MAD (mean absolute deviation) and mean to be 1.0 and 0.0, respectively, before accumulating the log-profits in the histogram. Disabling such normalization may only make sense for a single stock, or a set of closely related stocks whose MAD and mean are expected to be the same.

Add an option to overlay an analytical distribution, specifically the normal and Student's T distributions, for comparison with the sample distribution. Their mean and MAD by default should match the sample distribution if it wasn't normalized. The alpha parameter in the Student's T distribution still must be provided; the default can be set to 3, or perhaps 2.55 (my previous more accurate estimate for the last 20 years - to be re-assessed).

sergey-a-berezin commented 2 years ago

Process multiple stocks in parallel, to improve performance. Experiment how many stocks to batch for each unit of work.

sergey-a-berezin commented 2 years ago

Idea: rather than a log-scale Y axis, use log10(p.d.f.) and linear Y axis. This should display better in HTML graphs.

sergey-a-berezin commented 2 years ago

Another idea: plot a list of configured quantiles as vertical dashed lines. This way, we can visually mark e.g. 90% of all the stock moves by displaying 5th and 95th percentile.

sergey-a-berezin commented 2 years ago

To complete the experiment, add an option to plot the distribution of means and MADs across all stocks. The distribution can be unweighted (one stock, one sample), or weighted by cash volume (counters are augmented by the total cash volume within the time range rounded to an integer, e.g. the whole dollars).

This may require an additional method for the Histogram such as AddCount(x float64, n uint), which effectively adds x value n times.