[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-83481":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":17,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":45,"readmeContent":46,"aiSummary":10,"trendingCount":16,"starSnapshotCount":16,"syncStatus":47,"lastSyncTime":48,"discoverSource":49},83481,"quant-trading","je-suis-tm\u002Fquant-trading","je-suis-tm","Python quantitative trading strategies including VIX Calculator, Pattern Recognition, Commodity Trading Advisor, Monte Carlo, Options Straddle, Shooting Star, London Breakout, Heikin-Ashi, Pair Trading, RSI, Bollinger Bands, Parabolic SAR, Dual Thrust, Awesome, MACD","https:\u002F\u002Fje-suis-tm.github.io\u002Fquant-trading",null,"Python",10055,1811,284,3,0,31,93,108.37,"Apache License 2.0",false,"master",true,[25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],"algorithmic-trading","bollinger-bands","commodity-trading","macd","momentum-strategy","momentum-trading-strategy","options-strategies","options-trading","pair-trading","quant","quantimental-analysis","quantitative-finance","quantitative-trading","quantitative-trading-strategies","statistical-arbitrage","trading-algorithms","trading-bot","trading-strategies","trading-strategy","trading-systems","2026-06-12 04:01:41","# Quant-trading\n\n&nbsp;\n\n## Intro\n\n&nbsp;\n\n> We’re right 50.75 percent of the time... but we’re 100 percent right 50.75 percent of the time, you can make billions that way. \u003Cbr>\u003Cbr>\n> --- Robert Mercer, co-CEO of Renaissance Technologies\n\n> If you trade a lot, you only need to be right 51 percent of the time, we need a smaller edge on each trade. \u003Cbr>\u003Cbr>\n> --- Elwyn Berlekamp, co-Founder of Combinatorial Game Theory\n\n###### *The quotes above come from a book by Gregory Zuckerman, a book every quant must read, THE MAN WHO SOLVED THE MARKET.*\n\n&nbsp;\n\nMost scripts inside this repository are technical indicator automated trading. These scripts include various types of momentum trading, opening range breakout, reversal of support & resistance and statistical arbitrage strategies. Yet, quantitative trading is not only about technical analysis. It can refer to computational finance to exploit derivative price mismatch, pattern recognition on alternative datasets to generate alphas or low latency order execution in the market microstructure. Hence, there are a few ongoing projects inside this repository. These projects are mostly quantamental analysis on some strange ideas I come up with to beat the market (or so I thought). There is no HFT strategy simply because ultra high frequency data are very expensive to acquire (even consider platforms like Quantopian or Quandl). Additionally, please note that, all scripts are historical data backtesting\u002Fforward testing (basically via Python, not C++, maybe Julia in the near future). The assumption is that all trades are frictionless. No slippage, no surcharge, no illiquidity. Last but not least, all scripts contain a global function named main so that you can embed the scripts directly into you trading system (although too lazy to write docstring).\n\n### Table of Contents\n\n&nbsp;\n\n#### Options Strategy\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#12-options-straddle>Options Straddle\u003C\u002Fa>\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#15-vix-calculator>VIX Calculator\u003C\u002Fa>\n\n&nbsp;\n\n#### Quantamental Analysis\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#11-monte-carlo-project>Monte Carlo Project\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#6-oil-money-project>Oil Money Project\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#2-pair-trading>Pair Trading\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#13-portfolio-optimization-project>Portfolio Optimization Project\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#14-smart-farmers-project>Smart Farmers Project\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#16-wisdom-of-crowds-project>Wisdom of Crowd Project\u003C\u002Fa>\n\n&nbsp;\n\n#### Technical Indicators\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#5-awesome-oscillator>Awesome Oscillator\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#9-bollinger-bands-pattern-recognition>Bollinger Bands Pattern Recognition\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#7-dual-thrust>Dual Thrust\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#3-heikin-ashi-candlestick>Heikin-Ashi Candlestick\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#4-london-breakout>London Breakout\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#1-macd-oscillator>MACD Oscillator\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#8-parabolic-sar>Parabolic SAR\u003C\u002Fa> \n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#10-relative-strength-index-pattern-recognition>Relative Strength Index Pattern Recognition\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading#17-shooting-star>Shooting Star\u003C\u002Fa>\n\n&nbsp;\n\n### Data Source\n\n* Bloomberg\u002FEikon\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fweb-scraping\u002Fblob\u002Fmaster\u002FCME3.py>CME\u003C\u002Fa>\u002F\u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fweb-scraping\u002Fblob\u002Fmaster\u002FLME.py>LME\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fwww.histdata.com\u002F>Histdata\u003C\u002Fa>\u002F\u003Ca href=https:\u002F\u002Ffxhistoricaldata.com>FX Historical Data\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fweb-scraping\u002Fblob\u002Fmaster\u002FMacrotrends.py>Macrotrends\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fstooq.com>Stooq\u003C\u002Fa>\u002F\u003Ca href=https:\u002F\u002Fwww.quandl.com>Quandl\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fweb-scraping\u002Fblob\u002Fmaster\u002FWallStreetBets.py>Reddit WallStreetBets\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fweb-scraping>Web Scraping\u003C\u002Fa>\n\n* \u003Ca href=https:\u002F\u002Ffinance.yahoo.com>Yahoo Finance\u003C\u002Fa>\u002F\u003Ca href=https:\u002F\u002Fpypi.org\u002Fproject\u002Ffix-yahoo-finance>fix_yahoo_finance package\u003C\u002Fa>\u002F\u003Ca href=https:\u002F\u002Fpypi.org\u002Fproject\u002Fyfinance>yfinance package\u003C\u002Fa> \n\n\u003Cbr>\n\n## Strategies:\n\n### 1. MACD oscillator\n\nMACD oscillator is trading strategy 101. MACD refers to Moving Average Convergence\u002FDivergence. It is a momentum trading strategy which holds the belief that upward\u002Fdownward momentum has more impact on short term moving average than long term moving average. It only takes 5 minutes for any bloke with no background in finance to trade with MACD signals. Regarding the simplicity of MACD oscillator, it is the most common strategy among the non-professionals in the market. In behavioral economics, the more people believe in the strategy, the more effective the strategy becomes (not always true, e.g. 2008). Therefore, we should not underestimate the power of MACD oscillator.\n\nFor the strategy itself, we compute long term moving average and short term moving average on the close price of a given stock. To generate the trading signal, we implement a comparison between the moving averages of different time horizons. When short term moving average is above long term moving average, we long the given stock accordingly. Vice versa.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FMACD%20Oscillator%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fmacd%20positions.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fmacd%20oscillator.png)\n\n### 2. Pair trading\n\nPair trading is the basic form of statistics arbitrage. It relies on the assumption that two cointegrated stocks would not drift too far away from each other. First step, we select two stocks and run \u003Ca href=https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FError_correction_model#Engle_and_Granger_2-step_approach>Engle-Granger two step analysis\u003C\u002Fa>. Once the criteria of cointegration is met, we standardize the residual and set one sigma away (two tailed) as the threshold. After that, we compute the current standardized residual of the selected stocks accordingly. When the standardized residual exceeds the threshold, it generates the trading signal. The simple rule is we always long the cheap stock and short the expensive stock. \n\nThe core idea of pair trading is \u003Ca href=https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FCointegration>cointegration\u003C\u002Fa>. Metaphorically speaking, cointegration is like a couple in a clingy relationship where two parties are crazy-glued together. Yet, most relationships break sooner or later, and only the very few can make it to the marriage (from a statistics perspective, not being pessimistic). Hence, it is important to frequently check on the status quo of cointegration before any pair trading order execution (the same applies to relationships).\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FPair%20trading%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fpair%20trading%20positions.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fpair%20trading%20asset.png)\n\n### 3. Heikin-Ashi candlestick\n\nHeikin-Ashi, the exotic name actually referring to 'Average Bar' in Japanese, is an alternative style of candlestick chart. The sophisticated rules of Heiki-Ashi are designed to filter out the noise for momentum trading. Hence, Heikin-Ashi shows more consecutive bars in contrast to the standard candlestick, which makes price momentum and reverse points more distinguishable in figures. Arguably it should outperform the standard candlestick in sideways and choppy markets. \n\nFor the strategy itself, initially we make a few transformations on four vital benchmarks - Open, Close, High, Low. The next step is to apply unique Heikin-Ashi rules on Heikin-Ashi Open, Close, High, Low to generate trading signals. The downside of Heikin-Ashi (or any momentum trading strategies) is the slow response. Thus, we should set up the stop loss position accordingly so that we don't get caught up in any flash crash.\n\nThe rules of Heikin-Ashi can be found in \u003Ca href=https:\u002F\u002Fquantiacs.com\u002FBlog\u002FIntro-to-Algorithmic-Trading-with-Heikin-Ashi.aspx>Quantiacs\u003C\u002Fa>.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FHeikin-Ashi%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fheikin-ashi%20positions.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fheikin-ashi%20asset%20value.png)\n\n### 4. London Breakout\n\nTo one of my favourite cities in the world! Proud to be a Londoner!\n\nLondon Breakout is an intra daily opening range breakout strategy. Basically, it is a fascinating information arbitrage across different markets in different time zones. FX market runs 24\u002F7 globally. For instance, you cannot long the stock of Ford in ASX simply because Ford is listed in NYSE. As FX market is decentralised, you can long any currency pair in any market as long as the market is open. That leaves a door to take a peek at the activity in a closed foreign FX market before the opening of domestic FX market.\n\nBack to London Breakout, London and Tokyo are two of the largest FX markets in the world. Tokyo FX trading hour is GMT 0:00 a.m. - GMT 8:59am. London FX trading hour (no summer daylight saving) begins at GMT 8:00 a.m. Even though there is an hour of overlap, the crucial timeframe of London Breakout is GMT 7:00 a.m. - GMT 7:59 a.m. a.k.a. the last trading hour before the opening of London market. The price movement of the crucial timeframe incorporates the information of all the overnight activities of financial market (from the perspective of the current time zone).\n\nFor the strategy itself, we establish upper and lower thresholds prior to the high and low of the crucial timeframe. Once London FX market opens, we spend the first couple of minutes to check if the price would breach the preset boundaries. If it is above threshold, we long the currency pair accordingly. Vice versa. Nevertheless, we should set up a limit to prevent us from trading in the case of abnormal opening volatility. Normally, we clear our positions based on our target stop loss or stop profit respectively. By the end of the trading hour (still from the perspective of the current time zone), if there are any open positions, we clear them out.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FLondon%20Breakout%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Flondon%20breakout%20positions.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Flondon%20breakout%20thresholds.png)\n\n### 5. Awesome oscillator\n\nAwesome oscillator is an upgraded version of MACD oscillator. It is one of those momentum strategies focusing on the game of moving average. Instead of taking simple moving average on close price, awesome moving average is derived from the mean of high and low price. Similar to MACD oscillator, it takes both short term and long term moving averages to construct the oscillator.\n\nThere are various strategies for awesome oscillator to generate signals, such as traditional moving average divergence, twin peaks and saucer. Twin peaks is just one of the many names of bottom W pattern. The pattern recognition will be covered in another chapter so the main focus of this chapter is saucer. Saucer is slightly more complex to implement than the traditional divergence. In return, saucer has the power to beat the slow response of the traditional divergence. Generally speaking, a faster response may sound awesome, but it does not guarantee a less risky outcome or a more profitable outcome. Hence, we will take MACD oscillator as a control group, to test if awesome oscillator can actually outperform MACD oscillator.\n\nThe rules of awesome oscillator could be found in \u003Ca href=https:\u002F\u002Fwww.tradingview.com\u002Fwiki\u002FAwesome_Oscillator_(AO)>TradingView\u003C\u002Fa>.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FAwesome%20Oscillator%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fawesome%20positions.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fawesome%20oscillator.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fawesome%20ma.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fawesome%20asset.png)\n\n### 6. Oil Money project\n\nThis project is inspired by an \u003Ca href=https:\u002F\u002Fwww.bloomberg.com\u002Fnews\u002Farticles\u002F2018-05-20\u002Fcrude-oil-s-surge-is-putting-the-petro-back-in-petrocurrencies>article\u003C\u002Fa> on oil-backed foreign exchange. Amid the bullish outlook for crude oil, the currency exchange of oil producing countries would also bounce back. Does this statement really hold? \n\nAccording to the article by Bloomberg (or many other similar research), researchers examine the correlation between petrocurrency and oil price, instead of the causality. But correlation does not equal to causality. Correlation could be a coincidence of a math game. We simply cannot draw the conclusion that oil price moves the currency. Some researchers even use bootstrapping which greatly destroys the autocorrelation of a time series. Thus, it is vital to apply academic analysis and computer simulation on some petrocurrencies to test the causality of oil.\n\n*For more details, please refer to the \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FOil%20Money%20project\u002FREADME.md>read me page\u003C\u002Fa> of a separate directory or \u003Ca href=https:\u002F\u002Fje-suis-tm.github.io\u002Fquant-trading\u002Foil-money>quant trading section\u003C\u002Fa> on my personal blog.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FOil%20Money%20project\u002Fpreview\u002Foil%20production%20bubble%20map.png)\n\n### 7. Dual Thrust\n\nIf you search dual thrust on google, you will end up with results of rocket engine. Don't panic yet, you can rest assured that dual thrust strategy is nowhere near rocket science. It is just an opening range breakout strategy developed by the founder of Universal Technical Systems. The mathematics involved in this strategy is merely primary school level.\n\nInitially we establish upper and lower thresholds based on previous days' open, close, high and low. When the market opens and the price exceeds certain thresholds, we would take long\u002Fshort positions prior to upper\u002Flower thresholds. The strategy is quite useful in intra daily trading. However, there is no stop loss\u002Fprofit position in this strategy. We reverse our positions when the price goes from one threshold to the other. We need to clear all positions by the end of the day.\n\nRules of dual thrust can be found in \u003Ca href=https:\u002F\u002Fwww.quantconnect.com\u002Ftutorials\u002Fdual-thrust-trading-algorithm>QuantConnect\u003C\u002Fa>.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FDual%20Thrust%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fdual%20thrust%20positions.png)\n\n### 8. Parabolic SAR\n\nParabolic SAR is an indicator to identify stop and reverse of a trend. Usually, Parabolic SAR is presented as dotted line either above or below the price in charts. When the price is an uptrend, SAR curve would sit below the price. When the price is downtrend, SAR curve would rise above the price. Parabolic SAR is always considered as a symbol of resistance to the price momentum. When SAR curve and the price curve cross over, it is when trade orders are supposed to be executed. \n\nThe building of this strategy seems very simple, but the construction of the indicator is extremely painful due to the involvement of recursive calculation. Illustration on how to compute Parabolic SAR can be found in \u003Ca href=https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FParabolic_SAR>Wikipedia\u003C\u002Fa> but it is not very well explained. To get a clear idea of the calculation, my personal recommendation is to take a look at the \u003Ca href=https:\u002F\u002Fwww.box.com\u002Fs\u002Fgbtrjuoktgyag56j6lv0>spreadsheet\u003C\u002Fa> made by joeu2004.\n\nIt is worth mentioning that SAR and RSI (which will be featured in a later chapter) shares the same founder, Welles Wilder. The guy is a real legend who used to work as mechanical engineer and real estate developer and later became a technical analyst. His book on technical trading system is a must-read for anyone that wants to elevate quant trading system to the next level.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FParabolic%20SAR%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fparabolic%20sar%20positions.png)\n\n### 9. Bollinger Bands Pattern Recognition\n\nBollinger Bands is a very simple but powerful indicator. There are three bands of this indicator. The mid band is the moving average on the price series (usually takes 20 lags). The upper and lower bands are two moving standard deviations away from the mid band. Bollinger Bands can be used to test for various types of strategies. \n\nFor volatility trading, contraction and expansion of the band width are crucial elements. Any distinct momentum clustering (it can take form of either upward or downward) would result in a Bollinger Bands expansion. And the oscillation in a horizontal channel would result in a Bollinger Bands contraction. \n\nFor momentum trading, the phenomenon of 'walking the band' indicates the resistance and support level of the underlying asset. In a strong trend, the price constantly attempts to touch or break through the upper\u002Flower band along with Bollinger Bands moving towards the same direction.\n\nFor pattern recognition, Bollinger Bands has the capability of testing bottom W, top M, head-shoulder patterns, etc. With upper and lower bands served as an interval, it is easier to identify the hidden pattern in the historical data.\n\nMore details of Bollinger Bands can be found in \u003Ca href=https:\u002F\u002Fwww.tradingview.com\u002Fwiki\u002FBollinger_Bands_(BB)>TradingView\u003C\u002Fa>.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FBollinger%20Bands%20Pattern%20Recognition%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fbollinger%20bands%20positions.png)\n\n### 10. Relative Strength Index Pattern Recognition\n\nRSI (Relative Strength Index) is also a popular indicator. It reflects the current strength\u002Fweakness of the stock price momentum. The calculation is pretty straight forward. We use 14 days of smoothed moving average (or other moving average methods) to separately calculate the intra daily uptrend and downtrend. We denote uptrend moving average divided by downtrend moving average as the relative strength. We normalize the relative strength by 100 which becomes an index called RSI. It is commonly believed that RSI above 70 is overbought and RSI below 30 is oversold. This is the simplest way to trade on RSI (as shown in the pictures below). Nonetheless, there could be divergence between RSI momentum and price momentum which will not be covered in the script. The effectiveness of any divergence strategy on RSI is rather debatable.\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Frsi%20positions.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Frsi%20oscillator.png)\n\nIf you are looking for something slightly more complex, well, we can apply pattern recognition technique to RSI as well. Unlike strategy No.9 Bollinger Bands, we can directly look at the patterns of RSI itself instead of the price. Since we have tested double bottom pattern in Bollinger Bands, we would test head-shoulder pattern on RSI this time.\n\nFor details of head-shoulder pattern, please refer to \u003Ca href=https:\u002F\u002Fwww.investopedia.com\u002Fterms\u002Fh\u002Fhead-shoulders.asp>Investopedia\u003C\u002Fa>.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FRSI%20Pattern%20Recognition%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Frsi%20pattern%20positions.png)\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Frsi%20pattern%20oscillator.png)\n\n### 11. Monte Carlo project\n\nMonte Carlo, my first thought on these two words is the grand casino, where you meet Famke Janssen in tuxedo and introduce yourself, 'Bond, James Bond'. Indeed, the simulation is named after the infamous casino. It actually refers to the computer simulation of massive amount of random events. This unconventional mathematical method is extremely powerful in the study of stochastic process. \n\nHere comes the argument on Linkedin that caught my eyes the other day. \"Stock price can be seemed as a Wiener Process. Hence, we can use Monte Carlo simulation to predict the stock price.\" said a data science blog. Well, in order to be a Wiener Process, we have to assume the stock price is continuous in time. In reality, the market closes. The overnight volatility exists. But that is not the biggest issue here. The biggest issue is, can we really use Monte Carlo simulation to predict the stock price, even a range or its direction?\n\n*For more details, please refer to the \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FMonte%20Carlo%20project\u002FREADME.md>read me\u003C\u002Fa> page of a separate directory or \u003Ca href=https:\u002F\u002Fje-suis-tm.github.io\u002Fquant-trading\u002Fmonte-carlo>quant trading\u003C\u002Fa> section on my personal blog.*\n\n![alt text](https:\u002F\u002Fraw.githubusercontent.com\u002Fje-suis-tm\u002Fquant-trading\u002Fmaster\u002FMonte%20Carlo%20project\u002Fpreview\u002Fge%20simulation2.png)\n\n### 12. Options Straddle\n\nHere marks the debut of options strategy in this repository. Straddle refers to the shape of compasses in the payoff diagram of the strategy. A long straddle involves buying a call option and a put option at the same strike price, the same expiration date and preferably the same price. In reality, the same price is not always feasible (call options price higher implies higher upside risk, vice versa). It is recommended to trade when the price disparity between call and put options is converging.\n\nLong straddle is commonly seen in event driven strategy, e.g. political referendum, company earning release. It profits from the uncertainty of both-side risk. For upside risk, the potential profit is unlimited. The potential loss does not come from the downside risk (there is limited gain from downside risk). Instead, it comes from the stagnant price due to insufficient volatility. In this case, short straddle is more suitable for sideways choppy market.\n\nThe crucial element of options straddle is the selection of the strike price. As the price of options contains the market consensus, the only way to maximize the profit is to find the optimal strike price to shrink the loss bandwidth. This is where the economists kick in and offer base case outlook plus best\u002Fworst scenarios. In contrast to the common misunderstanding of quantitative trading, Option Greeks are no silver bullet. Quantitative combined with fundamental in one, so-called quantamental, makes the portfolio impeccable.\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FOptions%20Straddle%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Foptions%20straddle%20payoff%20diagram.png)\n\n### 13. Portfolio Optimization project\n\nModern portfolio theory was introduced in 1952 by Nobel laureate Harry Markowitz. It is part of investment class 101. But I watched a video by \u003Ca href=https:\u002F\u002Fwww.wolfram.com\u002Ftraining\u002Fvideos\u002FFIN015>Wolfram\u003C\u002Fa> recently. It challenged the traditional approach and introduced graph theory to asset diversification. There are plenty of quant shops deploying fancy mathematic tools to solve the market. The real question for us is, as fancy as it sounds, does graph theory work on portfolio optimization?\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fgraph-theory\u002Fblob\u002Fmaster\u002FPortfolio%20Optimization%20project\u002Fpreview\u002Foutta%20sample%20mean%20variance.png)\n\n*This project is documented in the repository of \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fgraph-theory>Graph Theory\u003C\u002Fa>. For more details, please refer to the \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fgraph-theory\u002Fblob\u002Fmaster\u002FPortfolio%20Optimization%20project\u002FREADME.md>read me\u003C\u002Fa> page of a separate directory or \u003Ca href=https:\u002F\u002Fje-suis-tm.github.io\u002Fgraph-theory\u002Fportfolio-optimization>graph theory\u003C\u002Fa> section on my personal blog.*\n\n### 14. Smart Farmers project\n\nI know a lot of you have complained that this repository isn’t quantitative enough. You are yelling for the ultimate weapon of math destruction such as Poisson process or Jensen’s inequality. Well, the objective of quantitative trading is churning out more :euro: rather than deploying an elegant closed form equation. If you crave for intellectual challenge in mathematics, you are always welcome to check out my \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fgraph-theory>Graph Theory\u003C\u002Fa> repository. Nevertheless, I believe the birth of this project will meet your picky demand. Buon appetito :yum:\n\n:tangerine: :pineapple: :melon: :corn: and :sweet_potato: are something we have been taking for granted. Up until COVID-19, we finally come to senses that farmers are one of our low-paid essential workers. This project is dedicated to the optimal allocation of agricultural resources. By trading agricultural market, we are able to eliminate the inefficiency in the crop market. Ideally no food will be wasted and farmers will be fairly compensated. \n\nThe project per se intends to leverage convex optimization to approximate farmers’ plantation planning for different crops. Assuming farmers are Homo Economicus, their end game is to maximize the profit regarding the price impact from supply and demand. Their decision is constrained by arable land area and biological features of crops. We develop this smart model accordingly to acquire a head start in trading :rice: :coffee: and :chocolate_bar:\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FSmart%20Farmers%20project\u002Fpreview\u002Foil%20palm%20vs%20palm%20oil.png)\n\n*For more details, please refer to the \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Ftree\u002Fmaster\u002FSmart%20Farmers%20project\u002FREADME.md>read me page\u003C\u002Fa> of a separate directory or \u003Ca href=https:\u002F\u002Fje-suis-tm.github.io\u002Fquant-trading\u002Fsmart-farmers>quant trading section\u003C\u002Fa> on my personal blog.*\n\n### 15. VIX Calculator\n\nVIX is the fear gauge of S&P 500 index. By using \u003Ca href=https:\u002F\u002Fwww.mathopenref.com\u002Fcalcriemann.html>Riemann sum\u003C\u002Fa> and \u003Ca href=https:\u002F\u002Fwww.emathhelp.net\u002Fnotes\u002Fcalculus-1\u002Ftaylor-formula>Taylor series expansion\u003C\u002Fa>, we are able to convert a continuous fair price variance swap to a discrete options volatility index, which is called VIX. VIX is determined by two components, 3-week-ahead weekly S&P 500 options and one-month-ahead monthly S&P 500 options. It is de facto market anticipated volatility of S&P 500 index in 30 days. So far it has been applied to some stock exchange indices and some forex pairs. Since VIX is such a great risk management tool, why don’t we apply it to any asset with options contract? The objective of this script is to create a VIX calculator for any commodity options within any given length of forecast time horizon.\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fvix%20calculator.PNG)\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FVIX%20Calculator.py>here\u003C\u002Fa> to be redirected to the script.*\n\n### 16. Wisdom of Crowds Project\n\nEvery now and then, we read some bulge brackets hit the headline, “XXX will reach 99999€ in 20YY”. Some forecasts hit the bull’s eye but most projections are as accurate as astrology. Price prediction can be easily influenced by the cognitive bias. In the financial market, there is merit to the idea that \u003Ca href=https:\u002F\u002Fwww.investopedia.com\u002Fterms\u002Fc\u002Fconsensusestimate.asp>consensus estimate\u003C\u002Fa> is the best oracle. By harnessing the power of ensemble learning, we are about to leverage \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fmachine-learning\u002Fblob\u002Fmaster\u002FWisdom%20of%20Crowds%20project\u002Fdawid%20skene.ipynb>Dawid-Skene model\u003C\u002Fa> and \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fmachine-learning\u002Fblob\u002Fmaster\u002FWisdom%20of%20Crowds%20project\u002Fplatt%20burges.ipynb>Platt-Burges model\u003C\u002Fa> to eliminate the idiosyncratic noise associate with each individual judgement. The end game is to reveal the underlying intrinsic value generated by the collective knowledge of research analysts from different investment banks. Is wisdom of crowds a crystal ball for trading? \n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fmachine-learning\u002Fblob\u002Fmaster\u002FWisdom%20of%20Crowds%20project\u002Fpreview\u002Fy1%20forecast%20bias.png)\n\n*This project is documented in the repository of \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fmachine-learning>Machine Learning\u003C\u002Fa>. For more details, please refer to the \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fmachine-learning\u002Fblob\u002Fmaster\u002FWisdom%20of%20Crowds%20project\u002FREADME.md>read me\u003C\u002Fa> page of a separate directory or \u003Ca href=https:\u002F\u002Fje-suis-tm.github.io\u002Fmachine-learning\u002Fwisdom-of-crowds>machine learning\u003C\u002Fa> section on my personal blog.*\n\n### 17. Shooting Star\n\n> Can we pretend that airplanes in the night sky are like shooting stars? I could really use a wish right now!\u003Cbr>\u003Cbr>\n> --- Hayley Williams, Lead Vocalist of Paramore\n\nShooting star, such a poetic name, is merely a simple candlestick pattern. It has a long upper shadow, little lower shadow and a small real body, which resonates the shape of a shooting star. Similar to a real comet, shooting star is a jinxed signal. It indicates the beginning of a bearish momentum after a price uptrend. However, the definition of a shooting star in mathematics is sophisticated. Not many candlesticks can suffice the rigid criteria of shooting star. In practice, people relax the constraint on shooting star in order to trigger the signal.\n\nA sibling of shooting star is called hammer which is effectively a vertical flipped shooting star with bullish outlook. The close price of a hammer is supposed to be higher than the open price. Another sibling of shooting star is called inverted hammer. Inverted hammer shares the same shape with shooting star, but inverted hammer comes with higher close price than open price and usually is an omen of price hike. Nonetheless, there is no \"inverted shooting star\". As malicious as it sounds, the official name is called hanging man...\n\n*Click \u003Ca href=https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002FShooting%20Star%20backtest.py>here\u003C\u002Fa> to be redirected to the script.*\n\n![alt text](https:\u002F\u002Fgithub.com\u002Fje-suis-tm\u002Fquant-trading\u002Fblob\u002Fmaster\u002Fpreview\u002Fshooting%20star%20positions.png)\n\n\u003Cbr>\n\n#### STAY TUNED\n",2,"2026-06-11 04:11:14","high_star"]