Profile avatar
optionstocksmachines.com
Options, stocks, machines: Driven by data, Tamed by Python and R https://www.optionstocksmachines.com/ Helping coders invest, and investors code
59 posts 96 followers 37 following
Prolific Poster

๐—›๐—™๐—ช ๐Ÿฑ: ๐—ฆ๐—ถ๐—บ๐—ฝ๐—น๐—ฒ ๐—บ๐—ผ๐˜ƒ๐—ถ๐—ป๐—ด ๐—ฎ๐˜ƒ๐—ฒ๐—ฟ๐—ฎ๐—ด๐—ฒ๐˜€ to forecast S&P 500 sector revenues. Not to be confused with moving average models that use lagged error terms! Individual company error rates are often meaningful different from other models. Ensembling? Stay tuned! optionstocksmachines.substack.com/p/hfw-5-simp...

๐—•๐—ข๐—ง๐—ช ๐Ÿฐ: ๐—›๐—ผ๐—บ๐—ฒ ๐—ฐ๐—ผ๐˜‚๐—ป๐˜๐—ฟ๐˜† ๐—ฏ๐—ถ๐—ฎ๐˜€ ๐Ÿฏ A long VTI - short emerging market portfolio generated 50 pts of outperformance relative to long-only VTI. Global exposure might be great in theory, but very hard to endure in practice! optionstocksmachines.substack.com/p/botw-4-hom... #python #datascience

๐—›๐—™๐—ช๐—ช๐—ง ๐Ÿฑ: ๐—ฅ๐—ฒ๐˜ƒ๐—ฒ๐—ป๐˜‚๐—ฒ ๐—ฏ๐˜‚๐—ถ๐—น๐—ฑ: Concluding code walk-through to build the revenue dataset. Alpha Vantage issues led us to use Simfin. Clean data and an easy to use API. Highlights effort building robust, minimal error investing dataset optionstocksmachines.substack.com/p/hfwwt-5-re... #python #datascience

๐—›๐—™๐—ช ๐Ÿฑ: ๐—Ÿ๐—ฒ๐˜€๐˜€ ๐—น๐—ฎ๐—ด๐˜€ ๐—ฎ๐—ฟ๐—ฒ ๐—บ๐—ผ๐—ฟ๐—ฒ: A four quarter lag model performs worse than both one quarter lag and naรฏve models. The naรฏve model is outperforming more sophisticated algorithms! Moving average models next. Stay tuned! optionstocksmachines.substack.com/p/hfw-5-less... #python #timeseries #datascience

๐—•๐—ข๐—ง๐—ช ๐Ÿฏ: ๐—ฅ๐—ผ๐—น๐—น๐—ถ๐—ป๐—ด ๐—ฎ ๐—ฝ๐—ฎ๐—ถ๐—ฟ: Pairs trading oil services and oil ETFs, OIH and USO, adding a rolling regression to calculate the spread ratio improves out-of-sample performance. Further refinements coming. Stay tuned! optionstocksmachines.substack.com/p/botw-3-rol... #python #datascience #pairstrading

๐—›๐—™๐—ช๐—ช๐—ง ๐Ÿฐ: ๐—™๐—ถ๐—ป๐—ฑ๐—ถ๐—ป๐—ด ๐—™๐˜‚๐—ป๐—ฑ๐—ฎ๐—บ๐—ฒ๐—ป๐˜๐—ฎ๐—น๐˜€: Tickers assigned, time to build the revenue dataset using the Alpha Vantage API. Quick EDA shows too many problems. Scrubbing your dataset is good for your wealth! optionstocksmachines.substack.com/p/hfwwt-4-fi... #python #datascience

