Spaces:
Runtime error
Runtime error
File size: 17,908 Bytes
696af78 560ffaf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# Note - 1
# Only some patterns have bull and bear versions.
# However, to make the process unified and for codability purposes
# all patterns are labeled with "_Bull" and "_Bear" tags.
# Both versions of the single patterns are given same performance rank,
# since they will always return only 1 version.
# Note - 2
# Following TA-Lib patterns are excluded from the analysis since the corresponding ranking not found:
# CounterAttack, Longline, Shortline, Stalledpattern, Kickingbylength
candle_rankings = {
"CDL3LINESTRIKE_Bull": 1,
"CDL3LINESTRIKE_Bear": 2,
"CDL3BLACKCROWS_Bull": 3,
"CDL3BLACKCROWS_Bear": 3,
"CDLEVENINGSTAR_Bull": 4,
"CDLEVENINGSTAR_Bear": 4,
"CDLTASUKIGAP_Bull": 5,
"CDLTASUKIGAP_Bear": 5,
"CDLINVERTEDHAMMER_Bull": 6,
"CDLINVERTEDHAMMER_Bear": 6,
"CDLMATCHINGLOW_Bull": 7,
"CDLMATCHINGLOW_Bear": 7,
"CDLABANDONEDBABY_Bull": 8,
"CDLABANDONEDBABY_Bear": 8,
"CDLBREAKAWAY_Bull": 10,
"CDLBREAKAWAY_Bear": 10,
"CDLMORNINGSTAR_Bull": 12,
"CDLMORNINGSTAR_Bear": 12,
"CDLPIERCING_Bull": 13,
"CDLPIERCING_Bear": 13,
"CDLSTICKSANDWICH_Bull": 14,
"CDLSTICKSANDWICH_Bear": 14,
"CDLTHRUSTING_Bull": 15,
"CDLTHRUSTING_Bear": 15,
"CDLINNECK_Bull": 17,
"CDLINNECK_Bear": 17,
"CDL3INSIDE_Bull": 20,
"CDL3INSIDE_Bear": 56,
"CDLHOMINGPIGEON_Bull": 21,
"CDLHOMINGPIGEON_Bear": 21,
"CDLDARKCLOUDCOVER_Bull": 22,
"CDLDARKCLOUDCOVER_Bear": 22,
"CDLIDENTICAL3CROWS_Bull": 24,
"CDLIDENTICAL3CROWS_Bear": 24,
"CDLMORNINGDOJISTAR_Bull": 25,
"CDLMORNINGDOJISTAR_Bear": 25,
"CDLXSIDEGAP3METHODS_Bull": 27,
"CDLXSIDEGAP3METHODS_Bear": 26,
"CDLTRISTAR_Bull": 28,
"CDLTRISTAR_Bear": 76,
"CDLGAPSIDESIDEWHITE_Bull": 46,
"CDLGAPSIDESIDEWHITE_Bear": 29,
"CDLEVENINGDOJISTAR_Bull": 30,
"CDLEVENINGDOJISTAR_Bear": 30,
"CDL3WHITESOLDIERS_Bull": 32,
"CDL3WHITESOLDIERS_Bear": 32,
"CDLONNECK_Bull": 33,
"CDLONNECK_Bear": 33,
"CDL3OUTSIDE_Bull": 34,
"CDL3OUTSIDE_Bear": 39,
"CDLRICKSHAWMAN_Bull": 35,
"CDLRICKSHAWMAN_Bear": 35,
"CDLSEPARATINGLINES_Bull": 36,
"CDLSEPARATINGLINES_Bear": 40,
"CDLLONGLEGGEDDOJI_Bull": 37,
"CDLLONGLEGGEDDOJI_Bear": 37,
"CDLHARAMI_Bull": 38,
"CDLHARAMI_Bear": 72,
"CDLLADDERBOTTOM_Bull": 41,
"CDLLADDERBOTTOM_Bear": 41,
"CDLCLOSINGMARUBOZU_Bull": 70,
"CDLCLOSINGMARUBOZU_Bear": 43,
"CDLTAKURI_Bull": 47,
"CDLTAKURI_Bear": 47,
"CDLDOJISTAR_Bull": 49,
"CDLDOJISTAR_Bear": 51,
"CDLHARAMICROSS_Bull": 50,
"CDLHARAMICROSS_Bear": 80,
"CDLADVANCEBLOCK_Bull": 54,
"CDLADVANCEBLOCK_Bear": 54,
"CDLSHOOTINGSTAR_Bull": 55,
"CDLSHOOTINGSTAR_Bear": 55,
"CDLMARUBOZU_Bull": 71,
"CDLMARUBOZU_Bear": 57,
"CDLUNIQUE3RIVER_Bull": 60,
"CDLUNIQUE3RIVER_Bear": 60,
"CDL2CROWS_Bull": 61,
"CDL2CROWS_Bear": 61,
"CDLBELTHOLD_Bull": 62,
"CDLBELTHOLD_Bear": 63,
"CDLHAMMER_Bull": 65,
"CDLHAMMER_Bear": 65,
"CDLHIGHWAVE_Bull": 67,
"CDLHIGHWAVE_Bear": 67,
"CDLSPINNINGTOP_Bull": 69,
"CDLSPINNINGTOP_Bear": 73,
"CDLUPSIDEGAP2CROWS_Bull": 74,
"CDLUPSIDEGAP2CROWS_Bear": 74,
"CDLGRAVESTONEDOJI_Bull": 77,
"CDLGRAVESTONEDOJI_Bear": 77,
"CDLHIKKAKEMOD_Bull": 82,
"CDLHIKKAKEMOD_Bear": 81,
"CDLHIKKAKE_Bull": 85,
"CDLHIKKAKE_Bear": 83,
"CDLENGULFING_Bull": 84,
"CDLENGULFING_Bear": 91,
"CDLMATHOLD_Bull": 86,
"CDLMATHOLD_Bear": 86,
"CDLHANGINGMAN_Bull": 87,
"CDLHANGINGMAN_Bear": 87,
"CDLRISEFALL3METHODS_Bull": 94,
"CDLRISEFALL3METHODS_Bear": 89,
"CDLKICKING_Bull": 96,
"CDLKICKING_Bear": 102,
"CDLDRAGONFLYDOJI_Bull": 98,
"CDLDRAGONFLYDOJI_Bear": 98,
"CDLCONCEALBABYSWALL_Bull": 101,
"CDLCONCEALBABYSWALL_Bear": 101,
"CDL3STARSINSOUTH_Bull": 103,
"CDL3STARSINSOUTH_Bear": 103,
"CDLDOJI_Bull": 104,
"CDLDOJI_Bear": 104
}
candlestick_patterns = {
"CDL3BLACKCROWS": "Three Black Crows",
"CDL3INSIDE": "Three Inside Up/Down",
"CDL3LINESTRIKE": "Three-Line Strike",
"CDL3OUTSIDE": "Three Outside Up/Down",
"CDL3STARSINSOUTH": "Three Stars In The South",
"CDL3WHITESOLDIERS": "Three Advancing White Soldiers",
"CDLABANDONEDBABY": "Abandoned Baby",
"CDLADVANCEBLOCK": "Advance Block",
"CDLBELTHOLD": "Belt-hold",
"CDLBREAKAWAY": "Breakaway",
"CDLCLOSINGMARUBOZU": "Closing Marubozu",
"CDLCONCEALBABYSWALL": "Concealing Baby Swallow",
"CDLCOUNTERATTACK": "Counterattack",
"CDLDARKCLOUDCOVER": "Dark Cloud Cover",
"CDLDOJI": "Doji",
"CDLDOJISTAR": "Doji Star",
"CDLDRAGONFLYDOJI": "Dragonfly Doji",
"CDLENGULFING": "Engulfing Pattern",
"CDLEVENINGDOJISTAR": "Evening Doji Star",
"CDLEVENINGSTAR": "Evening Star",
"CDLGAPSIDESIDEWHITE": "Up/Down-gap side-by-side white lines",
"CDLGRAVESTONEDOJI": "Gravestone Doji",
"CDLHAMMER": "Hammer",
"CDLHANGINGMAN": "Hanging Man",
"CDLHARAMI": "Harami Pattern",
"CDLHARAMICROSS": "Harami Cross Pattern",
"CDLHIGHWAVE": "High-Wave Candle",
"CDLHIKKAKE": "Hikkake Pattern",
"CDLHIKKAKEMOD": "Modified Hikkake Pattern",
"CDLHOMINGPIGEON": "Homing Pigeon",
"CDLIDENTICAL3CROWS": "Identical Three Crows",
"CDLINNECK": "In-Neck Pattern",
"CDLINVERTEDHAMMER": "Inverted Hammer",
"CDLKICKING": "Kicking",
"CDLKICKINGBYLENGTH": "Kicking - bull/bear determined by the longer marubozu",
"CDLLADDERBOTTOM": "Ladder Bottom",
"CDLLONGLEGGEDDOJI": "Long Legged Doji",
"CDLLONGLINE": "Long Line Candle",
"CDLMARUBOZU": "Marubozu",
"CDLMATCHINGLOW": "Matching Low",
"CDLMATHOLD": "Mat Hold",
"CDLMORNINGDOJISTAR": "Morning Doji Star",
"CDLMORNINGSTAR": "Morning Star",
"CDLONNECK": "On-Neck Pattern",
"CDLPIERCING": "Piercing Pattern",
"CDLRICKSHAWMAN": "Rickshaw Man",
"CDLRISEFALL3METHODS": "Rising/Falling Three Methods",
"CDLSEPARATINGLINES": "Separating Lines",
"CDLSHOOTINGSTAR": "Shooting Star",
"CDLSHORTLINE": "Short Line Candle",
"CDLSPINNINGTOP": "Spinning Top",
"CDLSTALLEDPATTERN": "Stalled Pattern",
"CDLSTICKSANDWICH": "Stick Sandwich",
"CDLTAKURI": "Takuri (Dragonfly Doji with very long lower shadow)",
"CDLTASUKIGAP": "Tasuki Gap",
"CDLTHRUSTING": "Thrusting Pattern",
"CDLTRISTAR": "Tristar Pattern",
"CDLUNIQUE3RIVER": "Unique 3 River",
"CDLUPSIDEGAP2CROWS": "Upside Gap Two Crows",
"CDLXSIDEGAP3METHODS": "Upside/Downside Gap Three Methods"
}
candlestick_patterns_description = {
"CDL2CROWS": "Two red candlesticks in a row, suggesting a potential trend reversal",
"CDL3BLACKCROWS": "Three consecutive red candlesticks, with each open within the previous candlestick's real body and each close lower, indicating a strong bearish trend",
"CDL3INSIDE": "Three candlesticks where the first is red, the second is green, and the third is red again, with the third red candlestick's high within the second green one's real body, suggesting a potential trend reversal",
"CDL3LINESTRIKE": "Three red or green candlesticks in a row with progressively higher highs or lower lows, indicating a strong trend",
"CDL3OUTSIDE": "Three candlesticks where the first is red, the second is green, and the third is red again, with the third red candlestick's high above the first red one's high and low below the second green one's low, suggesting a trend reversal",
"CDL3STARSINSOUTH": "Three red candlesticks with each having a small real body, where the first two are contained within the prior red candlestick's real body and the third has a lower close, suggesting a potential trend reversal",
"CDL3WHITESOLDIERS": "Three green candlesticks in a row, each with a higher close, indicating a strong bullish trend",
"CDLABANDONEDBABY": "A gap followed by a doji, which is a candle with a small real body, where the doji is above or below the gap, suggesting a trend reversal",
"CDLADVANCEBLOCK": "Three red candlesticks with each having a higher high and progressively higher lows, indicating a potential trend reversal",
"CDLBELTHOLD": "A red or green candlestick with a long real body, followed by a doji with a similar color and a small real body, where the doji is above or below the first candlestick, suggesting indecision in the market",
"CDLBREAKAWAY": "A gap followed by a red or green candlestick with a long real body, where the color of the real body continues the preceding trend, indicating a potential trend continuation",
"CDLCLOSINGMARUBOZU": "A red or green candlestick with no shadow and a long real body, indicating strong buying or selling pressure",
"CDLCONCEALBABYSWALL": "A green candlestick followed by a red or doji candlestick that is fully contained within the real body of the green candle, suggesting a potential trend reversal",
"CDLCOUNTERATTACK": "A red candlestick with a long real body followed by a green candlestick with a smaller real body, where the green candle's real body is contained within the prior red candle's real body, indicating a potential trend reversal",
"CDLDARKCLOUDCOVER": "A green candlestick followed by a red candlestick, where the red candle's real body is partially contained within the prior green candle's real body, indicating a potential trend reversal",
"CDLDOJI": "A candlestick with the same opening and closing price, suggesting indecision in the market",
"CLDOJISTAR": "A doji with a small real body and long upper and lower shadows, where the doji is above or below the preceding trend, suggesting a potential trend reversal",
"CDLDRAGONFLYDOJI": "A doji with a long lower shadow and no upper shadow, suggesting bullishness",
"CDLENGULFING": "A red candlestick with a long real body that completely engulfs the prior green candlestick, indicating a potential trend reversal",
"CDLEVENINGDOJISTAR": "A doji with a small real body and long upper shadow, where the doji is above or below the preceding trend, suggesting a potential trend reversal",
"CDLEVENINGSTAR": "A small real body candle that gaps above or below a long real body candle, where the color of the small candle is opposite to that of the long candle, suggesting a potential trend reversal",
"CDLGAPSIDESIDEWHITE": "A green candlestick with no shadows and a high that is above the prior red candlestick's high and a low that is below the prior red candlestick's low, suggesting a potential trend reversal",
"CDLGRAVESTONEDOJI": "A doji with long upper and lower shadows and no real body, indicating potential trend reversal",
"CDLHAMMER": "A green or red candlestick with a small real body and a long lower shadow that is at least twice the length of the real body, indicating potential bullishness or bearishness",
"CDLHANGINGMAN": "A red or green candlestick with a small real body and a long lower shadow that is at least twice the length of the real body, where the candle is at the top of an uptrend, indicating potential bearishness",
"CDLHARAMI": "A red candlestick followed by a green candlestick with a real body that is contained within the prior red candlestick's real body, indicating a potential trend reversal",
"CDLHARAMICROSS": "A red candlestick followed by a doji, where the doji is contained within the prior red candlestick's real body, indicating a potential trend reversal",
"CDLHIGHWAVE": "A green or red candlestick with a long real body, no shadows, and a longer than average upper shadow, suggesting potential bullishness or bearishness",
"CDLHIKKAKE": "A gap followed by a doji, where the color of the doji is opposite to that of the preceding trend, suggesting a potential trend reversal",
"CDLHIKKAKEMOD": "A gap followed by a doji, where the color of the doji is opposite to that of the preceding trend and the doji is contained within the gap, suggesting a potential trend reversal",
"CDLHOMINGPIGEON": "A green candlestick followed by a doji, where the doji is contained within the prior green candle's real body, indicating a potential trend reversal",
"CDLIDENTICAL3CROWS": "Three red candlesticks in a row with identical real body lengths and lower closes, indicating a strong bearish trend",
"CDLINNECK": "A red or green candlestick with a long real body and no or very short shadows, where the real body is at the extreme end of the trend, indicating a potential trend reversal",
"CDLINVERTEDHAMMER": "A green or red candlestick with a small real body and a long upper shadow that is at least twice the length of the real body, indicating potential bullishness or bearishness",
"CDLKICKING": "A red or green candlestick with a long real body that follows a doji and gaps away from the doji, indicating a potential trend reversal",
"CDLKICKINGBYLENGTH": "A red or green candlestick with a long real body that follows a doji, where the real body is longer than the doji, indicating a potential trend reversal",
"CDLLADDERBOTTOM": "A pattern of three or more dojis where the prices are consistently getting higher, indicating a potential bullish trend",
"CDLLONGLEGGEDDOJI": "A doji with long upper and lower shadows, indicating potential trend reversal",
"CDLLONGLINE": "A green or red candlestick with a very long real body, indicating potential trend continuation",
"CDLMARUBOZU": "A green or red candlestick with no shadows, indicating potential trend continuation",
"CDLMATCHINGLOW": "A green or red candlestick with a low that is equal to the prior candlestick's low, indicating potential trend reversal or continuation",
"CDLMATHOLD": "A red candlestick followed by a green candlestick that has a high that is equal to the prior red candlestick's high, indicating potential trend reversal",
"CDLMORNINGDOJISTAR": "A doji with a small real body and long lower shadow, where the doji is above or below the preceding trend, suggesting a potential trend reversal",
"CDLMORNINGSTAR": "A small real body candle that gaps above or below a long real body candle, where the color of the small candle is opposite to that of the long candle, suggesting a potential trend reversal",
"CDLONNECK": "A red or green candlestick with a long real body and no or very short shadows, where the real body is at the extreme end of the trend, indicating a potential trend reversal",
"CDLPIERCING": "A green candlestick that opens below the prior red candlestick's low and closes above the midpoint of the prior red candlestick's real body, indicating potential bullishness",
"CDLRICKSHAWMAN": "A pattern of two or more dojis, indicating potential trend reversal or market indecision",
"CDLRISEFALL3METHODS": "A pattern of three candlesticks, where a long red candle is followed by a green candle that gaps above the red candle and a third red candle that closes within the gap, indicating a potential trend reversal",
"CDLSEPARATINGLINES": "A red candlestick followed by a green candlestick that has a higher high and a higher low, indicating potential bullishness",
"CDLSHOOTINGSTAR": "A red or green candlestick with a small real body and a long upper shadow that is at least twice the length of the real body, where the color of the small body is opposite to that of the preceding trend, indicating a potential trend reversal",
"CDLSHORTLINE": "A green or red candlestick with a short real body, indicating potential trend continuation",
"CDLSPINNINGTOP": "A green or red candlestick with a small real body and long upper and lower shadows, indicating market indecision",
"CDLSTALLEDPATTERN": "A pattern of two candlesticks where the first candle is a long red or green real body and the second candle is a spinning top, where the color of the spinning top is opposite to that of the first candle, indicating potential trend reversal",
"CDLSTICKSANDWICH": "A pattern of three candlesticks, where a green candle is sandwiched between two red candles with lower highs, indicating potential trend reversal",
"CDLTAKURI": "A green or red candlestick with a small real body and a long upper shadow, where the color of the small body is the same as that of the preceding trend, indicating potential trend continuation",
"CDLTASUKIGAP": "A pattern of two candlesticks, where the second candle opens above or below the first candle, gaps away, and then closes, indicating potential trend reversal or continuation",
"CDLTHRUSTING": "A pattern of two candlesticks, where the first candle is a long red or green real body and the second candle is a spinning top, where the color of the spinning top is the same as that of the first candle, indicating potential trend continuation",
"CDLTRISTAR": "A pattern of three dojis, where the middle doji is higher or lower than the first and last dojis, indicating potential trend reversal",
"CDLUNIQUE3RIVER": "A pattern of three candlesticks where a green candle is followed by three small red candles that are progressively lower, indicating potential trend reversal",
"CDLUPSIDEGAP2CROWS": "A pattern of three candlesticks, where a green candle is followed by a gap and then two red candles, indicating potential trend reversal",
"CDLXSIDEGAP3METHODS": "A pattern of three candlesticks, where a long red candle is followed by a gap and then a green candle that closes within the gap, indicating a potential trend reversal"
}
|