Serving the Quantitative Finance Community

 
User avatar
Amin
Topic Author
Posts: 2572
Joined: July 14th, 2002, 3:00 am

Re: Application of Filtering Principles Towards Trading Stock Prices

January 28th, 2022, 4:57 pm

Please first download the prototype matlab program for this project on last post on previous page, this thread.

Before I write the notes about the program in previous post, I would like to tell friends that I had made a careless but serious error in earlier version of the program. While reading stock data from file, I was reading bids and instead of ask prices, I was reading last trade.( I never gave appropriate time to this program and was mostly busy last year with my SDEs research) That resulted in my earlier saying the average bid-ask spread for Tesla is 8-9 cents which is only roughly half of total bid-ask spread. Actual bid-ask spread is 16-17 cents for the 15 second periods I have. Even if we take all of the continuous data, I doubt that it could ever be smaller than 10 cents. When I re-ran the algorithm, trades decreased to roughly 23,000 from 27,000 and mid-price profits changed from $411 to $393 on the decreased number of trades. 
Following are the notes for friends

1. It is an AR(4) process whose parameters I am filtering for TESLA. For most stocks an ARMA(p,q) process would fare much better. It is these auto-regressive parameters with four different lags that I am filtering. After filtering the parameters, I make a prediction and if the prediction is greater than a positive threshold, stock is declared buy and if lower than a certain negative threshold, the stock is declared a sell. These thresholds have been chosen by me very roughly and should be a part of optimization in final analysis. 

2. I have done rough optimization of free variance parameters by iteratively changing them by hand. This is sub-optimal and usually will not result in the best parameters. A proper optimization routine has to be written for optimization of free variances.

3. I have taken covariances between all parameters zero so all variance-covariance matrices are diagonal. This is handy for the first prototype but in the final industrial program, these covariances would have to be included or found by optimization and  tis will change the current linear structure of the Kalman-like algorithm to matrix-vector multiplications. Good choice of covariances would greatly alter the result of filtering parameters and result in much better profits.

4. I have also used a stop-loss limit per trade and profit-taking limit per trade and both of these limits change the final profits. They also have to be optimized for best results. In this program, they are pretty much unoptimized and only very roughly optimized.

5. This is just an initial proof-of-concept program and may have many errors. Please pardon any errors.

6. I will continue to work on better versions of the program and if friends would like, I can develop better proprietary trading algorithms for them that are better in every respect and suitable for trading. If you want me to do that, please email me at anan2999(at)yahoo(dot)com as I have wonderful ideas for better programs.
You think life is a secret, Life is only love of flying, It has seen many ups and downs, But it likes travel more than the destination. Allama Iqbal