๐—›๐—™๐—ช ๐Ÿฏ: ๐—ก๐—ฎรฏ๐˜ƒ๐—ฒ ๐—ถ๐˜€, ๐—ฎ๐˜€ ๐—ป๐—ฎรฏ๐˜ƒ๐—ฒ ๐—ฑ๐—ผ๐—ฒ๐˜€ Minimal differences between linear regression and naรฏve models. Naรฏve model has higher error rates for a few individual companies regardless of sector. Key takeaway: which models capture company idiosyncrasies better? optionstocksmachines.substack.com/p/hfw-3-naiv...

๐—•๐—ข๐—ง๐—ช ๐Ÿฎ: ๐—›๐—ผ๐—บ๐—ฒ ๐—ฐ๐—ผ๐˜‚๐—ป๐˜๐—ฟ๐˜† ๐—ฏ๐—ถ๐—ฎ๐˜€ ๐Ÿฎ -- ๐—œ๐—ป๐—ฑ๐—ถ๐—ฐ๐—ฒ๐˜€ ๐—บ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ Following up on prior post, we substitute EFA and EEM for VXUS. Long emerging markets made sense for a while. Long VTI and EEM against 25% short EFA generated the highest cumulative return since 2003.ย  optionstocksmachines.substack.com/p/botw-2-hom...

๐—›๐—™๐—ช๐—ช๐—ง ๐Ÿฏ: ๐—•๐—ฒ๐—ถ๐—ป๐—ด ๐—ป๐—ถ๐—ฐ๐—ฒ ๐˜๐—ผ ๐—ผ๐˜‚๐—ฟ ๐—ณ๐˜‚๐˜๐˜‚๐—ฟ๐—ฒ ๐˜€๐—ฒ๐—น๐˜ƒ๐—ฒ๐˜€: Still looking for our lost tickers, we try a third option: Yahoo! A manual search might have been faster. But we want to find a programmatic solution to save time for our future selves! optionstocksmachines.substack.com/p/hfwwt-3-wa... #python #datascience

๐—›๐—™๐—ช ๐Ÿฎ: ๐—ข๐—Ÿ๐—ฆ ๐—ช๐—ผ๐—ฟ๐—ธ๐—ต๐—ผ๐—ฟ๐˜€๐—ฒ: Forecasting series starts in earnest using linear regression, the ubiquitous workhorse. Deploying a single period lag with recursive forecasting, results are not too different from the naรฏve baseline. optionstocksmachines.substack.com/p/hfw-2-ols-... #python #timeseries

๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜ ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ ๐—ช๐—ฒ๐—ฒ๐—ธ ๐Ÿญ: New (semi) regular series of quick analyses and backtests. First one on home country bias. Nice theory, not so great in practice. Long VTI/short VXUS ETFs outperforms 11 of the last 14 years! optionstocksmachines.substack.com/p/botw-1-hom... #python #datascience #backtesting

Cleaning company financial data is hard. First, know accounting to make proper adjustments. Then, assign cleaned data to the correct timestamp to be usable for backtests. Time involved: days for one company. How many new ๐’‡๐’Š๐’๐’‚๐’๐’„๐’† ๐‘จ๐‘ฐ companies have spent the time or have the staff to do this?

๐—›๐—™๐—ช๐—ช๐—ง ๐Ÿฎ: ๐—œ๐—ป ๐˜€๐—ฒ๐—ฎ๐—ฟ๐—ฐ๐—ต ๐—ผ๐—ณ ๐—น๐—ผ๐˜€๐˜ ๐˜๐—ถ๐—ฐ๐—ธ๐—ฒ๐—ฟ๐˜€ We test the Tiingo API to find the tickers missed by Alpha Vantage, continuing our walk-thru of how to build the dataset used in our revenue forecasting series. Each Python code step explained. optionstocksmachines.substack.com/p/hfwwt-2-wa... #python #datascience

๐—›๐—™๐—ช ๐Ÿญ: ๐—ก๐—ฎรฏ๐˜ƒ๐—ฒ๐˜รฉ: Time series algorithms for fundamental analysis begins in earnest by establishing a naรฏve benchmark and showing baseline error rates by S&P 500 sector. Next post will detail how we built the dataset with fully reproducible code! optionstocksmachines.substack.com/p/hfw-1-naiv...

