Mean Reverting Asset Trading Project Presentation CSCI-5551 Grant Meyers
Table of Contents Review Revision of Technique New Search Algorithm Parallelization Project Results
1. Review Mean Reverting Asset + Goal
Review – Mean Reverting Asset
Example Mean Reverting Asset Example Generated with: data=RandomFunction[OrnsteinUhlenbeckProcess[0,1,.1],{0,15,.1}] ListLinePlot[data,Filling->Axis,AxesLabel->{HoldForm[Time],HoldForm[Worth]},PlotLabel->HoldForm[Mean Reverting Stock Price - Centered at 0],LabelStyle->{12,GrayLevel[0],Bold}] Via Mathematica. Due to OrnsteinUhlenbeckProcess being a random process, your generated graph will look different, but will maintain the properties required.
Goal – Price Selection We want to select 2 prices. Price 1 is ‘buy’ price, this is an upper limit of when to start purchasing shares. Price 2 is ‘sell’ price, this is a lower limit of when to start selling shares.
Goal – Price Selection Better:
Goal – Optimal Price Selection What are the best buy / sell prices for a given stock? How do we find these prices?
Goal – Optimal Price Selection What are the best buy / sell prices for a given stock? Specific per stock. How do we find these prices? Algorithmic search on historic data
Table of Contents Review Revision of Technique New Search Algorithm Parallelization Project Results
2. Revision of Technique Mean reverting assets are rare
Findings from Previous Work Finding #1 – Mean Reverting Assets are hard to find. None of the tech / commodity stocks I tested could be classified as a ‘Mean Reverting Asset’. Finding #2 – Most stocks follow fairly closely with a regression line. Finding #3 - Deviation from regression line is parallelizable much more easily than the Stochastic Approximation techniques previously discussed.
A New Technique – Deviation from Regression Line Stocks tend to follow a fairly predictable trend. Regression is history based and is an attempt to find the overall direction and slope of an asset’s price. Similar to the ‘mean reversion’ process where volatility pushes the price above and below a known / calculable quantity. Follow the same strategy of - Buy low Sell High.
Table of Contents New Search Algorithm Review Revision of Goals Parallelization Project Results
3. New Search Algorithm Subset of regression deviation ranges
Regression Line Search Space Orange is the regression line Green is the highest possible selling point Red is the lowest possible buying point
Regression Line Search Space - Partitions Each color band is a range to test – Buy or Sell ranges Top 3 are sell ranges 105% of regression normal 110% of regression normal 115% of regression normal Bottom 3 are buy ranges 95% of regression normal 90% of regression normal 85% of regression normal
Independent Search Threads We have 3 buy ranges and 3 sell ranges (on example graph). Creating all pairs of 1 buying range and 1 selling range, creates 9 sets. All of these sets can be optimized independently as they do not overlap. Optimized - most profit, from buying in buy range and selling sell range.
Table of Contents Parallelization Review Revision of Goals New Search Algorithm Parallelization Project Results
4. Parallelization
Required work Load training data. Create regression model. Find high and low points for price deviation from regression line. Partition work space. Find best price in assigned ranges to buy & sell. Calculate profit for assigned ranges buy & sell. Merge best ranges + find most profitable range. Calculate + return profit on test data. Steps 5, 6 are done in parallel.
Serial Work Load training data. Create regression model. Find high and low points for price deviation from regression line. Partition work space. Find best price in assigned ranges to buy & sell. Calculate profit for assigned ranges buy & sell. Merge best ranges + find most profitable range. Calculate + return profit on test data. Clean-Up
Top Level Parallel Work Load training data. Create regression model. Find high and low points for price deviation from regression line. Partition work space. Find best price in assigned ranges to buy & sell. Calculate profit for assigned ranges buy & sell. Merge best ranges + find most profitable range. Calculate + return profit on test data. Clean-up Steps 5, 6 are done in parallel.
2nd Level Parallel Work Load training data. Create regression model. Find high and low points for price deviation from regression line. Partition work space. Find best price in assigned ranges to buy & sell. Calculate profit for assigned ranges buy & sell. Merge best ranges + find most profitable range. Calculate + return profit on test data. Clean-up Steps 5, 6 are done in parallel.
Work Diagram – See Work Diagram PDF Steps 5, 6 are done in parallel.
Table of Contents Project Results Review Revision of Goals New Search Algorithm Parallelization Project Results
5. Project Results Sample Results
Observations The larger the deviations from the regression model, the larger the search space and time it takes to find the optimum buy / sell deviation prices. Small deviation search spaces go REAL quick (in less than a second). Executor services can take a decent amount of time to clean-up after they are completed.
Observations The largest factor in determining the runtime is the STEP_SIZE variable in the FindOptimumInRange class. 1 cent is the maximal logical STEP_SIZE, but it will max the search timeout for any decently size deviation.
Some Statistics Symbols: CVX, GOOGL, AAPL, MSFT Time To Completion STEP_SIZE THREAD_POOL_SIZE PARTITIONS_COUNT SUB_THREAD_POOL_SIZE 42.396s 0.05 1 4 8 12.975s 0.1 2.117s 0.5 1.869s 43.456s 2 12.191s 2.324s 1.875s 43.649s 3 12.258s 2.436s 2.043s 44.373s 12.388s 2.511s 1.710s
SUB_THREAD_POOL_SIZE Some Statistics Symbol: CVX Time To Completion STEP_SIZE THREAD_POOL_SIZE PARTITIONS_COUNT SUB_THREAD_POOL_SIZE 3.511s 0.01 1 0.484s 0.1 0.360s 0.5 0.313s 3.228s 2 0.375s 0.328s 0.343s 2.119s 0.344s 2.174s 4 0.391s
SUB_THREAD_POOL_SIZE Some Statistics Symbol: GOOGL Time To Completion STEP_SIZE THREAD_POOL_SIZE PARTITIONS_COUNT SUB_THREAD_POOL_SIZE 240.304s 0.01 1 24.759s 0.1 1.316s 0.5 0.578s 240.318s 2 24.716s 1.325s 0.594s 240.326s 13.102s 0.844s 0.437s 240.333s 4 7.641s 0.672s 6.757s 8 0.641s
SUB_THREAD_POOL_SIZE Some Statistics Symbol: AAPL Time To Completion STEP_SIZE THREAD_POOL_SIZE PARTITIONS_COUNT SUB_THREAD_POOL_SIZE 240.476s 0.01 1 16.216s 0.1 0.978s 0.5 0.485s 240.329s 2 17.629s 1.176s 0.641s 240.450s 9.384s 0.844s 0.657s 240.555s 4 5.690s 0.610s 0.406s 4.501s 8 0.546s
SUB_THREAD_POOL_SIZE Some Statistics Symbol: MSFT Time To Completion STEP_SIZE THREAD_POOL_SIZE PARTITIONS_COUNT SUB_THREAD_POOL_SIZE 0.528s 0.01 1 0.453s 0.1 0.422s 0.5 0.547s 2 0.469s 0.438s 0.516s 0.437s 0.515s 4 0.500s 0.485s 0.483s