top of page

Markov Chain Proj.: Return (▲Price) with Highest & Above Zero Probabilities, SQQQ, 21/12/2021

Güncelleme tarihi: 4 Nis 2022

*Remember that when an interactice chart is cited on the post, by clicking on it the source code will be shown, In order to visualize it on the right way, download the file as html and open it with your browser.*

1. Linear Programming

In prior posts it had been discussed about the probabilities of the different bins for the coming weeks (days if a certain user decides to use this collapse option) and how they help to take timely decision based on their values and odds. Looking solely at the numbers is a way to inspect the data; however, most of speculators are graphically-driven people, then it is of utmost help to represent it on a convenient way. To do so, some inputs are required and will not be here elaborated as in this post they are explained in detail.

The graph at the beginning of this post corresponds to the univariate spline that will alow the user to find out what is the return (▲Price) with the highest probability of ocurrence according to the following input values:

SQQQ, frequency table, most traded etfs, nasdaq, nyse, python
Historical Data, Frequency Table & Bins Limit Values - SQQQ

The function has the following structure:



  • df is a pandas dataframe that contains a frequency table with the characteristics shown above.

  • feat is an iterable object (e.g. array, list, etc.) that contains the values for the x axis of the spline.

  • n is simply the fontsize for the legend.

  • list_ac is any empty list where both the ▲Price with the highest probability and its probability will be stored as a two element list. "list_ac" will have as many elements as it is run as it appends values rather than replacing them.

  • _s_ is solely the marker size for the spline graph.

  • smtf2 is a feature that can take one of the following values:

- "na" as string that allows the user to choose the smoothing factor

after inspecting the graph. If selected, the value is stored under

the name "smt_fct2".

- 0 as float which runs a spline of degree "3" and smoothing factor


- A positive float which runs a spline of degree "2" and smoothing

factor "smft2". Even though a degree of "2" is not recommended,

by doing this a positive probability outcome is ensure.

On the other hand, the graph below corresponds to the acumulated univariate spline that allows the user to compute the probability of ▲Price >0, which means positive return:

The function has exactly same structure as the prior one:


Under current inputs and methodlogy (LP) the probability of giving a positive return is 23,7% while the ▲Price with the highest probability is 4,98@63,18%. Before moving towards the estimations on prices, it is important to examine how historical ▲Prices, spline, and markov Chain states correlate. The following graph helps to viasualize it:

As seen above, the probability of negative returns around -10 have been increasing while those around the positive same value decreased through Markov states two to nine, a first indicative of turning towards more probable negative returns. The spline shows a good fit around the historical values (dark green dots) without touching them despite the "2" degree. The turn to ▲Prices below zero is supported by the priorly calculated probability of positive return of merely 23,7%.

Finally, all the data collected is communicated as follows:

markov chains, probabilities, bayes, sqqq, nyse, nasdaq, etfs, most traded etfs, plotly, python
Markov Price Estimations & ▲Price > 0 Indicator - SQQQ

By checking the real file the most probable price yields to 11,04@61,65% (purple dot) while there is a probability of 94,12% for the price to end up between 0,69 and 16,65 as extreme cases. As the range goes over zero, the oods of staying on the positive side are 0,29.

2. Bootstrapping

As the reader is already familiarized with the spline shown above, it will only be discussed the differences between methodologies i.e. while with LP ▲Price got 4,98@63,18% with bootstrapping the estimation yields to 4,35@61,58%, a bit more conservative. This difference can be better observed by checking the inputs:

SQQQ, frequency table, most traded etfs, nasdaq, nyse, python, bootstrapping
Historical Data, Frequency Table & Bins Limit Values - SQQQ

At first glance, while LP's initial vector had the elements [0,0,0,1,0], Bootstrapping one has [0,0,1,0,0], it is of utmost importance on defining the probabilities of the Markov states. Additionally, as the bootstrap runs 1039 times, there is more data available for the program to be more accurate, thus it reaches the stable state on merely four weeks while LP needed eight. Therefore, as 157 entries from the LP methodology left part of the data biased to the right, the higher value for the return with maximum probability.

Regarding the probability of getting a ▲Price above zero LP computed 23,7% while bootstrapping 21,97%, again, a more conservative result. Subsequently, historical ▲Prices, spline, and markov Chain states correlate on the following way:

As can be seen in the real file, the Markov statements don't have major displacements toward the spline, which confirms that indeed the bootstrapping method yielded to more accurate results, an aspect that is widely mentioned in literature related to statistics or programming. Consequently, the projections for the following weeks is shown below:

The most probable price yields to 10,69@61,58% (blue dot) while there is a probability of 93,80% for the price to end up between -0,80 and 15,10 as extreme cases. The reader can note that the range is 2,5 times the initial price for both LP and bootstrapping; however, the latter needs only six states to reach the steady state while the prior one needs ten (one month more). Finally, as the range goes over zero, the oods of staying on the positive side are 0,27.

All these calculations are based on probabilities, which can fail sometimes; however, the developed algorithm to reach those numbers has been thought to reduce such failures to their lowest level.


bottom of page