[๐—›๐—™๐—ช๐—ช๐—ง ๐Ÿญ]: ๐—›๐—ฒ๐—น๐—น๐—ผ ๐—™๐—ผ๐—ฟ๐—ฒ๐—ฐ๐—ฎ๐˜€๐˜๐—ถ๐—ป๐—ด ๐—ช๐—ผ๐—ฟ๐—น๐—ฑ ๐—ช๐—ฎ๐—น๐—ธ ๐—ง๐—ต๐—ฟ๐—ผ๐˜‚๐—ด๐—ต ๐Ÿญ We walk through how we built the dataset we will use for our revenue forecasting series, explaining the Python code for each step using the Alpha Vantage API. optionstocksmachines.substack.com/p/hfwwt-1-he...

New series on time series forecasting for fundamental analysis. Time to size up how well popular time series packages perform against naรฏve fundamental analysis. optionstocksmachines.substack.com/p/hello-fore...

Iโ€™m thrilled to share some exciting news! Iโ€™ve decided to move Option, Stocks, Machines to Substack. I hope this platform will become an even better hub to attract readers interested in using data science to improve, scale, and automate the investment process! optionstocksmachines.substack.com

๐——๐—ฎ๐˜† ๐Ÿฏ๐Ÿฌ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Lessons learned. Targeted tweaks benefit simple strategies. Need a systematic approach for using multiple performance metrics. Place simulations logically in overall analysis. #30daysofbacktesting #python #datascience www.optionstocksmachines.com/post/2024-12...

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿต ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Out-of-sample test on four strategies vs. buy-and-hold, the 200-day SMA, and the 60-40 SPY-IEF. Adjusted strategy with error correction most promising if not the highest result #30daysofbacktesting #python #datascience www.optionstocksmachines.com/post/2024-12...

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿด ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Additional enhancements boost outperformance by 16% pts vs. the original strategy. But simulations show adjusted strategy still lags behind buy-and-hold. #30daysofbacktesting #python #datascience www.optionstocksmachines.com/post/2024-12...

Every year I take a few days around New Year's to review articles, blog posts, and pdfs I've saved in my "Read for later" folder. Seems like a lot more this year. Most seem to be going into a "Really read for later" folder. I should probably resolve to do something about that.

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿณ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Error correction method refined. Attractive results. Cumulative return outpaces buy-and-hold by 36% pts and the original strategy by 26% pts. The Sharpe ratio jumps to 0.6 www.optionstocksmachines.com/post/2024-12... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿฒ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Five days left! Compare adjusted strategy to original 12-by-12. Statistical tests confirm significant difference in returns for key scenarios. www.optionstocksmachines.com/post/2024-12... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿฑ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Confusion matrices! Adjusted strategy: fewer false positives but more false negatives. Delivers higher average returns on true positives. Misses fewer upticks on false negatives www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿฐ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! More on error correction method. Success due to correcting directional biases in mean-reverting models? Maybe. Lags predicting positive, but beats forecasting negatives returns. www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿฏ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Logic or luck for enhanced strategy? Bit of both. Adjustment improves performance by capturing forward return direction better. www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿฎ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! 12-by-12 model improves using error correction term, inspired by #ML and the Prognostikon blog. www.optionstocksmachines.com/post/2024-11... Check out Prognostikon: prognostikon.cce.uoa.gr/category/pos... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿญ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! 12-by-12 strategy thus far. Limitations but adding an error correction term to improve trading signals shows promise. www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿฎ๐Ÿฌ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! 3-block circular sampling tests 12-by-12 strategy vs. buy-and-hold. Average underperformance of 11% points. 7-block sampling improves but not enough to make viable as is www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿต ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Circular block sampling to gauge outperformance likelihood. Results: 200-day SMA underperforms buy-and-hold by 13% points on average. Outperforms only 25% of the time. www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿด ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Exploring simulation methods. Assessing sampling from distributions or historical data. Favor historical block sampling. Use autocorrelation plots to find optimal block size. www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿณ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! 12-by-12 strategy vs. 200-day SMA. 12-by-12 faces deeper drawdowns after the Tech Bubble, but similar over entire period. Evidence of market regime-driven performance. www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿฒ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Improved 12-by-12 strategy avoids major market declines and outperforms the 60-40 by 22% points. It also outperforms the 200-day, but that mainly stems from 2015-2018. www.optionstocksmachines.com/post/2024-11... #30daysofbacktestingย #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿฑ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—™๐—ผ๐—ฟ๐—ฒ๐—ฐ๐—ฎ๐˜€๐˜๐—ถ๐—ป๐—ด! Correcting for snooping. Exploring up-to-date weekly data to enhance trading signals. Long-only outperforms buy-and-hold by 10% points. The Sharpe Ratio is 20% points higher. www.optionstocksmachines.com/post/2024-11... #30daysofbacktestingย #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿฐ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—™๐—ผ๐—ฟ๐—ฒ๐—ฐ๐—ฎ๐˜€๐˜๐—ถ๐—ป๐—ด! Day 13 looked so great because we intentionally snooped. Correcting for that, performance dropped. We explore balancing data availability and up-to-date models in our next post. www.optionstocksmachines.com/post/2024-11... #30daysofbacktestingย #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿฏ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Unlucky number proves the opposite. First backtest looks great. Too great. Be very skeptical. We reveal why in the next post. Spoiler: introducing a common backtesting error www.optionstocksmachines.com/post/2024-11... #30daysofbacktestingย #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿฎ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—™๐—ผ๐—ฟ๐—ฒ๐—ฐ๐—ฎ๐˜€๐˜๐—ถ๐—ป๐—ด! 320 training/forecasting combinations for the momentum models reveals that a 5 week training period on 12-week forecasts yields attractive results. www.optionstocksmachines.com/post/2024-11... #30daysofbacktestingย #python #datascience

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿญ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—™๐—ผ๐—ฟ๐—ฒ๐—ฐ๐—ฎ๐˜€๐˜๐—ถ๐—ป๐—ด! Significant autocorrelation in 12-by-12 model's residuals at lags 1-7. Iterating train/forecast splits finds combinations with the lowest forecast error trough in the 5-by-1 to 13-by-4 range. www.optionstocksmachines.com/post/2024-11... #30daysofbacktesting

๐——๐—ฎ๐˜† ๐Ÿญ๐Ÿฌ ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—™๐—ผ๐—ฟ๐—ฒ๐—ฐ๐—ฎ๐˜€๐˜๐—ถ๐—ป๐—ด! We examine the 12-by-12 model's residuals. The results are encouraging. The model appears stable within typical return ranges, but residuals may be autocorrelated #30daysofbacktestingย #python #datascience www.optionstocksmachines.com/post/2024-11...

๐——๐—ฎ๐˜† ๐Ÿต ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Developing a market thesis instead of p-hacking. Applying walk-forward techniques to build successive forecasts. Analyzing residuals. #30daysofbacktestingย #python #datascience www.optionstocksmachines.com/post/2024-10...

๐——๐—ฎ๐˜† ๐Ÿด ๐—ผ๐—ณ ๐Ÿฏ๐Ÿฌ ๐——๐—ฎ๐˜†๐˜€ ๐—ผ๐—ณ ๐—•๐—ฎ๐—ฐ๐—ธ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด! Baseline effects on the 16 different lookback and look forward momentum models see stability across the same look forward periods. Not surprising in an up trending market. #30daysofbacktesting #python #datascience www.optionstocksmachines.com/post/2024-10...